Skip to content

Commit

Permalink
Merge 1f02875 into ea3dd30
Browse files Browse the repository at this point in the history
  • Loading branch information
paradite committed Mar 17, 2019
2 parents ea3dd30 + 1f02875 commit cd36fda
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 24 deletions.
8 changes: 5 additions & 3 deletions lib/macaca-wd.js
Original file line number Diff line number Diff line change
Expand Up @@ -776,20 +776,22 @@ function touch(action, args) {}
function allCookies() {}

/**
* Adds a single cookie to the cookie store associated with the active document’s address. {url: 'https://macacajs.github.io', name:'foo', value:'bar'} Optional cookie fields: secure, expiry
* Adds a single cookie to the cookie store associated with the active document’s address.
* @summary Support: Web(WebView)
* @param {object} cookie - example: {url: 'https://macacajs.github.io', name:'foo', value:'bar'} Optional cookie fields: secure, expiry
* @see {@link https://w3c.github.io/webdriver/webdriver-spec.html#add-cookie|POST /session/:sessionId/cookie}
* @returns {Promise.<string>}
*/
function setCookie() {}
function setCookie(cookie) {}

/**
* Delete either a single cookie by parameter name, or all the cookies associated with the active document’s address if name is undefined.
* @summary Support: Web(WebView)
* @param {string} name cookie name
* @see {@link https://w3c.github.io/webdriver/webdriver-spec.html#delete-cookie|DELETE /session/:sessionId/cookie/:name}
* @returns {Promise.<string>}
*/
function deleteCookie() {}
function deleteCookie(name) {}

/**
* Allows deletion of all cookies associated with the active document’s address.
Expand Down
47 changes: 39 additions & 8 deletions test/cookie.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,65 @@ describe('test/cookie.test.js', function() {
*/
describe('allCookies', async () => {
it('should work', async () => {

await driver.allCookies();
assert.equal(server.ctx.url, '/wd/hub/session/sessionId/cookie');
assert.equal(server.ctx.method, 'GET');
});
});

/**
/**
* https://macacajs.github.io/macaca-wd/#deleteAllCookies
*/
describe('deleteAllCookies', async () => {
it('should work', async () => {

await driver.deleteAllCookies();
assert.equal(server.ctx.url, '/wd/hub/session/sessionId/cookie');
assert.equal(server.ctx.method, 'DELETE');
assert.deepEqual(server.ctx.request.body, {});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: ''
});
});
});

/**
/**
* https://macacajs.github.io/macaca-wd/#deleteCookie
*/
describe('deleteCookie', async () => {
it('should work', async () => {

await driver.deleteCookie('test_cookie');
assert.equal(
server.ctx.url,
'/wd/hub/session/sessionId/cookie/test_cookie'
);
assert.equal(server.ctx.method, 'DELETE');
assert.deepEqual(server.ctx.request.body, {});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: ''
});
});
});

/**
/**
* https://macacajs.github.io/macaca-wd/#setCookie
*/
describe('setCookie', async () => {
it('should work', async () => {

await driver.setCookie('test_cookie');
assert.equal(server.ctx.url, '/wd/hub/session/sessionId/cookie');
assert.equal(server.ctx.method, 'POST');
assert.deepEqual(server.ctx.request.body, {
cookie: 'test_cookie'
});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: ''
});
});
});
});
});
29 changes: 16 additions & 13 deletions test/utility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('test/utility.test.js', function() {
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
value: ''
});
});
});
Expand All @@ -63,7 +63,7 @@ describe('test/utility.test.js', function() {
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
value: ''
});
});
});
Expand All @@ -80,7 +80,7 @@ describe('test/utility.test.js', function() {
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
value: ''
});
});
});
Expand All @@ -97,7 +97,7 @@ describe('test/utility.test.js', function() {
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
value: ''
});
});
});
Expand All @@ -114,30 +114,33 @@ describe('test/utility.test.js', function() {
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
value: ''
});
});
});

/**
/**
* https://macacajs.github.io/macaca-wd/#initWindow
*/
describe('initWindow', async () => {
it('should work', async () => {
await driver.initWindow({
width: 800,
height: 600,
height: 600
});
assert.equal(server.ctx.url, '/wd/hub/session/sessionId/window/current/size');
assert.equal(
server.ctx.url,
'/wd/hub/session/sessionId/window/current/size'
);
assert.equal(server.ctx.method, 'POST');
assert.deepEqual(server.ctx.request.body, {
width: 800,
height: 600,
height: 600
});
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
value: ''
});
});
});
Expand All @@ -147,7 +150,7 @@ describe('test/utility.test.js', function() {
*/
describe.skip('openReporter', async () => {
it('should work', async () => {
await driver.openReporter();
await driver.openReporter(false);
});
});

Expand All @@ -156,13 +159,13 @@ describe('test/utility.test.js', function() {
*/
describe('saveScreenshots', async () => {
it('should work', async () => {
await driver.saveScreenshots();
await driver.saveScreenshots(this);
assert.equal(server.ctx.url, '/wd/hub/session/sessionId/screenshot');
assert.equal(server.ctx.method, 'GET');
assert.deepEqual(server.ctx.response.body, {
sessionId: 'sessionId',
status: 0,
value: '',
value: ''
});
});
});
Expand Down

0 comments on commit cd36fda

Please sign in to comment.