Skip to content

Commit

Permalink
Merge 7298826 into 2250cee
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Mar 17, 2019
2 parents 2250cee + 7298826 commit 116c434
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/macaca-wd.test.js → test/browser.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const { Server } = require('./helper');

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

describe('test/macaca-wd.test.js', function() {
describe('test/browser.test.js', function() {
let driver, server;
before(() => {
server = new Server();
Expand Down
103 changes: 103 additions & 0 deletions test/session.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
'use strict';

const assert = require('assert');

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

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

describe('test/session.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/#init
*/
describe('init', async () => {
it('should work', async () => {
await driver.init({
platformName: 'desktop',
browserName: 'chrome'
});
assert.equal(server.ctx.method, 'POST');
assert.equal(server.ctx.url, '/wd/hub/session');
assert.deepEqual(server.ctx.request.body, {
desiredCapabilities: {
platformName: 'desktop',
browserName: 'chrome',
version: '',
javascriptEnabled: true,
platform: 'ANY',
},
});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});

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

/**
* https://macacajs.github.io/macaca-wd/#sessions
*/
describe('sessions', async () => {
beforeEach(async () => {
await driver.init({
platformName: 'desktop',
browserName: 'chrome'
});
});
it('should work', async () => {
await driver.sessions();
assert.equal(server.ctx.method, 'GET');
assert.equal(server.ctx.url, '/wd/hub/sessions');
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
});
});
});
});
2 changes: 1 addition & 1 deletion test/helper.test.js → test/utility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const assert = require('assert');

const helper = require('../lib/helper');

describe('test/helper.test.js', function() {
describe('test/utility.test.js', function() {
it('should be ok', function() {
assert.ok(helper);
});
Expand Down

0 comments on commit 116c434

Please sign in to comment.