2018-08-30 23:11:09 +00:00
|
|
|
import { expect, tap } from '@pushrocks/tapbundle';
|
|
|
|
import path = require('path');
|
2016-07-16 23:23:22 +00:00
|
|
|
|
2017-07-09 17:05:03 +00:00
|
|
|
// module to test
|
2018-08-30 23:11:09 +00:00
|
|
|
import npmExtra = require('../ts/index');
|
2016-09-23 20:13:06 +00:00
|
|
|
|
2018-08-30 23:11:09 +00:00
|
|
|
let testNpmextra: npmExtra.Npmextra;
|
2016-09-24 14:44:48 +00:00
|
|
|
|
2017-07-09 17:05:03 +00:00
|
|
|
tap.test('should create a new Npmtextra instance', async () => {
|
2018-08-30 23:11:09 +00:00
|
|
|
testNpmextra = new npmExtra.Npmextra('./test/');
|
|
|
|
expect(testNpmextra).be.instanceof(npmExtra.Npmextra);
|
|
|
|
});
|
2017-07-09 17:05:03 +00:00
|
|
|
|
|
|
|
tap.test('should state wether a npmextra.json exists', async () => {
|
|
|
|
// tslint:disable-next-line:no-unused-expression
|
2018-08-30 23:11:09 +00:00
|
|
|
expect(testNpmextra.npmextraJsonExists).be.true;
|
|
|
|
});
|
2017-07-09 17:05:03 +00:00
|
|
|
|
|
|
|
tap.test('should pass through default value, if not overriden by config from file', async () => {
|
2018-08-30 23:11:09 +00:00
|
|
|
let testData = testNpmextra.dataFor('testTool', { someKey2: 'someValue2' });
|
|
|
|
console.log(testData);
|
|
|
|
expect(testData).have.ownProperty('someKey2');
|
|
|
|
});
|
2017-07-09 17:05:03 +00:00
|
|
|
|
|
|
|
tap.test('should read a config file', async () => {
|
2018-08-30 23:11:09 +00:00
|
|
|
let testData = testNpmextra.dataFor<any>('testTool', {
|
2021-01-27 21:00:49 +00:00
|
|
|
someKey2: 'someValue2',
|
2018-08-30 23:11:09 +00:00
|
|
|
});
|
|
|
|
expect(testData).have.ownProperty('someKey2');
|
|
|
|
expect(testData.testValue).equal(2);
|
|
|
|
});
|
2017-07-09 17:05:03 +00:00
|
|
|
|
2018-08-30 23:11:09 +00:00
|
|
|
tap.start();
|