Co-authored-by: Mikhail Bashkirov <mikhail.bashkirov@ing.com> Co-authored-by: Thijs Louisse <thijs.louisse@ing.com> Co-authored-by: Joren Broekema <joren.broekema@ing.com> Co-authored-by: Gerjan van Geest <gerjan.van.geest@ing.com> Co-authored-by: Erik Kroes <erik.kroes@ing.com> Co-authored-by: Lars den Bakker <lars.den.bakker@ing.com>
33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
/* eslint-env mocha */
|
|
import { expect } from '@open-wc/testing';
|
|
|
|
import isLocalizeESModule from '../src/isLocalizeESModule.js';
|
|
|
|
describe('isLocalizeESModule', () => {
|
|
it('detects a module by finding the "default" key containing an object', () => {
|
|
expect(isLocalizeESModule({ default: {} })).to.equal(true);
|
|
});
|
|
|
|
it('detects a real ES module with a default export', async () => {
|
|
const mod = await import('./test-esmodule-default.js');
|
|
expect(isLocalizeESModule(mod)).to.equal(true);
|
|
});
|
|
|
|
it('ignores if the "default" key is a string', () => {
|
|
expect(isLocalizeESModule({ default: 'my string' })).to.equal(false);
|
|
});
|
|
|
|
it('ignores if there are extra keys to the "default" key', () => {
|
|
expect(isLocalizeESModule({ default: {}, otherKey: 'other key' })).to.equal(false);
|
|
expect(isLocalizeESModule({ default: {}, otherKey: {} })).to.equal(false);
|
|
});
|
|
|
|
it('ignores if there is no "default" key', () => {
|
|
expect(isLocalizeESModule({ otherKey: 'other key' })).to.equal(false);
|
|
expect(isLocalizeESModule({ otherKey: {} })).to.equal(false);
|
|
});
|
|
|
|
it('ignores if not an object', () => {
|
|
expect(isLocalizeESModule(undefined)).to.equal(false);
|
|
});
|
|
});
|