Skip to content

Commit

Permalink
test: testcase supplement (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Mar 17, 2019
1 parent 9850353 commit 6ef9035
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ Macaca WD Client is inspired by [admc/wd](//github.com/admc/wd), according to [W

## Contributors

|[<img src="https://avatars1.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars1.githubusercontent.com/u/1044425?v=4" width="100px;"/><br/><sub><b>ziczhu</b></sub>](https://github.com/ziczhu)<br/>|[<img src="https://avatars1.githubusercontent.com/u/2139038?v=4" width="100px;"/><br/><sub><b>zhangyuheng</b></sub>](https://github.com/zhangyuheng)<br/>|[<img src="https://avatars3.githubusercontent.com/u/4006436?v=4" width="100px;"/><br/><sub><b>meowtec</b></sub>](https://github.com/meowtec)<br/>|[<img src="https://avatars0.githubusercontent.com/u/2720537?v=4" width="100px;"/><br/><sub><b>tsj1107</b></sub>](https://github.com/tsj1107)<br/>|[<img src="https://avatars3.githubusercontent.com/u/1209810?v=4" width="100px;"/><br/><sub><b>paradite</b></sub>](https://github.com/paradite)<br/>|
|[<img src="https://avatars1.githubusercontent.com/u/1011681?v=4" width="100px;"/><br/><sub><b>xudafeng</b></sub>](https://github.com/xudafeng)<br/>|[<img src="https://avatars1.githubusercontent.com/u/1044425?v=4" width="100px;"/><br/><sub><b>ziczhu</b></sub>](https://github.com/ziczhu)<br/>|[<img src="https://avatars1.githubusercontent.com/u/2139038?v=4" width="100px;"/><br/><sub><b>zhangyuheng</b></sub>](https://github.com/zhangyuheng)<br/>|[<img src="https://avatars3.githubusercontent.com/u/4006436?v=4" width="100px;"/><br/><sub><b>meowtec</b></sub>](https://github.com/meowtec)<br/>|[<img src="https://avatars3.githubusercontent.com/u/1209810?v=4" width="100px;"/><br/><sub><b>paradite</b></sub>](https://github.com/paradite)<br/>|[<img src="https://avatars0.githubusercontent.com/u/2720537?v=4" width="100px;"/><br/><sub><b>tsj1107</b></sub>](https://github.com/tsj1107)<br/>|
| :---: | :---: | :---: | :---: | :---: | :---: |
[<img src="https://avatars3.githubusercontent.com/u/7878020?v=4" width="100px;"/><br/><sub><b>kobe990</b></sub>](https://github.com/kobe990)<br/>|[<img src="https://avatars0.githubusercontent.com/u/29451458?v=4" width="100px;"/><br/><sub><b>centy720</b></sub>](https://github.com/centy720)<br/>|[<img src="https://avatars3.githubusercontent.com/u/15025212?v=4" width="100px;"/><br/><sub><b>zhuyali</b></sub>](https://github.com/zhuyali)<br/>

This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sat Mar 16 2019 23:25:39 GMT+0800`.
This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Sun Mar 17 2019 14:38:35 GMT+0800`.

<!-- GITCONTRIBUTOR_END -->

Expand Down
51 changes: 51 additions & 0 deletions test/excecute.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
'use strict';

const assert = require('assert');

const { Server } = require('./helper');

const wd = require('../lib/macaca-wd');

describe('test/execute.test.js', function() {
let driver, server;
before(() => {
server = new Server();
server.start();
const remoteConfig = {
host: 'localhost',
port: 3456
};

driver = wd.promiseChainRemote(remoteConfig);
driver.configureHttp({
timeout: 20 * 1000,
retries: 5,
retryDelay: 5
});
});

after(() => {
server.stop();
});

/**
* https://macacajs.github.io/macaca-wd/#source
*/
describe('execute', async () => {
it('should work', async () => {
await driver.execute('return window');
assert.equal(server.ctx.method, 'POST');
assert.equal(server.ctx.url, '/wd/hub/session/execute');
assert.deepEqual(server.ctx.request.body, {
args: [],
script: 'return window'
});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});
});

65 changes: 65 additions & 0 deletions test/screenshot.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
'use strict';

const assert = require('assert');

const { Server } = require('./helper');

const wd = require('../lib/macaca-wd');

describe('test/screenshot.test.js', function() {
let driver, server;
before(() => {
server = new Server();
server.start();
const remoteConfig = {
host: 'localhost',
port: 3456
};

driver = wd.promiseChainRemote(remoteConfig);
driver.configureHttp({
timeout: 20 * 1000,
retries: 5,
retryDelay: 5
});
});

after(() => {
server.stop();
});

/**
* https://macacajs.github.io/macaca-wd/#saveScreenshot
*/
describe('saveScreenshot', async () => {
it('should work', async () => {
await driver.saveScreenshot();
assert.equal(server.ctx.method, 'GET');
assert.equal(server.ctx.url, '/wd/hub/session/screenshot');
assert.deepEqual(server.ctx.request.body, {});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});

/**
* https://macacajs.github.io/macaca-wd/#takeScreenshot
*/
describe('takeScreenshot', async () => {
it('should work', async () => {
await driver.takeScreenshot();
assert.equal(server.ctx.method, 'GET');
assert.equal(server.ctx.url, '/wd/hub/session/screenshot');
assert.deepEqual(server.ctx.request.body, {});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});
});

48 changes: 48 additions & 0 deletions test/source.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

const assert = require('assert');

const { Server } = require('./helper');

const wd = require('../lib/macaca-wd');

describe('test/source.test.js', function() {
let driver, server;
before(() => {
server = new Server();
server.start();
const remoteConfig = {
host: 'localhost',
port: 3456
};

driver = wd.promiseChainRemote(remoteConfig);
driver.configureHttp({
timeout: 20 * 1000,
retries: 5,
retryDelay: 5
});
});

after(() => {
server.stop();
});

/**
* https://macacajs.github.io/macaca-wd/#source
*/
describe('source', async () => {
it('should work', async () => {
await driver.source();
assert.equal(server.ctx.method, 'GET');
assert.equal(server.ctx.url, '/wd/hub/session/source');
assert.deepEqual(server.ctx.request.body, {});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});
});

48 changes: 48 additions & 0 deletions test/title.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

const assert = require('assert');

const { Server } = require('./helper');

const wd = require('../lib/macaca-wd');

describe('test/title.test.js', function() {
let driver, server;
before(() => {
server = new Server();
server.start();
const remoteConfig = {
host: 'localhost',
port: 3456
};

driver = wd.promiseChainRemote(remoteConfig);
driver.configureHttp({
timeout: 20 * 1000,
retries: 5,
retryDelay: 5
});
});

after(() => {
server.stop();
});

/**
* https://macacajs.github.io/macaca-wd/#title
*/
describe('title', async () => {
it('should work', async () => {
await driver.title();
assert.equal(server.ctx.method, 'GET');
assert.equal(server.ctx.url, '/wd/hub/session/title');
assert.deepEqual(server.ctx.request.body, {});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});
});

48 changes: 48 additions & 0 deletions test/url.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
'use strict';

const assert = require('assert');

const { Server } = require('./helper');

const wd = require('../lib/macaca-wd');

describe('test/url.test.js', function() {
let driver, server;
before(() => {
server = new Server();
server.start();
const remoteConfig = {
host: 'localhost',
port: 3456
};

driver = wd.promiseChainRemote(remoteConfig);
driver.configureHttp({
timeout: 20 * 1000,
retries: 5,
retryDelay: 5
});
});

after(() => {
server.stop();
});

/**
* https://macacajs.github.io/macaca-wd/#url
*/
describe('url', async () => {
it('should work', async () => {
await driver.url();
assert.equal(server.ctx.method, 'GET');
assert.equal(server.ctx.url, '/wd/hub/session/url');
assert.deepEqual(server.ctx.request.body, {});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});
});

Loading

0 comments on commit 6ef9035

Please sign in to comment.