Skip to content

Commit

Permalink
feat: next rebuildContextPage
Browse files Browse the repository at this point in the history
  • Loading branch information
yihuineng committed Oct 11, 2023
1 parent 51deab6 commit 591960c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 14 deletions.
20 changes: 7 additions & 13 deletions lib/next/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,15 @@ module.exports = wd => {
'pagePopup'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
const [func, ...args] = params;
return this.next(method, [{ func, args }]);
const [ func, ...args ] = params;
return this.next(method, [ { func, args } ]);
});
});

[
'elementStatus'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
return this.next(method, params);
});
});

[
'fileChooser'
'fileChooser',
'elementStatus',
'rebuildContextPage'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
return this.next(method, params);
Expand All @@ -32,8 +26,8 @@ module.exports = wd => {
'keyboard'
].map(method => {
wd.addPromiseChainMethod(method, function(...params) {
const [type, ...args] = params;
return this.next(method, [{ type, args }]);
const [ type, ...args ] = params;
return this.next(method, [ { type, args } ]);
});
});
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "macaca-wd",
"version": "4.2.2",
"version": "4.2.3",
"description": "Macaca webdirver API for Node.js",
"keywords": [
"macaca",
Expand Down
16 changes: 16 additions & 0 deletions test/utility.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,20 @@ describe('test/utility.test.js', function() {
});
});
});

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

0 comments on commit 591960c

Please sign in to comment.