npmextra/test/test.ts
2023-08-03 19:22:34 +02:00

34 lines
1.0 KiB
TypeScript

import { expect, tap } from '@push.rocks/tapbundle';
import path = require('path');
// module to test
import * as npmextra from '../ts/index.js';
let testNpmextra: npmextra.Npmextra;
tap.test('should create a new Npmtextra instance', async () => {
testNpmextra = new npmextra.Npmextra('./test/');
expect(testNpmextra).toBeInstanceOf(npmextra.Npmextra);
});
tap.test('should state wether a npmextra.json exists', async () => {
// tslint:disable-next-line:no-unused-expression
expect(testNpmextra.npmextraJsonExists).toBeTrue();
});
tap.test('should pass through default value, if not overriden by config from file', async () => {
let testData = testNpmextra.dataFor('testTool', { someKey2: 'someValue2' });
console.log(testData);
expect(testData).toHaveProperty('someKey2');
});
tap.test('should read a config file', async () => {
let testData = testNpmextra.dataFor<any>('testTool', {
someKey2: 'someValue2',
});
expect(testData).toHaveProperty('someKey2');
expect(testData.testValue).toEqual(2);
});
tap.start();