@@ -9,10 +9,13 @@ describe('the deploy plugin object', function() {
9
9
var plugin ;
10
10
var promise ;
11
11
var distDir ;
12
+ var jsonBlueprint ;
13
+ var context ;
12
14
13
15
before ( function ( ) {
14
16
fakeRoot = process . cwd ( ) + '/tests/fixtures' ;
15
17
distDir = 'dist' ;
18
+ jsonBlueprint = false ;
16
19
} ) ;
17
20
18
21
beforeEach ( function ( ) {
@@ -28,7 +31,7 @@ describe('the deploy plugin object', function() {
28
31
name : 'json-config'
29
32
} ) ;
30
33
31
- var context = {
34
+ context = {
32
35
ui : mockUi ,
33
36
config : {
34
37
'json-config' : {
@@ -44,6 +47,10 @@ describe('the deploy plugin object', function() {
44
47
}
45
48
} ;
46
49
50
+ if ( jsonBlueprint ) {
51
+ context . config [ 'json-config' ] . jsonBlueprint = jsonBlueprint ;
52
+ }
53
+
47
54
plugin . beforeHook ( context ) ;
48
55
plugin . configure ( context ) ;
49
56
@@ -63,7 +70,8 @@ describe('the deploy plugin object', function() {
63
70
it ( 'generates index.json from index.html' , function ( ) {
64
71
return assert . isFulfilled ( promise )
65
72
. 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 ) ;
67
75
68
76
assert . equal ( Object . keys ( json ) . length , 4 ) ;
69
77
@@ -73,6 +81,7 @@ describe('the deploy plugin object', function() {
73
81
assert . deepEqual ( json . link [ 1 ] , { rel : 'stylesheet' , href : 'assets/app.css' } ) ;
74
82
assert . deepEqual ( json . script [ 0 ] , { src : 'assets/vendor.js' , integrity : 'sha256-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC' } ) ;
75
83
assert . deepEqual ( json . script [ 1 ] , { src : 'assets/app.js' } ) ;
84
+ assert . deepEqual ( json . script [ 2 ] , { } ) ;
76
85
} ) ;
77
86
} ) ;
78
87
@@ -97,5 +106,31 @@ describe('the deploy plugin object', function() {
97
106
} ) ;
98
107
} ) ;
99
108
} ) ;
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
+ } ) ;
100
135
} ) ;
101
136
} ) ;
0 commit comments