Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

Commit 01ea85b

Browse files
committed
Improve barrier test.
1 parent e9cb4a6 commit 01ea85b

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

spec/unit/webdriver_proxy_spec.ts

+14-5
Original file line numberDiff line numberDiff line change
@@ -28,17 +28,19 @@ describe('WebDriver Proxy', () => {
2828
// Verify that all nock endpoints were called.
2929
expect(resp.writeHead.calls.first().args[0]).toBe(200);
3030
expect(data).toEqual(JSON.stringify(responseData));
31-
scope.done();
31+
scope.isDone();
3232
done();
3333
});
3434
});
3535

3636
it('waits for barriers', (done) => {
37+
const WD_URL = '/session/sessionId/url';
38+
3739
let req = new InMemoryReader() as any;
3840
let resp = new InMemoryWriter() as any;
3941
resp.writeHead = jasmine.createSpy('spy');
40-
req.url = '/session/sessionId/get';
41-
req.method = 'GET';
42+
req.url = WD_URL;
43+
req.method = 'POST';
4244

4345
let barrier = new TestBarrier();
4446
let barrierDone = false;
@@ -51,11 +53,18 @@ describe('WebDriver Proxy', () => {
5153
});
5254
};
5355

56+
let scope = nock(proxy.seleniumAddress).post(WD_URL).reply(() => {
57+
// Shouldn't see the command until the barrier is done.
58+
expect(barrierDone).toBeTruthy();
59+
return [200];
60+
});
61+
5462
proxy.addBarrier(barrier);
5563
proxy.requestListener(req, resp);
5664

5765
resp.onEnd(() => {
5866
expect(barrierDone).toBeTruthy();
67+
scope.isDone();
5968
done();
6069
});
6170
});
@@ -76,7 +85,7 @@ describe('WebDriver Proxy', () => {
7685
barrier.onCommand = (command: WebDriverCommand): Promise<void> => {
7786
command.on('response', () => {
7887
expect(command.responseData['url']).toEqual(RESPONSE.url);
79-
scope.done();
88+
scope.isDone();
8089
done();
8190
});
8291
return undefined;
@@ -102,7 +111,7 @@ describe('WebDriver Proxy', () => {
102111
resp.onEnd((data) => {
103112
expect(resp.writeHead.calls.first().args[0]).toBe(500);
104113
expect(data).toEqual(ERR.toString());
105-
scope.done();
114+
scope.isDone();
106115
done();
107116
});
108117
});

0 commit comments

Comments
 (0)