- Rename all source files from npmextra.* to simpler names (classes.appdata.ts, etc.) - Rename Npmextra class to Smartconfig - Config file changed from npmextra.json to smartconfig.json - KV store path changed from ~/.npmextra/kv to ~/.smartconfig/kv - Update all imports, tests, and metadata
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
|
|
// module to test
|
|
import * as smartconfig from '../ts/index.js';
|
|
|
|
let testSmartconfig: smartconfig.Smartconfig;
|
|
|
|
tap.test('should create a new Smartconfig instance', async () => {
|
|
testSmartconfig = new smartconfig.Smartconfig('./test/');
|
|
expect(testSmartconfig).toBeInstanceOf(smartconfig.Smartconfig);
|
|
});
|
|
|
|
tap.test('should state wether a smartconfig.json exists', async () => {
|
|
// tslint:disable-next-line:no-unused-expression
|
|
expect(testSmartconfig.smartconfigJsonExists).toBeTrue();
|
|
});
|
|
|
|
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');
|
|
},
|
|
);
|
|
|
|
tap.test('should read a config file', async () => {
|
|
let testData = testSmartconfig.dataFor<any>('testTool', {
|
|
someKey2: 'someValue2',
|
|
});
|
|
expect(testData).toHaveProperty('someKey2');
|
|
expect(testData.testValue).toEqual(2);
|
|
});
|
|
|
|
tap.start();
|