You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
/**
|
|
|
|
* Common公用方法测试用例
|
|
|
|
*/
|
|
|
|
|
|
|
|
import test from 'node:test';
|
|
|
|
import assert from 'node:assert';
|
|
|
|
import common from '../common.mjs';
|
|
|
|
|
|
|
|
|
|
|
|
test('Common function sortDict test', (t) => {
|
|
|
|
let params = {
|
|
|
|
b: 2,
|
|
|
|
a: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectRes = {
|
|
|
|
a: 1,
|
|
|
|
b: 2
|
|
|
|
};
|
|
|
|
|
|
|
|
assert.deepEqual(common.sortDict(params), expectRes);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Common function joinDict test', (t) => {
|
|
|
|
let params = {
|
|
|
|
b: 2,
|
|
|
|
a: 1
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectRes = "a=1&b=2";
|
|
|
|
|
|
|
|
assert.strictEqual(common.joinDict(common.sortDict(params)), expectRes);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Common function getConfigFromJsonFile test', async (t) => {
|
|
|
|
let filename = 'config.json';
|
|
|
|
let config = await common.getConfigFromJsonFile(filename);
|
|
|
|
|
|
|
|
assert.ok(config);
|
|
|
|
|
|
|
|
const expectName = 'Hero Union';
|
|
|
|
assert.strictEqual(config.name, expectName);
|
|
|
|
});
|