修改功,现在补齐页面
This commit is contained in:
@@ -1,95 +0,0 @@
|
||||
const assert = require('assert');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const ProfilePages = require('../public/js/profile-pages.js');
|
||||
|
||||
function run() {
|
||||
assert.strictEqual(ProfilePages.pick({
|
||||
nickName: '汤小明',
|
||||
userName: '备用'
|
||||
}, ['nickName', 'userName'], '未设置'), '汤小明');
|
||||
|
||||
assert.strictEqual(ProfilePages.getAvatarText({
|
||||
nickName: '汤小明'
|
||||
}), '汤');
|
||||
|
||||
assert.deepStrictEqual(ProfilePages.buildProfileView({
|
||||
nickName: '汤小明',
|
||||
phone: '13800000000',
|
||||
sex: '1',
|
||||
birthday: '2026-07-09',
|
||||
provinceCode: '510000',
|
||||
cityCode: '510100',
|
||||
districtCode: '510104'
|
||||
}), {
|
||||
displayName: '汤小明',
|
||||
avatarText: '汤',
|
||||
phone: '13800000000',
|
||||
sex: '1',
|
||||
birthday: '2026-07-09',
|
||||
regionText: '510000 / 510100 / 510104'
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(ProfilePages.buildProfileUpdateBody({
|
||||
nickName: ' 汤小明 ',
|
||||
avatarOssId: '2060001',
|
||||
sex: '1',
|
||||
birthday: '2026-07-09',
|
||||
provinceCode: '510000',
|
||||
cityCode: '510100',
|
||||
districtCode: '510104'
|
||||
}), {
|
||||
nickName: '汤小明',
|
||||
avatarOssId: 2060001,
|
||||
sex: '1',
|
||||
birthday: '2026-07-09',
|
||||
provinceCode: '510000',
|
||||
cityCode: '510100',
|
||||
districtCode: '510104'
|
||||
});
|
||||
|
||||
assert.deepStrictEqual(ProfilePages.buildProfileUpdateBody({
|
||||
nickName: ' ',
|
||||
avatarOssId: '',
|
||||
sex: '',
|
||||
birthday: ''
|
||||
}), {
|
||||
nickName: undefined,
|
||||
avatarOssId: undefined,
|
||||
sex: undefined,
|
||||
birthday: undefined,
|
||||
provinceCode: undefined,
|
||||
cityCode: undefined,
|
||||
districtCode: undefined
|
||||
});
|
||||
|
||||
assert.strictEqual(ProfilePages.shouldRedirectToHome({
|
||||
getToken: () => ''
|
||||
}), true);
|
||||
assert.strictEqual(ProfilePages.shouldRedirectToHome({
|
||||
getToken: () => 'token-x'
|
||||
}), false);
|
||||
assert.strictEqual(ProfilePages.shouldRedirectToHome({
|
||||
getToken: () => 'token-x'
|
||||
}, { status: 401 }), true);
|
||||
assert.strictEqual(ProfilePages.shouldRedirectToHome({
|
||||
getToken: () => 'token-x'
|
||||
}, { code: 401 }), true);
|
||||
assert.strictEqual(ProfilePages.shouldRedirectToHome({
|
||||
getToken: () => 'token-x'
|
||||
}, { status: 500 }), false);
|
||||
|
||||
const profileData = fs.readFileSync(path.join(__dirname, '..', 'profile-data.html'), 'utf8');
|
||||
assert.match(profileData, /data-upload-target="#profileAvatarOssId"/);
|
||||
assert.match(profileData, /data-upload-mode="auto"/);
|
||||
assert.match(profileData, /data-upload-biz-type="avatar"/);
|
||||
assert.match(profileData, /<script src="public\/js\/md5\.js"><\/script>/);
|
||||
assert.match(profileData, /<script src="public\/js\/upload-pages\.js"><\/script>/);
|
||||
assert.match(profileData, /data-region-search-form/);
|
||||
assert.match(profileData, /data-region-search-results/);
|
||||
assert.match(profileData, /data-region-search-path/);
|
||||
|
||||
console.log('profile-pages tests passed');
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user