家谱现有接口调试50%
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
const assert = require('assert');
|
||||
const LineagePages = require('../public/js/lineage-pages.js');
|
||||
|
||||
function run() {
|
||||
assert.deepStrictEqual(LineagePages.normalizeList({ rows: [{ personId: 1 }] }), [{ personId: 1 }]);
|
||||
assert.deepStrictEqual(LineagePages.normalizeList({ records: [{ personId: 2 }] }), [{ personId: 2 }]);
|
||||
|
||||
assert.deepStrictEqual(LineagePages.buildLineagePersonBody({
|
||||
appUserId: '',
|
||||
personNo: ' P001 ',
|
||||
personName: ' 汤明 ',
|
||||
aliasName: ' 明公 ',
|
||||
sex: '0',
|
||||
generationNo: ' 3 ',
|
||||
generationName: '忠',
|
||||
birthDate: '1990-01-02',
|
||||
deathDate: '',
|
||||
introduction: ' 三世成员 '
|
||||
}), {
|
||||
appUserId: undefined,
|
||||
personNo: 'P001',
|
||||
personName: '汤明',
|
||||
aliasName: '明公',
|
||||
sex: '0',
|
||||
generationNo: 3,
|
||||
generationName: '忠',
|
||||
avatarOssId: undefined,
|
||||
birthDate: '1990-01-02',
|
||||
deathDate: undefined,
|
||||
introduction: '三世成员'
|
||||
});
|
||||
|
||||
assert.strictEqual(LineagePages.formatSex('0'), '男');
|
||||
assert.strictEqual(LineagePages.formatSex('1'), '女');
|
||||
assert.strictEqual(LineagePages.formatSex('9'), '未知');
|
||||
|
||||
assert.strictEqual(
|
||||
LineagePages.buildPersonRow({
|
||||
personId: 7001,
|
||||
personName: '汤明',
|
||||
generationNo: 3,
|
||||
generationName: '忠',
|
||||
sex: '0',
|
||||
boundAccount: true
|
||||
}),
|
||||
'<button class="module-row lineage-row" type="button" data-lineage-person="7001"><div><h3>汤明</h3><p>第 3 世 · 忠字辈 · 男 · 已绑定账号</p></div><span class="pill">查看资料</span></button>'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
LineagePages.buildTreeNode({
|
||||
personId: 7001,
|
||||
personName: '汤明',
|
||||
generationNo: 3,
|
||||
children: [
|
||||
{
|
||||
personId: 7002,
|
||||
personName: '汤小明',
|
||||
generationNo: 4
|
||||
}
|
||||
]
|
||||
}),
|
||||
'<li><button type="button" class="lineage-node" data-lineage-person="7001"><strong>汤明</strong><span>第 3 世</span></button><ul><li><button type="button" class="lineage-node" data-lineage-person="7002"><strong>汤小明</strong><span>第 4 世</span></button></li></ul></li>'
|
||||
);
|
||||
|
||||
assert.strictEqual(
|
||||
LineagePages.buildHomeSummary({
|
||||
genealogyNo: 'JP001',
|
||||
hallName: '敦本堂',
|
||||
memberCount: 18
|
||||
}, 3),
|
||||
'JP001 · 堂号 敦本堂 · 共 18 人 · 3 个世系根节点'
|
||||
);
|
||||
|
||||
console.log('lineage-pages tests passed');
|
||||
}
|
||||
|
||||
run();
|
||||
Reference in New Issue
Block a user