requiring.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import ImportedHashids from '../';
  2. import * as AsteriskImportedHashids from '../';
  3. import { assert } from 'chai';
  4. describe('requiring', () => {
  5. it('via node', () => {
  6. const Hashids = require('../');
  7. assert.isFunction(Hashids);
  8. const instance = new Hashids('Not Real', 5, 'ABCDEFGHJKMNPQRTWXY234689');
  9. assert.instanceOf(instance, Hashids);
  10. });
  11. it('via babel-es interop', () => {
  12. function _interopRequireDefault(obj) {
  13. return obj && obj.__esModule ? obj : { default: obj };
  14. }
  15. const _hashids = require('../');
  16. const _hashids2 = _interopRequireDefault(_hashids);
  17. assert.isFunction(_hashids2.default);
  18. const Hashids = _hashids2.default;
  19. const instance = new Hashids('Not Real', 5, 'ABCDEFGHJKMNPQRTWXY234689');
  20. assert.instanceOf(instance, Hashids);
  21. });
  22. it('via babel default import', () => {
  23. assert.isFunction(ImportedHashids);
  24. const instance = new ImportedHashids('Not Real', 5, 'ABCDEFGHJKMNPQRTWXY234689');
  25. assert.instanceOf(instance, ImportedHashids);
  26. });
  27. it('via babel asterisk import', () => {
  28. assert.isFunction(AsteriskImportedHashids);
  29. const instance = new AsteriskImportedHashids('Not Real', 5, 'ABCDEFGHJKMNPQRTWXY234689');
  30. assert.instanceOf(instance, AsteriskImportedHashids);
  31. });
  32. });