@@ -47,7 +47,8 @@ test('hide elements using the `hide` option', async t => {
47
47
const fixture = path . join ( __dirname , 'fixtures' , 'test-hide-element.html' ) ;
48
48
const stream = screenshotStream ( fixture , '100x100' , { hide : [ 'div' ] } ) ;
49
49
const png = new PNG ( await getStream . buffer ( stream ) ) ;
50
- png . decode ( pixels => t . is ( pixels [ 0 ] , 255 ) ) ;
50
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
51
+ t . is ( pixels [ 0 ] , 255 ) ;
51
52
} ) ;
52
53
53
54
test ( 'ignore multiline page errors' , async t => {
@@ -93,7 +94,7 @@ test('have a `format` option', async t => {
93
94
test ( 'have a `css` option' , async t => {
94
95
const stream = screenshotStream ( 'http://yeoman.io' , '1024x768' , { css : '.mobile-bar { background-color: red !important; }' } ) ;
95
96
const png = new PNG ( await getStream . buffer ( stream ) ) ;
96
- const pixels = await rfpify ( png . decode . bind ( png ) , Promise ) ( ) ;
97
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
97
98
t . is ( pixels [ 0 ] , 255 ) ;
98
99
t . is ( pixels [ 1 ] , 0 ) ;
99
100
t . is ( pixels [ 2 ] , 0 ) ;
@@ -102,7 +103,7 @@ test('have a `css` option', async t => {
102
103
test ( 'have a `css` file' , async t => {
103
104
const stream = screenshotStream ( 'http://yeoman.io' , '1024x768' , { css : 'fixtures/style.css' } ) ;
104
105
const png = new PNG ( await getStream . buffer ( stream ) ) ;
105
- const pixels = await rfpify ( png . decode . bind ( png ) , Promise ) ( ) ;
106
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
106
107
t . is ( pixels [ 0 ] , 0 ) ;
107
108
t . is ( pixels [ 1 ] , 128 ) ;
108
109
t . is ( pixels [ 2 ] , 0 ) ;
@@ -111,7 +112,7 @@ test('have a `css` file', async t => {
111
112
test ( 'have a `script` option' , async t => {
112
113
const stream = screenshotStream ( 'http://yeoman.io' , '1024x768' , { script : 'document.querySelector(\'.mobile-bar\').style.backgroundColor = \'red\';' } ) ;
113
114
const png = new PNG ( await getStream . buffer ( stream ) ) ;
114
- const pixels = await rfpify ( png . decode . bind ( png ) , Promise ) ( ) ;
115
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
115
116
t . is ( pixels [ 0 ] , 255 ) ;
116
117
t . is ( pixels [ 1 ] , 0 ) ;
117
118
t . is ( pixels [ 2 ] , 0 ) ;
@@ -120,7 +121,7 @@ test('have a `script` option', async t => {
120
121
test ( 'have a `js` file' , async t => {
121
122
const stream = screenshotStream ( 'http://yeoman.io' , '1024x768' , { script : 'fixtures/script.js' } ) ;
122
123
const png = new PNG ( await getStream . buffer ( stream ) ) ;
123
- const pixels = await rfpify ( png . decode . bind ( png ) , Promise ) ( ) ;
124
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
124
125
t . is ( pixels [ 0 ] , 0 ) ;
125
126
t . is ( pixels [ 1 ] , 128 ) ;
126
127
t . is ( pixels [ 2 ] , 0 ) ;
@@ -133,7 +134,7 @@ test('send cookie', async t => {
133
134
} ) ;
134
135
135
136
const png = new PNG ( await getStream . buffer ( stream ) ) ;
136
- const pixels = await rfpify ( png . decode . bind ( png ) , Promise ) ( ) ;
137
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
137
138
138
139
t . is ( pixels [ 0 ] , 0 ) ;
139
140
await s . close ( ) ;
@@ -150,7 +151,7 @@ test('send cookie using an object', async t => {
150
151
} ) ;
151
152
152
153
const png = new PNG ( await getStream . buffer ( stream ) ) ;
153
- const pixels = await rfpify ( png . decode . bind ( png ) , Promise ) ( ) ;
154
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
154
155
155
156
t . is ( pixels [ 0 ] , 0 ) ;
156
157
await s . close ( ) ;
@@ -165,15 +166,15 @@ test('send headers', async t => {
165
166
}
166
167
} ) ;
167
168
168
- t . is ( ( await rfpify ( s . once . bind ( s ) , Promise ) ( '/' ) ) . headers . foobar , 'unicorn' ) ;
169
+ t . is ( ( await rfpify ( s . once . bind ( s ) ) ( '/' ) ) . headers . foobar , 'unicorn' ) ;
169
170
await s . close ( ) ;
170
171
} ) ;
171
172
172
173
test ( 'handle redirects' , async t => {
173
174
const s = await server ( ) ;
174
175
const stream = screenshotStream ( `${ s . url } /redirect` , '100x100' ) ;
175
176
const png = new PNG ( await getStream . buffer ( stream ) ) ;
176
- const pixels = await rfpify ( png . decode . bind ( png ) , Promise ) ( ) ;
177
+ const pixels = await rfpify ( png . decode . bind ( png ) ) ( ) ;
177
178
t . is ( pixels [ 0 ] , 0 ) ;
178
179
await s . close ( ) ;
179
180
} ) ;
@@ -183,7 +184,7 @@ test('resource timeout', async t => {
183
184
const stream = screenshotStream ( s . url , '100x100' , { timeout : 1 } ) ;
184
185
185
186
await Promise . race ( [
186
- rfpify ( s . once . bind ( s ) , Promise ) ( '/' ) . then ( ( ) => t . fail ( 'Expected resource timed out error' ) ) ,
187
+ rfpify ( s . once . bind ( s ) ) ( '/' ) . then ( ( ) => t . fail ( 'Expected resource timed out error' ) ) ,
187
188
t . throws ( getStream ( stream ) , `Resource timed out #1 (Network timeout on resource.) → ${ s . url } /` )
188
189
] ) ;
189
190
0 commit comments