@@ -9,10 +9,13 @@ describe('the deploy plugin object', function() {
99 var plugin ;
1010 var promise ;
1111 var distDir ;
12+ var jsonBlueprint ;
13+ var context ;
1214
1315 before ( function ( ) {
1416 fakeRoot = process . cwd ( ) + '/tests/fixtures' ;
1517 distDir = 'dist' ;
18+ jsonBlueprint = false ;
1619 } ) ;
1720
1821 beforeEach ( function ( ) {
@@ -28,7 +31,7 @@ describe('the deploy plugin object', function() {
2831 name : 'json-config'
2932 } ) ;
3033
31- var context = {
34+ context = {
3235 ui : mockUi ,
3336 config : {
3437 'json-config' : {
@@ -44,6 +47,10 @@ describe('the deploy plugin object', function() {
4447 }
4548 } ;
4649
50+ if ( jsonBlueprint ) {
51+ context . config [ 'json-config' ] . jsonBlueprint = jsonBlueprint ;
52+ }
53+
4754 plugin . beforeHook ( context ) ;
4855 plugin . configure ( context ) ;
4956
@@ -63,7 +70,8 @@ describe('the deploy plugin object', function() {
6370 it ( 'generates index.json from index.html' , function ( ) {
6471 return assert . isFulfilled ( promise )
6572 . then ( function ( ) {
66- var json = require ( fakeRoot + '/dist/index.json' ) ;
73+ var contents = fs . readFileSync ( fakeRoot + '/dist/index.json' ) ;
74+ var json = JSON . parse ( contents ) ;
6775
6876 assert . equal ( Object . keys ( json ) . length , 4 ) ;
6977
@@ -73,6 +81,7 @@ describe('the deploy plugin object', function() {
7381 assert . deepEqual ( json . link [ 1 ] , { rel : 'stylesheet' , href : 'assets/app.css' } ) ;
7482 assert . deepEqual ( json . script [ 0 ] , { src : 'assets/vendor.js' , integrity : 'sha256-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC' } ) ;
7583 assert . deepEqual ( json . script [ 1 ] , { src : 'assets/app.js' } ) ;
84+ assert . deepEqual ( json . script [ 2 ] , { } ) ;
7685 } ) ;
7786 } ) ;
7887
@@ -97,5 +106,31 @@ describe('the deploy plugin object', function() {
97106 } ) ;
98107 } ) ;
99108 } ) ;
109+
110+ describe ( 'when we ask for script tag contents' , function ( ) {
111+ before ( function ( ) {
112+ jsonBlueprint = {
113+ script : {
114+ selector : 'script' ,
115+ attributes : [ ] ,
116+ includeContent : true ,
117+ }
118+ } ;
119+ } ) ;
120+
121+ it ( 'provides the contents of the script tag' , function ( ) {
122+ return assert . isFulfilled ( promise )
123+ . then ( function ( ) {
124+ var contents = fs . readFileSync ( fakeRoot + '/dist/index.json' ) ;
125+ var json = JSON . parse ( contents ) ;
126+
127+ assert . equal ( Object . keys ( json ) . length , 1 ) ;
128+
129+ assert . deepEqual ( json . script [ 0 ] , { } ) ;
130+ assert . deepEqual ( json . script [ 1 ] , { } ) ;
131+ assert . deepEqual ( json . script [ 2 ] , { content : "var a = 'foo';" } ) ;
132+ } ) ;
133+ } ) ;
134+ } ) ;
100135 } ) ;
101136} ) ;
0 commit comments