52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
const assert = require('assert');
|
|
const SecurityPages = require('../public/js/security-pages.js');
|
|
|
|
function hash(value) {
|
|
return `hashed:${value}`;
|
|
}
|
|
|
|
function run() {
|
|
assert.deepStrictEqual(SecurityPages.buildPasswordChangeBody({
|
|
oldPassword: '123456',
|
|
newPassword: 'abcdef'
|
|
}, hash), {
|
|
oldPassword: 'hashed:123456',
|
|
newPassword: 'hashed:abcdef'
|
|
});
|
|
|
|
assert.deepStrictEqual(SecurityPages.buildPhoneChangeBody({
|
|
newPhone: ' 13900000000 ',
|
|
smsCode: ' 123456 ',
|
|
validToken: ' ticket '
|
|
}), {
|
|
newPhone: '13900000000',
|
|
smsCode: '123456',
|
|
validToken: 'ticket'
|
|
});
|
|
|
|
assert.deepStrictEqual(SecurityPages.buildSmsLoginBody({
|
|
phone: '13900000000',
|
|
smsCode: '123456',
|
|
validToken: ''
|
|
}), {
|
|
phone: '13900000000',
|
|
smsCode: '123456',
|
|
validToken: undefined
|
|
});
|
|
|
|
assert.deepStrictEqual(SecurityPages.buildDeactivateBody({
|
|
password: '123456',
|
|
reason: ' 不再使用 '
|
|
}, hash), {
|
|
password: 'hashed:123456',
|
|
reason: '不再使用'
|
|
});
|
|
|
|
assert.strictEqual(SecurityPages.isDangerConfirmed('确认注销'), true);
|
|
assert.strictEqual(SecurityPages.isDangerConfirmed('注销'), false);
|
|
|
|
console.log('security-pages tests passed');
|
|
}
|
|
|
|
run();
|