Skip to content

Commit b3ca4af

Browse files
authored
chore: misc test fixes (#2857)
1 parent 6209d14 commit b3ca4af

File tree

5 files changed

+19
-34
lines changed

5 files changed

+19
-34
lines changed

src/rpc/channels.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,14 +274,12 @@ export type RequestInitializer = {
274274

275275
export interface RouteChannel extends Channel {
276276
abort(params: { errorCode: string }): Promise<void>;
277-
continue(params: { overrides: { method?: string, headers?: types.Headers, postData?: string } }): Promise<void>;
277+
continue(params: { method?: string, headers?: types.Headers, postData?: string }): Promise<void>;
278278
fulfill(params: {
279-
response: {
280-
status?: number,
281-
headers?: types.Headers,
282-
body: string,
283-
isBase64: boolean,
284-
}
279+
status?: number,
280+
headers?: types.Headers,
281+
body: string,
282+
isBase64: boolean,
285283
}): Promise<void>;
286284
}
287285
export type RouteInitializer = {

src/rpc/client/network.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,11 @@ export class Route extends ChannelOwner<RouteChannel, RouteInitializer> {
152152

153153
async fulfill(response: types.FulfillResponse & { path?: string }) {
154154
const normalized = await normalizeFulfillParameters(response);
155-
await this._channel.fulfill({ response: normalized });
155+
await this._channel.fulfill(normalized);
156156
}
157157

158158
async continue(overrides: { method?: string; headers?: types.Headers; postData?: string } = {}) {
159-
await this._channel.continue({ overrides });
159+
await this._channel.continue(overrides);
160160
}
161161
}
162162

src/rpc/server/networkDispatchers.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,15 @@ export class RouteDispatcher extends Dispatcher<Route, RouteInitializer> impleme
8080
});
8181
}
8282

83-
async continue(params: { overrides: { method?: string, headers?: types.Headers, postData?: string } }): Promise<void> {
84-
await this._object.continue(params.overrides);
83+
async continue(params: { method?: string, headers?: types.Headers, postData?: string }): Promise<void> {
84+
await this._object.continue(params);
8585
}
8686

87-
async fulfill(params: { response: { status?: number, headers?: types.Headers, contentType?: string, body: string, isBase64: boolean } }): Promise<void> {
88-
const { response } = params;
87+
async fulfill(params: { status?: number, headers?: types.Headers, contentType?: string, body: string, isBase64: boolean }): Promise<void> {
8988
await this._object.fulfill({
90-
status: response.status,
91-
headers: response.headers,
92-
body: response.isBase64 ? Buffer.from(response.body, 'base64') : response.body,
89+
status: params.status,
90+
headers: params.headers,
91+
body: params.isBase64 ? Buffer.from(params.body, 'base64') : params.body,
9392
});
9493
}
9594

test/jshandle.spec.js

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,6 @@ describe('Page.evaluateHandle', function() {
9090
}, { foo: 42 });
9191
expect(result).toEqual({});
9292
});
93-
it('should use the same JS wrappers', async({page, server}) => {
94-
const aHandle = await page.evaluateHandle(() => {
95-
window.FOO = 123;
96-
return window;
97-
});
98-
expect(await page.evaluate(e => e.FOO, aHandle)).toBe(123);
99-
});
10093
it('should work with primitives', async({page, server}) => {
10194
const aHandle = await page.evaluateHandle(() => {
10295
window.FOO = 123;
@@ -152,22 +145,17 @@ describe('JSHandle.jsonValue', function() {
152145
const json = await aHandle.jsonValue();
153146
expect(json).toEqual({foo: 'bar'});
154147
});
155-
it('should not work with dates', async({page, server}) => {
148+
it('should work with dates', async({page, server}) => {
156149
const dateHandle = await page.evaluateHandle(() => new Date('2017-09-26T00:00:00.000Z'));
157150
const json = await dateHandle.jsonValue();
158-
expect(json).toEqual({});
151+
expect(json instanceof Date).toBeTruthy();
159152
});
160153
it('should throw for circular objects', async({page, server}) => {
161154
const windowHandle = await page.evaluateHandle('window');
162155
let error = null;
163156
await windowHandle.jsonValue().catch(e => error = e);
164157
expect(error.message).toContain('Argument is a circular structure');
165158
});
166-
it('should work with tricky values', async({page, server}) => {
167-
const aHandle = await page.evaluateHandle(() => ({a: 1}));
168-
const json = await aHandle.jsonValue();
169-
expect(json).toEqual({a: 1});
170-
});
171159
});
172160

173161
describe('JSHandle.getProperties', function() {

test/keyboard.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ describe('Keyboard', function() {
3434
await page.type('textarea', 'Hello World!');
3535
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('Hello World!');
3636
for (let i = 0; i < 'World!'.length; i++)
37-
page.keyboard.press('ArrowLeft');
37+
await page.keyboard.press('ArrowLeft');
3838
await page.keyboard.type('inserted ');
3939
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('Hello inserted World!');
40-
page.keyboard.down('Shift');
40+
await page.keyboard.down('Shift');
4141
for (let i = 0; i < 'inserted '.length; i++)
42-
page.keyboard.press('ArrowLeft');
43-
page.keyboard.up('Shift');
42+
await page.keyboard.press('ArrowLeft');
43+
await page.keyboard.up('Shift');
4444
await page.keyboard.press('Backspace');
4545
expect(await page.evaluate(() => document.querySelector('textarea').value)).toBe('Hello World!');
4646
});

0 commit comments

Comments
 (0)