Files
create-index/test/createIndexCode.js
T
Guillaume BoddaertandGajus Kuizinas 65892e3bb8 feat: use es2015 syntax to re-export default export (#32)
BREAKING CHANGE:

This changes the output generated by create-index and can effect CI if it runs linting tests against create-index.
2017-01-27 14:44:07 +00:00

60 lines
1.4 KiB
JavaScript

/* eslint-disable no-restricted-syntax */
import {
expect
} from 'chai';
import createIndexCode from '../src/utilities/createIndexCode';
import codeExample from './codeExample';
describe('createIndexCode()', () => {
it('describes no children', () => {
const indexCode = createIndexCode([]);
expect(indexCode).to.equal(codeExample(`
// @create-index
`));
});
it('describes a single child', () => {
const indexCode = createIndexCode(['foo']);
expect(indexCode).to.equal(codeExample(`
// @create-index
export { default as foo } from './foo';
`));
});
it('describes multiple children', () => {
const indexCode = createIndexCode(['bar', 'foo']);
expect(indexCode).to.equal(codeExample(`
// @create-index
export { default as bar } from './bar';
export { default as foo } from './foo';
`));
});
context('file with extension', () => {
it('removes the extension from the export statement', () => {
const indexCode = createIndexCode(['foo.js']);
expect(indexCode).to.equal(codeExample(`
// @create-index
export { default as foo } from './foo.js';
`));
});
});
context('multiple, unsorted', () => {
it('sorts the files', () => {
const indexCode = createIndexCode(['foo', 'bar']);
expect(indexCode).to.equal(codeExample(`
// @create-index
export { default as bar } from './bar';
export { default as foo } from './foo';
`));
});
});
});