1- import should from 'should' ;
1+ import * as chai from 'chai' ;
2+ chai . should ( ) ;
3+
24import '../../utils/assertions.js' ;
35import nock from 'nock' ;
46import fs from 'fs-extra' ;
@@ -72,18 +74,21 @@ describe('Functional: base', function() {
7274 // should return right result
7375 result . should . be . instanceOf ( Array ) . and . have . length ( 3 ) ;
7476
75- result [ 0 ] . should . have . properties ( { url : 'http://example.com/' , filename : 'index.html' } ) ;
76- result [ 0 ] . should . have . properties ( 'children' ) ;
77+ result [ 0 ] . should . have . property ( 'url' , 'http://example.com/' ) ;
78+ result [ 0 ] . should . have . property ( 'filename' , 'index.html' ) ;
79+ result [ 0 ] . should . have . property ( 'children' ) ;
7780 result [ 0 ] . children . should . be . instanceOf ( Array ) . and . have . length ( 4 ) ;
7881 result [ 0 ] . children [ 0 ] . should . be . instanceOf ( Resource ) ;
7982
80- result [ 1 ] . should . have . properties ( { url : 'http://example.com/about' , filename : 'about.html' } ) ;
81- result [ 1 ] . should . have . properties ( 'children' ) ;
83+ result [ 1 ] . should . have . property ( 'url' , 'http://example.com/about' ) ;
84+ result [ 1 ] . should . have . property ( 'filename' , 'about.html' ) ;
85+ result [ 1 ] . should . have . property ( 'children' ) ;
8286 result [ 1 ] . children . should . be . instanceOf ( Array ) . and . have . length ( 4 ) ;
8387 result [ 1 ] . children [ 0 ] . should . be . instanceOf ( Resource ) ;
8488
85- result [ 2 ] . should . have . properties ( { url : 'http://blog.example.com/' , filename : 'blog.html' } ) ; // url after redirect
86- result [ 2 ] . should . have . properties ( 'children' ) ;
89+ result [ 2 ] . should . have . property ( 'url' , 'http://blog.example.com/' ) ; // url after redirect
90+ result [ 2 ] . should . have . property ( 'filename' , 'blog.html' ) ;
91+ result [ 2 ] . should . have . property ( 'children' ) ;
8792 result [ 2 ] . children . should . be . instanceOf ( Array ) . and . have . length ( 1 ) ;
8893 result [ 2 ] . children [ 0 ] . should . be . instanceOf ( Resource ) ;
8994
@@ -102,7 +107,7 @@ describe('Functional: base', function() {
102107 // all sources in index.html should be replaced with local paths
103108 let $ = cheerio . load ( fs . readFileSync ( testDirname + '/index.html' ) . toString ( ) ) ;
104109 $ ( 'link[rel="stylesheet"]' ) . attr ( 'href' ) . should . be . eql ( 'css/index.css' ) ;
105- $ ( 'style' ) . html ( ) . should . containEql ( 'img/background.png' ) ;
110+ $ ( 'style' ) . html ( ) . should . contain ( 'img/background.png' ) ;
106111 $ ( 'img' ) . attr ( 'src' ) . should . be . eql ( 'img/cat.jpg' ) ;
107112 $ ( 'script' ) . attr ( 'src' ) . should . be . eql ( 'js/script.min.js' ) ;
108113
@@ -115,22 +120,22 @@ describe('Functional: base', function() {
115120
116121 // all sources in index.css should be replaces with local files recursively
117122 const indexCss = fs . readFileSync ( testDirname + '/css/index.css' ) . toString ( ) ;
118- indexCss . should . not . containEql ( 'files/index-import-1.css' ) ;
119- indexCss . should . not . containEql ( 'files/index-import-2.css' ) ;
120- indexCss . should . not . containEql ( 'http://example.com/files/index-image-1.png' ) ;
121- indexCss . should . containEql ( 'index-import-1.css' ) ;
122- indexCss . should . containEql ( 'index-import-2.css' ) ;
123- indexCss . should . containEql ( '../img/index-image-1.png' ) ;
123+ indexCss . should . not . contain ( 'files/index-import-1.css' ) ;
124+ indexCss . should . not . contain ( 'files/index-import-2.css' ) ;
125+ indexCss . should . not . contain ( 'http://example.com/files/index-image-1.png' ) ;
126+ indexCss . should . contain ( 'index-import-1.css' ) ;
127+ indexCss . should . contain ( 'index-import-2.css' ) ;
128+ indexCss . should . contain ( '../img/index-image-1.png' ) ;
124129
125130 const indexImportCss = fs . readFileSync ( testDirname + '/css/index-import-2.css' ) . toString ( ) ;
126- indexImportCss . should . not . containEql ( 'http://example.com/files/index-image-2.png' ) ;
127- indexImportCss . should . containEql ( '../img/index-image-2.png' ) ;
131+ indexImportCss . should . not . contain ( 'http://example.com/files/index-image-2.png' ) ;
132+ indexImportCss . should . contain ( '../img/index-image-2.png' ) ;
128133
129134 // should deal with base tag in about.html and not load new resources
130135 // all sources in about.html should be replaced with already loaded local resources
131136 $ = cheerio . load ( fs . readFileSync ( testDirname + '/about.html' ) . toString ( ) ) ;
132137 $ ( 'link[rel="stylesheet"]' ) . attr ( 'href' ) . should . be . eql ( 'css/index.css' ) ;
133- $ ( 'style' ) . html ( ) . should . containEql ( 'img/background.png' ) ;
138+ $ ( 'style' ) . html ( ) . should . contain ( 'img/background.png' ) ;
134139 $ ( 'img' ) . attr ( 'src' ) . should . be . eql ( 'img/cat.jpg' ) ;
135140 $ ( 'script' ) . attr ( 'src' ) . should . be . eql ( 'js/script.min.js' ) ;
136141
@@ -144,21 +149,21 @@ describe('Functional: base', function() {
144149 return scrape ( { ...options , filenameGenerator : 'bySiteStructure' } ) . then ( function ( result ) {
145150 result . should . be . instanceOf ( Array ) . and . have . length ( 3 ) ;
146151
147- should ( result [ 0 ] . url ) . eql ( 'http://example.com/' ) ;
148- should ( result [ 0 ] . filename ) . equalFileSystemPath ( 'example.com/index.html' ) ;
149- result [ 0 ] . should . have . properties ( 'children' ) ;
152+ result [ 0 ] . url . should . eql ( 'http://example.com/' ) ;
153+ result [ 0 ] . filename . should . equalFileSystemPath ( 'example.com/index.html' ) ;
154+ result [ 0 ] . should . have . property ( 'children' ) ;
150155 result [ 0 ] . children . should . be . instanceOf ( Array ) . and . have . length ( 4 ) ;
151156 result [ 0 ] . children [ 0 ] . should . be . instanceOf ( Resource ) ;
152157
153- should ( result [ 1 ] . url ) . eql ( 'http://example.com/about' ) ;
154- should ( result [ 1 ] . filename ) . equalFileSystemPath ( 'example.com/about/index.html' ) ;
155- result [ 1 ] . should . have . properties ( 'children' ) ;
158+ result [ 1 ] . url . should . eql ( 'http://example.com/about' ) ;
159+ result [ 1 ] . filename . should . equalFileSystemPath ( 'example.com/about/index.html' ) ;
160+ result [ 1 ] . should . have . property ( 'children' ) ;
156161 result [ 1 ] . children . should . be . instanceOf ( Array ) . and . have . length ( 4 ) ;
157162 result [ 1 ] . children [ 0 ] . should . be . instanceOf ( Resource ) ;
158163
159- should ( result [ 2 ] . url ) . eql ( 'http://blog.example.com/' ) ; // url after redirect
160- should ( result [ 2 ] . filename ) . equalFileSystemPath ( 'blog.example.com/index.html' ) ;
161- result [ 2 ] . should . have . properties ( 'children' ) ;
164+ result [ 2 ] . url . should . eql ( 'http://blog.example.com/' ) ; // url after redirect
165+ result [ 2 ] . filename . should . equalFileSystemPath ( 'blog.example.com/index.html' ) ;
166+ result [ 2 ] . should . have . property ( 'children' ) ;
162167 result [ 2 ] . children . should . be . instanceOf ( Array ) . and . have . length ( 1 ) ;
163168 result [ 2 ] . children [ 0 ] . should . be . instanceOf ( Resource ) ;
164169
@@ -177,7 +182,7 @@ describe('Functional: base', function() {
177182 // all sources in index.html should be replaced with local paths
178183 let $ = cheerio . load ( fs . readFileSync ( testDirname + '/example.com/index.html' ) . toString ( ) ) ;
179184 $ ( 'link[rel="stylesheet"]' ) . attr ( 'href' ) . should . be . eql ( 'index.css' ) ;
180- $ ( 'style' ) . html ( ) . should . containEql ( 'background.png' ) ;
185+ $ ( 'style' ) . html ( ) . should . contain ( 'background.png' ) ;
181186 $ ( 'img' ) . attr ( 'src' ) . should . be . eql ( 'cat.jpg' ) ;
182187 $ ( 'script' ) . attr ( 'src' ) . should . be . eql ( 'script.min.js' ) ;
183188
@@ -190,18 +195,18 @@ describe('Functional: base', function() {
190195
191196 // all sources in index.css should be replaces with local files recursively
192197 const indexCss = fs . readFileSync ( testDirname + '/example.com/index.css' ) . toString ( ) ;
193- indexCss . should . containEql ( 'files/index-import-1.css' ) ;
194- indexCss . should . containEql ( 'files/index-import-2.css' ) ;
195- indexCss . should . containEql ( 'files/index-image-1.png' ) ;
198+ indexCss . should . contain ( 'files/index-import-1.css' ) ;
199+ indexCss . should . contain ( 'files/index-import-2.css' ) ;
200+ indexCss . should . contain ( 'files/index-image-1.png' ) ;
196201
197202 const indexImportCss = fs . readFileSync ( testDirname + '/example.com/files/index-import-2.css' ) . toString ( ) ;
198- indexImportCss . should . containEql ( 'index-image-2.png' ) ;
203+ indexImportCss . should . contain ( 'index-image-2.png' ) ;
199204
200205 // should deal with base tag in about.html and not load new resources
201206 // all sources in about.html should be replaced with already loaded local resources
202207 $ = cheerio . load ( fs . readFileSync ( testDirname + '/example.com/about/index.html' ) . toString ( ) ) ;
203208 $ ( 'link[rel="stylesheet"]' ) . attr ( 'href' ) . should . be . eql ( '../index.css' ) ;
204- $ ( 'style' ) . html ( ) . should . containEql ( '../background.png' ) ;
209+ $ ( 'style' ) . html ( ) . should . contain ( '../background.png' ) ;
205210 $ ( 'img' ) . attr ( 'src' ) . should . be . eql ( '../cat.jpg' ) ;
206211 $ ( 'script' ) . attr ( 'src' ) . should . be . eql ( '../script.min.js' ) ;
207212
0 commit comments