初始化提交:go比特版本精简
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert');
|
||||
const { _private } = require('../src/services/change_2fa_service');
|
||||
|
||||
function locator(page, selector) {
|
||||
return {
|
||||
or() { return this; },
|
||||
first() { return this; },
|
||||
nth() { return this; },
|
||||
async count() {
|
||||
return selector.includes('div[jsname="c6xFrd"]') ? 1 : 0;
|
||||
},
|
||||
async isVisible() {
|
||||
if (selector.includes('div[jsname="c6xFrd"]')) return true;
|
||||
if (selector.includes('input[jsname="YPqjbf"]')) return !page.submitted;
|
||||
return false;
|
||||
},
|
||||
async evaluate() {
|
||||
page.submitted = true;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
(async () => {
|
||||
const logs = [];
|
||||
const page = {
|
||||
submitted: false,
|
||||
locator(selector) { return locator(this, selector); },
|
||||
url() {
|
||||
return 'https://myaccount.google.com/two-step-verification/authenticator?rapt=LOCAL';
|
||||
},
|
||||
async waitForTimeout() {},
|
||||
};
|
||||
|
||||
const result = await _private.clickVerifyButton(page, message => logs.push(message));
|
||||
|
||||
assert.deepStrictEqual(result, [true, false]);
|
||||
assert.strictEqual(page.submitted, true);
|
||||
assert.ok(logs.some(message => message.includes('验证弹窗已关闭')));
|
||||
console.log('change_2fa_submit_result.test.js passed');
|
||||
})().catch(error => {
|
||||
console.error(error);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
Reference in New Issue
Block a user