is-service-container.spec.js 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. import {expect} from 'chai';
  2. import {ServiceContainer} from '../service-container.js';
  3. import {isServiceContainer} from './is-service-container.js';
  4. import {SERVICE_CONTAINER_CLASS_NAME} from '../service-container.js';
  5. describe('isServiceContainer', function () {
  6. it('returns true for ServiceContainer instance', function () {
  7. const container = new ServiceContainer();
  8. const res = isServiceContainer(container);
  9. expect(res).to.be.true;
  10. });
  11. it('returns true if the given object has the kinds property of its constructor', function () {
  12. class CustomContainer {
  13. static kinds = [SERVICE_CONTAINER_CLASS_NAME];
  14. }
  15. const container = new CustomContainer();
  16. const res = isServiceContainer(container);
  17. expect(res).to.be.true;
  18. });
  19. it('returns false for not-container values', function () {
  20. expect(isServiceContainer('str')).to.be.false;
  21. expect(isServiceContainer(10)).to.be.false;
  22. expect(isServiceContainer(true)).to.be.false;
  23. expect(isServiceContainer(false)).to.be.false;
  24. expect(isServiceContainer({foo: 'bar'})).to.be.false;
  25. expect(isServiceContainer([])).to.be.false;
  26. expect(isServiceContainer(null)).to.be.false;
  27. expect(isServiceContainer(undefined)).to.be.false;
  28. });
  29. });