1
1
'use strict'
2
2
3
+ const { readFileSync } = require ( 'fs' )
3
4
const should = require ( 'should' )
4
5
const path = require ( 'path' )
5
- const { readFileSync, writeFileSync } = require ( 'fs' )
6
6
7
7
const browserless = require ( '..' )
8
8
@@ -12,17 +12,16 @@ describe('browserless', () => {
12
12
browserless
13
13
. html ( 'https://www.instagram.com/p/BWUDBntl3_Z/' )
14
14
. then ( html => {
15
- writeFileSync ( path . resolve ( 'test/example.html' ) , html , 'utf8' )
16
- should ( html ) . be . eql ( readFileSync ( 'test/example.html' , 'utf8' ) )
15
+ should ( html . includes ( 'DOCTYPE' ) ) . be . true ( )
17
16
} ) )
18
17
} )
19
18
20
19
describe ( '.screenshot' , ( ) => {
21
20
describe ( 'format' , ( ) => {
22
21
it ( 'png' , ( ) =>
23
22
browserless . screenshot ( 'http://example.com' ) . then ( tmpStream => {
24
- should ( readFileSync ( tmpStream . path ) ) . be . eql (
25
- readFileSync ( 'test/example.png' )
23
+ should ( readFileSync ( tmpStream . path ) . length ) . be . eql (
24
+ readFileSync ( 'test/example.png' ) . length
26
25
)
27
26
should ( path . extname ( tmpStream . path ) ) . be . equal ( '.png' )
28
27
tmpStream . cleanupSync ( )
@@ -32,8 +31,8 @@ describe('browserless', () => {
32
31
browserless
33
32
. screenshot ( 'http://example.com' , { type : 'jpeg' } )
34
33
. then ( tmpStream => {
35
- should ( readFileSync ( tmpStream . path ) ) . be . eql (
36
- readFileSync ( 'test/example.jpeg' )
34
+ should ( readFileSync ( tmpStream . path ) . length ) . be . eql (
35
+ readFileSync ( 'test/example.jpeg' ) . length
37
36
)
38
37
should ( path . extname ( tmpStream . path ) ) . be . equal ( '.jpeg' )
39
38
tmpStream . cleanupSync ( )
@@ -45,8 +44,8 @@ describe('browserless', () => {
45
44
browserless
46
45
. screenshot ( 'http://example.com' , { device : 'iPhone 6' } )
47
46
. then ( tmpStream => {
48
- should ( readFileSync ( tmpStream . path ) ) . be . eql (
49
- readFileSync ( 'test/example-iphone.png' )
47
+ should ( readFileSync ( tmpStream . path ) . length ) . be . eql (
48
+ readFileSync ( 'test/example-iphone.png' ) . length
50
49
)
51
50
tmpStream . cleanupSync ( )
52
51
} ) )
0 commit comments