smartyaml/test/test.both.ts

29 lines
892 B
TypeScript
Raw Normal View History

2024-04-30 15:49:25 +00:00
import { expect, tap } from '@push.rocks/tapbundle';
2017-05-25 13:09:01 +00:00
2022-05-20 13:22:56 +00:00
import * as smartyaml from '../ts/index.js';
2017-05-25 13:09:01 +00:00
let yamlString = `someKey: someValue
someKey2: someValue2
`;
2017-05-25 13:09:01 +00:00
tap.test('should convert yaml string to object', async () => {
let myObject = await smartyaml.yamlStringToObject(yamlString);
2022-05-20 13:22:56 +00:00
expect(myObject.someKey).toEqual('someValue');
expect(myObject.someKey2).toEqual('someValue2');
});
2017-05-25 13:09:01 +00:00
tap.test('should convert an object to a string', async () => {
let myObject = await smartyaml.yamlStringToObject(yamlString);
let myString = await smartyaml.objectToYamlString(myObject);
2022-05-20 13:22:56 +00:00
expect(myString).toEqual(yamlString);
});
2017-05-25 13:09:01 +00:00
2017-05-25 14:50:19 +00:00
// test some behaviours
tap.test('should allow dots in key', async () => {
let testString = `myKey.with.dots: some`;
let testObject = await smartyaml.yamlStringToObject(testString);
2022-05-20 13:22:56 +00:00
expect(testObject['myKey.with.dots']).toEqual('some');
});
2017-05-25 14:50:19 +00:00
tap.start();