1
0
Fork 0

fix(test): cover app main and stream type

This commit is contained in:
ssube 2020-03-31 17:47:10 -05:00
parent c1189a8569
commit 87e55c873b
Signed by: ssube
GPG Key ID: 3EED7B957D362AF1
2 changed files with 33 additions and 0 deletions

7
test/TestApp.ts Normal file
View File

@ -0,0 +1,7 @@
import { expect } from 'chai';
import { main } from '../src/app';
describe('main function', async () => {
it('should exit 1', async () => expect(main([])).to.eventually.equal(1));
});

26
test/type/TestStream.ts Normal file
View File

@ -0,0 +1,26 @@
import { NotFoundError } from '@apextoaster/js-utils';
import { expect } from 'chai';
import { streamType } from '../../src/type/Stream';
describe('stream config type', async () => {
it('should resolve existing streams', async () => {
expect(streamType.resolve('stdout')).to.equal(true);
});
it('should reject missing streams');
it('should reject other properties', async () => {
expect(() => streamType.resolve('env')).to.throw(NotFoundError);
});
it('should construct streams from process', async () => {
expect(streamType.construct('stdout')).to.equal(process.stdout);
});
/**
* TODO: throw
*/
it('should throw when constructing missing streams', async () => {
expect(streamType.construct('bob')).to.equal(undefined);
});
});