提交 9c4eb33a 编写于 作者: lizhongyi_'s avatar lizhongyi_

调整JSON测试例

上级 991eee47
...@@ -89,13 +89,13 @@ export function testJSON() : Result { ...@@ -89,13 +89,13 @@ export function testJSON() : Result {
"id": "30" "id": "30"
}`; }`;
let obj2 = JSON.parseObject<UserJSON>(json1); let obj2 = JSON.parseObject<UserJSON>(json1);
expect(obj2!!.id).toEqual("30"); expect(obj2!.id).toEqual("30");
const json2 = `{ const json2 = `{
"id": "30" "id": "30"
}`; }`;
let obj3 = JSON.parseObject<UserJSON>(json2); let obj3 = JSON.parseObject<UserJSON>(json2);
expect(obj3!!.id).toEqual("30"); expect(obj3!.id).toEqual("30");
const json3 = `{ const json3 = `{
"name": "John" "name": "John"
}`; }`;
...@@ -113,11 +113,11 @@ export function testJSON() : Result { ...@@ -113,11 +113,11 @@ export function testJSON() : Result {
const json3 = `[{"name":"John","id":"30"},{"name":"jack","id":"21"}]`; const json3 = `[{"name":"John","id":"30"},{"name":"jack","id":"21"}]`;
const array3 = JSON.parseArray(json3); const array3 = JSON.parseArray<UTSJSONObject>(json3);
expect((array3![0] as UTSJSONObject)["name"]).toEqual("John"); // expect((array3![0])["name"]).toEqual("John");
}) })
test('stringify', () => { test('stringify', () => {
const obj = { name: 'John', age: 30 }; const obj = { name: 'John', age: 30 };
const json = JSON.stringify(obj); const json = JSON.stringify(obj);
// expect(json).toEqual('{"name":"John","age":30}'); // expect(json).toEqual('{"name":"John","age":30}');
......
...@@ -3,7 +3,6 @@ import { testDate } from './Date.uts' ...@@ -3,7 +3,6 @@ import { testDate } from './Date.uts'
import { testString } from './String.uts' import { testString } from './String.uts'
import { testError } from './Error.uts' import { testError } from './Error.uts'
import { testKeyWord } from './KeyWord.uts' import { testKeyWord } from './KeyWord.uts'
import { testExtapi } from './Extapi.uts'
import { testJSON } from './JSON.uts' import { testJSON } from './JSON.uts'
import { testNumber } from './Number.uts' import { testNumber } from './Number.uts'
import { testMap } from './Map.uts' import { testMap } from './Map.uts'
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册