Skip to content

Commit

Permalink
remove: async test tracker and pid file utils
Browse files Browse the repository at this point in the history
BREAKING CHANGE: this removes the test helpers, which were not well
tested and required the `async_hooks` module, and the PID file
helpers, which introduced a requirement on `fs` that could not be
easily polyfilled. This should make the library easier to use in
browsers and bundlers.
  • Loading branch information
ssube committed Jun 30, 2020
1 parent a7cf22d commit e34641a
Show file tree
Hide file tree
Showing 16 changed files with 82 additions and 361 deletions.
96 changes: 0 additions & 96 deletions src/AsyncTracker.ts

This file was deleted.

44 changes: 0 additions & 44 deletions src/PidFile.ts

This file was deleted.

7 changes: 0 additions & 7 deletions src/index.ts
Expand Up @@ -5,9 +5,6 @@ export { NotFoundError } from './error/NotFoundError';
export { NotImplementedError } from './error/NotImplementedError';
export { TimeoutError } from './error/TimeoutError';

export {
AsyncTracker,
} from './AsyncTracker';
export {
ArrayMapper,
ArrayMapperOptions,
Expand Down Expand Up @@ -71,10 +68,6 @@ export {
mustExist,
mustFind,
} from './Maybe';
export {
removePid,
writePid,
} from './PidFile';
export {
constructorName,
getConstructor,
Expand Down
5 changes: 2 additions & 3 deletions test/TestApp.ts
Expand Up @@ -2,10 +2,9 @@ import { expect } from 'chai';
import { spy } from 'sinon';

import { main } from '../src/app';
import { describeLeaks, itLeaks } from './helpers/async';

describeLeaks('app', async () => {
itLeaks('should log a message', async () => {
describe('app', async () => {
it('should log a message', async () => {
/* tslint:disable-next-line:no-console no-unbound-method */
const logSpy = spy(console, 'log');

Expand Down
6 changes: 0 additions & 6 deletions test/TestHelpers.ts

This file was deleted.

74 changes: 0 additions & 74 deletions test/helpers/async.ts

This file was deleted.

11 changes: 5 additions & 6 deletions test/utils/TestArrayMapper.ts
@@ -1,11 +1,10 @@
import { expect } from 'chai';

import { ArrayMapper } from '../../src/ArrayMapper';
import { describeLeaks, itLeaks } from '../helpers/async';

describeLeaks('utils', async () => {
describeLeaks('array mapper', async () => {
itLeaks('should take initial args', async () => {
describe('utils', async () => {
describe('array mapper', async () => {
it('should take initial args', async () => {
const mapper = new ArrayMapper({
rest: 'others',
skip: 0,
Expand All @@ -18,7 +17,7 @@ describeLeaks('utils', async () => {
expect(results.get('others'), 'rest should be collected').to.deep.equal(['3', '4']);
});

itLeaks('should always include rest arg', async () => {
it('should always include rest arg', async () => {
const mapper = new ArrayMapper({
rest: 'empty',
skip: 0,
Expand All @@ -29,7 +28,7 @@ describeLeaks('utils', async () => {
expect(results.get('empty'), 'rest key should be empty').to.have.lengthOf(0);
});

itLeaks('should skit initial args', async () => {
it('should skit initial args', async () => {
const mapper = new ArrayMapper({
rest: 'empty',
skip: 3,
Expand Down
11 changes: 5 additions & 6 deletions test/utils/TestAsync.ts
Expand Up @@ -2,14 +2,13 @@ import { expect } from 'chai';

import { defer, timeout } from '../../src/Async';
import { TimeoutError } from '../../src/error/TimeoutError';
import { describeLeaks, itLeaks } from '../helpers/async';

describeLeaks('async utils', async () => {
describeLeaks('defer', async () => {
itLeaks('should resolve', async () => expect(defer(10, true)).to.eventually.equal(true));
describe('async utils', async () => {
describe('defer', async () => {
it('should resolve', async () => expect(defer(10, true)).to.eventually.equal(true));
});

describeLeaks('timeout', async () => {
itLeaks('should reject slow promises', async () => expect(timeout(10, defer(20))).to.eventually.be.rejectedWith(TimeoutError));
describe('timeout', async () => {
it('should reject slow promises', async () => expect(timeout(10, defer(20))).to.eventually.be.rejectedWith(TimeoutError));
});
});
15 changes: 7 additions & 8 deletions test/utils/TestBuffer.ts
@@ -1,30 +1,29 @@
import { expect } from 'chai';

import { concat, encode } from '../../src/Buffer';
import { describeLeaks, itLeaks } from '../helpers/async';

describeLeaks('buffer utils', async () => {
describeLeaks('concat', async () => {
itLeaks('should append chunk buffers', async () => {
describe('buffer utils', async () => {
describe('concat', async () => {
it('should append chunk buffers', async () => {
expect(concat([
Buffer.from('hello'),
Buffer.from('world'),
])).to.deep.equal(Buffer.from('helloworld'));
});
});

describeLeaks('encode', async () => {
itLeaks('should encode chunk buffers', async () => {
describe('encode', async () => {
it('should encode chunk buffers', async () => {
expect(encode([
Buffer.from('hello world'),
], 'utf-8')).to.equal('hello world');
});

itLeaks('should encode no buffers', async () => {
it('should encode no buffers', async () => {
expect(encode([], 'utf-8')).to.equal('');
});

itLeaks('should encode empty buffers', async () => {
it('should encode empty buffers', async () => {
expect(encode([
new Buffer(0),
], 'utf-8')).to.equal('');
Expand Down
15 changes: 7 additions & 8 deletions test/utils/TestChecklist.ts
@@ -1,24 +1,23 @@
import { expect } from 'chai';

import { Checklist, ChecklistMode } from '../../src/Checklist';
import { describeLeaks, itLeaks } from '../helpers/async';

const EXISTING_ITEM = 'foo';
const MISSING_ITEM = 'bin';
const TEST_DATA = [EXISTING_ITEM, 'bar'];

// tslint:disable:no-duplicate-functions
describeLeaks('checklist', async () => {
describeLeaks('exclude mode', async () => {
itLeaks('should check for present values', async () => {
describe('checklist', async () => {
describe('exclude mode', async () => {
it('should check for present values', async () => {
const list = new Checklist({
data: TEST_DATA,
mode: ChecklistMode.EXCLUDE,
});
expect(list.check(EXISTING_ITEM)).to.equal(false);
});

itLeaks('should check for missing values', async () => {
it('should check for missing values', async () => {
const list = new Checklist({
data: TEST_DATA,
mode: ChecklistMode.EXCLUDE,
Expand All @@ -27,16 +26,16 @@ describeLeaks('checklist', async () => {
});
});

describeLeaks('include mode', async () => {
itLeaks('should check for present values', async () => {
describe('include mode', async () => {
it('should check for present values', async () => {
const list = new Checklist<string>({
data: TEST_DATA,
mode: ChecklistMode.INCLUDE,
});
expect(list.check(EXISTING_ITEM)).to.equal(true);
});

itLeaks('should check for missing values', async () => {
it('should check for missing values', async () => {
const list = new Checklist<string>({
data: TEST_DATA,
mode: ChecklistMode.INCLUDE,
Expand Down

0 comments on commit e34641a

Please sign in to comment.