smartobject/test/test.smartobject.ts

25 lines
747 B
TypeScript
Raw Permalink Normal View History

2023-07-12 17:40:41 +00:00
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
import * as smartobject from '../ts/index.js';
2022-03-07 14:28:32 +00:00
let testSmartobject: smartobject.SmartObject;
tap.test('should create a smartobject', async () => {
const originalObject = {
test: 'hey',
deep: {
yeah: 'so deep',
evendeeper: {
sodeep: 2,
2023-07-12 17:40:41 +00:00
deepArray: ['one array', 'two array'],
},
},
};
2022-03-07 14:28:32 +00:00
testSmartobject = new smartobject.SmartObject(originalObject);
testSmartobject.addValueAtFlatPathString('deep.nice', 'yeah that has been added');
console.log(testSmartobject.originalObject);
2023-07-12 17:40:41 +00:00
console.log(testSmartobject.toFlatObject());
2022-03-07 14:28:32 +00:00
expect(testSmartobject.getValueAtFlatPathString('deep.yeah')).toEqual('so deep');
});
2023-07-12 17:40:41 +00:00
tap.start();