@@ -53,30 +53,97 @@ describe('Browser Builder', () => {
53
53
it ( 'works with service worker' , ( done ) => {
54
54
host . writeMultipleFiles ( {
55
55
'src/ngsw-config.json' : JSON . stringify ( manifest ) ,
56
+ 'src/assets/folder-asset.txt' : 'folder-asset.txt' ,
56
57
} ) ;
57
58
58
59
const overrides = { serviceWorker : true } ;
59
60
runTargetSpec ( host , browserTargetSpec , overrides ) . pipe (
60
61
tap ( buildEvent => {
61
62
expect ( buildEvent . success ) . toBe ( true ) ;
62
63
expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/ngsw.json' ) ) ) ;
64
+ const ngswJson = JSON . parse ( virtualFs . fileBufferToString (
65
+ host . scopedSync ( ) . read ( normalize ( 'dist/ngsw.json' ) ) ) ) ;
66
+ // Verify index and assets are there.
67
+ expect ( ngswJson ) . toEqual ( {
68
+ configVersion : 1 ,
69
+ index : '/index.html' ,
70
+ assetGroups : [
71
+ {
72
+ name : 'app' ,
73
+ installMode : 'prefetch' ,
74
+ updateMode : 'prefetch' ,
75
+ urls : [
76
+ '/favicon.ico' ,
77
+ '/index.html' ,
78
+ ] ,
79
+ patterns : [ ] ,
80
+ } ,
81
+ {
82
+ name : 'assets' ,
83
+ installMode : 'lazy' ,
84
+ updateMode : 'prefetch' ,
85
+ urls : [
86
+ '/assets/folder-asset.txt' ,
87
+ ] ,
88
+ patterns : [ ] ,
89
+ } ,
90
+ ] ,
91
+ dataGroups : [ ] ,
92
+ hashTable : {
93
+ '/favicon.ico' : '460fcbd48b20fcc32b184388606af1238c890dba' ,
94
+ '/assets/folder-asset.txt' : '617f202968a6a81050aa617c2e28e1dca11ce8d4' ,
95
+ '/index.html' : '3e659d6e536916b7d178d02a2e6e5492f868bf68' ,
96
+ } ,
97
+ } ) ;
63
98
} ) ,
64
99
) . subscribe ( undefined , done . fail , done ) ;
65
100
} , Timeout . Basic ) ;
66
101
67
102
it ( 'works with service worker and baseHref' , ( done ) => {
68
103
host . writeMultipleFiles ( {
69
104
'src/ngsw-config.json' : JSON . stringify ( manifest ) ,
105
+ 'src/assets/folder-asset.txt' : 'folder-asset.txt' ,
70
106
} ) ;
71
107
72
108
const overrides = { serviceWorker : true , baseHref : '/foo/bar' } ;
73
109
runTargetSpec ( host , browserTargetSpec , overrides ) . pipe (
74
110
tap ( buildEvent => {
75
111
expect ( buildEvent . success ) . toBe ( true ) ;
76
112
expect ( host . scopedSync ( ) . exists ( normalize ( 'dist/ngsw.json' ) ) ) ;
77
- expect ( virtualFs . fileBufferToString (
78
- host . scopedSync ( ) . read ( normalize ( 'dist/ngsw.json' ) ) ,
79
- ) ) . toMatch ( / " \/ f o o \/ b a r \/ i n d e x .h t m l " / ) ;
113
+ const ngswJson = JSON . parse ( virtualFs . fileBufferToString (
114
+ host . scopedSync ( ) . read ( normalize ( 'dist/ngsw.json' ) ) ) ) ;
115
+ // Verify index and assets include the base href.
116
+ expect ( ngswJson ) . toEqual ( {
117
+ configVersion : 1 ,
118
+ index : '/foo/bar/index.html' ,
119
+ assetGroups : [
120
+ {
121
+ name : 'app' ,
122
+ installMode : 'prefetch' ,
123
+ updateMode : 'prefetch' ,
124
+ urls : [
125
+ '/foo/bar/favicon.ico' ,
126
+ '/foo/bar/index.html' ,
127
+ ] ,
128
+ patterns : [ ] ,
129
+ } ,
130
+ {
131
+ name : 'assets' ,
132
+ installMode : 'lazy' ,
133
+ updateMode : 'prefetch' ,
134
+ urls : [
135
+ '/foo/bar/assets/folder-asset.txt' ,
136
+ ] ,
137
+ patterns : [ ] ,
138
+ } ,
139
+ ] ,
140
+ dataGroups : [ ] ,
141
+ hashTable : {
142
+ '/foo/bar/favicon.ico' : '460fcbd48b20fcc32b184388606af1238c890dba' ,
143
+ '/foo/bar/assets/folder-asset.txt' : '617f202968a6a81050aa617c2e28e1dca11ce8d4' ,
144
+ '/foo/bar/index.html' : '5b53fa9e07e4111b8ef84613fb989a56fee502b0' ,
145
+ } ,
146
+ } ) ;
80
147
} ) ,
81
148
) . subscribe ( undefined , done . fail , done ) ;
82
149
} , Timeout . Basic ) ;
0 commit comments