mirror of
https://github.com/sharevb/it-tools.git
synced 2026-12-05 10:45:10 +03:00
78 lines
1.6 KiB
TypeScript
78 lines
1.6 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import '@/utils/json5-bigint';
|
|
|
|
const bigJson = `{
|
|
"code":200,
|
|
"success":true,
|
|
"data":{
|
|
"vacantNum":121,
|
|
"arrearsNum":95,
|
|
"rentingNum":239,
|
|
"houseNum":95,
|
|
"communityDongFloorHouseVoList":{
|
|
"records":[{
|
|
"id":1911328104527409155,
|
|
"personId":null,
|
|
"communityId":1911239335774236673,
|
|
"communityName":"临江产业邻里中心",
|
|
"dongNumber":"3栋1单元",
|
|
"houseName":"818",
|
|
"houseAlias":"818",
|
|
"tenants":null,
|
|
"withPeople":null,
|
|
"manager":null,
|
|
"maintenance":null,
|
|
"managerList":null,
|
|
"maintenanceList":null,
|
|
"deviceId":"1929809743871979521",
|
|
"productKey":"68240ae56b00c735478abb1c",
|
|
"deviceModel":"G1N9",
|
|
"checkIn":false,
|
|
"houseStatus":1,
|
|
"createTime":null,
|
|
"lastTime":"2026-08-17",
|
|
"startTime":null,
|
|
"endTime":null,
|
|
"houseCode":"1911239335774236673,1911328104154116098,1911328104527409155",
|
|
"houseCodeName":"临江产业邻里中心3栋1单元818",
|
|
"online":1,
|
|
"devSignal":"0",
|
|
"electricityStatus":"1",
|
|
"electricity":"100%",
|
|
"monthlyElectricity":233.5,
|
|
"monthlyWater":9,
|
|
"occupancy":null,
|
|
"houseType":1,
|
|
"houseMoney":-166.16,
|
|
"waterCount":null,
|
|
"electricCount":null,
|
|
"isCollection":null,
|
|
"deviceSn":"62ba4bf0bb5e",
|
|
"vacantNum":0,
|
|
"rentingNum":0,
|
|
"occupancyNum":2,
|
|
"vacantDays":"0"
|
|
}],
|
|
"total":95,
|
|
"size":10,
|
|
"current":3,
|
|
"orders":[],
|
|
"optimizeCountSql":true,
|
|
"searchCount":true,
|
|
"countId":null,
|
|
"maxLimit":null,
|
|
"pages":10
|
|
}
|
|
},
|
|
"msg":"操作成功"
|
|
}
|
|
`;
|
|
|
|
describe('json5-bigint utils', () => {
|
|
describe('JSON.parseBigInt', () => {
|
|
it('should parse bigint in JSON (but not in strings)', () => {
|
|
expect(JSON.stringify(JSON.parseBigInt(bigJson))).toBe(bigJson.replace(/[\r\n]/g, ''));
|
|
});
|
|
});
|
|
});
|