Files
smartconfig/test/test.ts

36 lines
1.1 KiB
TypeScript
Raw Normal View History

import { expect, tap } from '@git.zone/tstest/tapbundle';
2016-07-17 01:23:22 +02:00
2017-07-09 19:05:03 +02:00
// module to test
import * as smartconfig from '../ts/index.js';
2016-09-23 22:13:06 +02:00
let testSmartconfig: smartconfig.Smartconfig;
2016-09-24 16:44:48 +02:00
tap.test('should create a new Smartconfig instance', async () => {
testSmartconfig = new smartconfig.Smartconfig('./test/');
expect(testSmartconfig).toBeInstanceOf(smartconfig.Smartconfig);
});
2017-07-09 19:05:03 +02:00
tap.test('should state wether a smartconfig.json exists', async () => {
2017-07-09 19:05:03 +02:00
// tslint:disable-next-line:no-unused-expression
expect(testSmartconfig.smartconfigJsonExists).toBeTrue();
});
2017-07-09 19:05:03 +02:00
tap.test(
'should pass through default value, if not overriden by config from file',
async () => {
let testData = testSmartconfig.dataFor('testTool', { someKey2: 'someValue2' });
console.log(testData);
expect(testData).toHaveProperty('someKey2');
},
);
2017-07-09 19:05:03 +02:00
tap.test('should read a config file', async () => {
let testData = testSmartconfig.dataFor<any>('testTool', {
2021-01-27 21:00:49 +00:00
someKey2: 'someValue2',
});
2023-08-03 19:22:34 +02:00
expect(testData).toHaveProperty('someKey2');
expect(testData.testValue).toEqual(2);
});
2017-07-09 19:05:03 +02:00
tap.start();