Skip to content

Commit

Permalink
[Tests] add initial enzyme-adapter-utils unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jul 21, 2018
1 parent f4d779d commit 2113c8d
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions packages/enzyme-test-suite/test/adapter-utils-spec.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expect } from 'chai';
import { ensureKeyOrUndefined } from 'enzyme-adapter-utils';

describe('enzyme-adapter-utils', () => {
describe('ensureKeyOrUndefined', () => {
it('returns the key if truthy', () => {
[true, 42, 'foo', [], {}, () => {}].forEach((truthy) => {
expect(ensureKeyOrUndefined(truthy)).to.equal(truthy);
});
});

it('returns the empty string if the key is the empty string', () => {
expect(ensureKeyOrUndefined('')).to.equal('');
});

it('returns undefined if falsy and not the empty string', () => {
[null, undefined, false, 0, NaN].forEach((falsy) => {
expect(ensureKeyOrUndefined(falsy)).to.equal(undefined);
});
});
});
});

0 comments on commit 2113c8d

Please sign in to comment.