Rename color constants and move util function into separate file (#6074)

* rename constant colors to UPPERCASE

* Move isDefined into its own file and add unit test
This commit is contained in:
Krist Wongsuphasawat
2018-10-11 14:05:34 -07:00
committed by Grace Guo
parent c0f685b640
commit 64383ce96e
6 changed files with 37 additions and 14 deletions

View File

@@ -0,0 +1,22 @@
import { it, describe } from 'mocha';
import { expect } from 'chai';
import isDefined from '../../../src/utils/isDefined';
describe('isDefined(value)', () => {
it('returns true if value is not null and not undefined', () => {
expect(isDefined(0)).to.equal(true);
expect(isDefined(1)).to.equal(true);
expect(isDefined('')).to.equal(true);
expect(isDefined('a')).to.equal(true);
expect(isDefined([])).to.equal(true);
expect(isDefined([0])).to.equal(true);
expect(isDefined([1])).to.equal(true);
expect(isDefined({})).to.equal(true);
expect(isDefined({ a: 1 })).to.equal(true);
expect(isDefined([{}])).to.equal(true);
});
it('returns false otherwise', () => {
expect(isDefined(null)).to.equal(false);
expect(isDefined(undefined)).to.equal(false);
});
});