Files
smartconfig/test/test.ts
Juergen Kunz 22a9aa9f3e rename package from @push.rocks/npmextra to @push.rocks/smartconfig
- 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
2026-03-24 14:56:23 +00:00

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();