is-promise.spec.js 839 B

12345678910111213141516171819202122
  1. import {expect} from 'chai';
  2. import {isPromise} from './is-promise.js';
  3. describe('isPromise', function () {
  4. it('returns true if the given value has type of PromiseLike', function () {
  5. expect(isPromise(Promise.resolve())).to.be.true;
  6. expect(isPromise('string')).to.be.false;
  7. expect(isPromise('')).to.be.false;
  8. expect(isPromise(10)).to.be.false;
  9. expect(isPromise(0)).to.be.false;
  10. expect(isPromise(true)).to.be.false;
  11. expect(isPromise(false)).to.be.false;
  12. expect(isPromise(undefined)).to.be.false;
  13. expect(isPromise(null)).to.be.false;
  14. expect(isPromise({foo: 'bar'})).to.be.false;
  15. expect(isPromise({})).to.be.false;
  16. expect(isPromise([1, 2, 3])).to.be.false;
  17. expect(isPromise([])).to.be.false;
  18. expect(isPromise(NaN)).to.be.false;
  19. expect(isPromise(() => 10)).to.be.false;
  20. });
  21. });