Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
grantcopley committed Sep 29, 2024
1 parent e4df642 commit ecf4fa9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
30 changes: 20 additions & 10 deletions test-harness/tests/specs/CBWIRESpec.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,6 @@ component extends="coldbox.system.testing.BaseTestCase" {
var result = CBWIREController.wire( "test.should_not_render_cbwire_script_tags" );
expect( result ).notToInclude( "<cbwire:script>" );
expect( result ).notToInclude( "</cbwire:script>" );
expect( result ).notToInclude( "This should not be rendered" );
} );

it( "should not render cbwire:assets tags", function() {
Expand All @@ -301,17 +300,11 @@ component extends="coldbox.system.testing.BaseTestCase" {
expect( result ).notToInclude( "tailwind.min.css" );
} );

fit( "should track scripts and assets in snapshot memo", function() {
var result = CBWIREController.wire( "test.should_track_scripts_and_assets_in_snapshot_memo" );
it( "should track scripts in snapshot memo", function() {
var result = CBWIREController.wire( "test.should_track_scripts_in_snapshot_memo" );
var parsing = parseRendering( result );
writeDump( parsing.snapshot.memo );
abort;
expect( parsing.snapshot.memo.scripts ).toBeArray();
expect( parsing.snapshot.memo.scripts.len() ).toBe( 1 );
expect( parsing.snapshot.memo.scripts[ 1 ] ).toBe( "https://cdn.jsdelivr.net/npm/[email protected]/dist/alpine.min.js" );
expect( parsing.snapshot.memo.assets ).toBeArray();
expect( parsing.snapshot.memo.assets.len() ).toBe( 1 );
expect( parsing.snapshot.memo.assets[ 1 ] ).toBe( "tailwind.min.css" );
expect( parsing.snapshot.memo.scripts.len() ).toBe( 2 );
} );

xit( "should provide original path to component when there is a template rendering error", function() {
Expand Down Expand Up @@ -463,6 +456,23 @@ component extends="coldbox.system.testing.BaseTestCase" {
settings.trimStringValues = false;
} );

it( "should track cbwire:assets in http response", function() {
var payload = incomingRequest(
memo = {
"name": "test.should_track_cbwire_assets_in_http_response",
"id": "Z1Ruz1tGMPXSfw7osBW2",
"children": []
},
data = {},
calls = [],
updates = {}
);
var result = cbwireController.handleRequest( payload, event );
expect( result.assets.count() ).toBe( 1 );
var keys = result.assets.keyArray();
expect( result.assets[ keys.first() ] ).toInclude( "tailwind.min.css" );
} );

it( "should support $refresh action", function() {
var payload = incomingRequest(
memo = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<cfoutput>
<div>
<h1>Should track assets in http response</h1>
</div>
</cfoutput>

<cfscript>
// @startWire
// @endWire
</cfscript>

<cbwire:assets>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
</cbwire:script>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<cfoutput>
<div>
<h1>Should track scripts and assets</h1>
<h1>Should track scripts</h1>
</div>
</cfoutput>

Expand All @@ -20,8 +20,4 @@
<script>
console.log('This should be tracked also');
</script>
</cbwire:script>

<cbwire:assets>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css">
</cbwire:script>

0 comments on commit ecf4fa9

Please sign in to comment.