index-test.js 921 B

1234567891011121314151617181920212223242526272829303132333435
  1. /* eslint-env mocha */
  2. import fs from 'fs';
  3. import path from 'path';
  4. import assert from 'assert';
  5. import core from '../../src/index';
  6. const src = fs.readdirSync(path.resolve(__dirname, '../../src'))
  7. .filter((f) => f.indexOf('.js') >= 0)
  8. .map((f) => path.basename(f, '.js'));
  9. describe('main export', () => {
  10. it('should export an object', () => {
  11. const expected = 'object';
  12. const actual = typeof core;
  13. assert.equal(actual, expected);
  14. });
  15. src.filter((f) => f !== 'index').forEach((f) => {
  16. it(`should export ${f}`, () => {
  17. assert.equal(
  18. core[f],
  19. require(path.join('../../src/', f)).default // eslint-disable-line
  20. );
  21. });
  22. it(`should export ${f} from root`, () => {
  23. const file = `${f}.js`;
  24. const expected = true;
  25. const actual = fs.statSync(path.join(path.resolve('.'), file)).isFile();
  26. assert.equal(actual, expected);
  27. });
  28. });
  29. });