forked from webrtc/samples
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtest.js
More file actions
51 lines (44 loc) · 1.72 KB
/
test.js
File metadata and controls
51 lines (44 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree.
*/
const webdriver = require('selenium-webdriver');
const seleniumHelpers = require('../../../../../test/webdriver');
let driver;
const path = '/src/content/datachannel/basic/index.html';
const url = `${process.env.BASEURL ? process.env.BASEURL : ('file://' + process.cwd())}${path}`;
describe('datachannel basic', () => {
beforeAll(async () => {
driver = await seleniumHelpers.buildDriver();
});
afterAll(() => {
return driver.quit();
});
beforeEach(() => {
return driver.get(url);
});
it('transfers text', async () => {
const text = 'Hello world';
await driver.findElement(webdriver.By.id('startButton')).click();
await Promise.all([
driver.wait(() => driver.executeScript(() => {
return pc1 && pc1.connectionState === 'connected'; // eslint-disable-line no-undef
})),
await driver.wait(() => driver.executeScript(() => {
return pc2 && pc2.connectionState === 'connected'; // eslint-disable-line no-undef
})),
]);
await driver.wait(() => driver.findElement(webdriver.By.id('sendButton')).isEnabled());
await driver.findElement(webdriver.By.id('dataChannelSend'))
.sendKeys(text);
await driver.findElement(webdriver.By.id('sendButton')).click();
await driver.wait(() => driver.executeScript(() => {
return document.getElementById('dataChannelReceive').value.length > 0;
}));
const value = await driver.findElement(webdriver.By.id('dataChannelReceive')).getAttribute('value');
expect(value).toBe(text);
});
});