2018-08-26 18:20:23 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
2017-05-25 13:09:01 +00:00
|
|
|
|
2018-08-26 18:20:23 +00:00
|
|
|
import * as smartyaml from '../ts/index';
|
2017-05-25 13:09:01 +00:00
|
|
|
|
|
|
|
let yamlString = `someKey: someValue
|
|
|
|
someKey2: someValue2
|
2018-08-26 18:20:23 +00:00
|
|
|
`;
|
2017-05-25 13:09:01 +00:00
|
|
|
|
|
|
|
tap.test('should convert yaml string to object', async () => {
|
2018-08-26 18:20:23 +00:00
|
|
|
let myObject = await smartyaml.yamlStringToObject(yamlString);
|
|
|
|
expect(myObject.someKey).to.equal('someValue');
|
|
|
|
expect(myObject.someKey2).to.equal('someValue2');
|
|
|
|
});
|
2017-05-25 13:09:01 +00:00
|
|
|
|
|
|
|
tap.test('should convert an object to a string', async () => {
|
2018-08-26 18:20:23 +00:00
|
|
|
let myObject = await smartyaml.yamlStringToObject(yamlString);
|
|
|
|
let myString = await smartyaml.objectToYamlString(myObject);
|
|
|
|
expect(myString).to.equal(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 () => {
|
2018-08-26 18:20:23 +00:00
|
|
|
let testString = `myKey.with.dots: some`;
|
|
|
|
let testObject = await smartyaml.yamlStringToObject(testString);
|
|
|
|
expect(testObject['myKey.with.dots']).to.equal('some');
|
|
|
|
});
|
2017-05-25 14:50:19 +00:00
|
|
|
|
2018-08-26 18:20:23 +00:00
|
|
|
tap.start();
|