提交 6ae6c336 编写于 作者: 杜庆泉's avatar 杜庆泉

增加 Object.assign 相关测试示例

上级 7839898a
......@@ -67,7 +67,6 @@ export function testDate() : Result {
test('newDateTest', () => {
// #ifdef APP-ANDROID
console.log(new Date("2024/5/1").toString())
expect(new Date("2024/5/1").toString()).toEqual("Wed May 01 2024 00:00:00 GMT+0800");
expect(new Date("2024/5/1 10:00:00").toString()).toEqual("Wed May 01 2024 10:00:00 GMT+0800");
expect(new Date("2024-05-01 10:00:00").toString()).toEqual("Wed May 01 2024 10:00:00 GMT+0800");
......
......@@ -156,6 +156,29 @@ export function testJSON() : Result {
const array3 = JSON.parseArray<UTSJSONObject>(json3);
// expect((array3![0])["name"]).toEqual("John");
})
test('merge-test-1', () => {
// #ifdef APP-ANDROID
const data1 = {
name: 'Tom1',
age: 21
};
const data2 = {
aa: {
name: 'Tom2',
age: 22,
bb: {
name: 'Tom3',
age: 23
}
}
}
const obj = Object.assign(JSON.parse<UTSJSONObject>(JSON.stringify(data2))!, JSON.parse<UTSJSONObject>(JSON.stringify(data1))!) as UTSJSONObject;
const innerObj = obj.getJSON("aa.bb")
expect(innerObj instanceof UTSJSONObject).toEqual(true);
// #endif
})
test('stringify', () => {
const obj = { name: 'John', age: 30 };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册