Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
puehringer committed Feb 24, 2024
1 parent 9430356 commit ca6fcdf
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions tests/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { readdirSync, readFileSync } from 'fs';
import packageJson from '../package.json';

const NOT_EXPORTED_PACKAGES = ['assets', 'demo', 'locales', 'scss', 'stories'];
const ADDITIONAL_EXPORTS = ['.', './assets/*', './plotly/full', './scss/*', './dist/scss/*', './phovea_registry', './package.json'];
const ADDITIONAL_EXPORTS = ['.', './assets/*', './plotly/full', './scss/*', './phovea_registry', './package.json'];

describe('package.json exports', () => {
expect(packageJson.exports).toBeDefined();
Expand All @@ -31,17 +31,15 @@ describe('package.json exports', () => {
test.each(allPackages)('checks if package %s is exported', (p) => {
const exported = packageJson.exports[`./${p}`];
expect(exported).toBeDefined();
expect(Object.keys(exported)).toStrictEqual(['types', 'import', 'default']);
// Some packages are exported as .tsx
const extension = exported?.types[1]?.includes('.tsx') ? 'tsx' : 'ts';
expect(exported.types).toEqual([`./dist/${p}/index.d.ts`, `./src/${p}/index.${extension}`]);
expect(exported.import).toEqual([`./dist/${p}/index.js`, `./src/${p}/index.${extension}`]);
expect(exported.default).toEqual([`./dist/${p}/index.js`, `./src/${p}/index.${extension}`]);
const extension = exported?.includes('.tsx') ? 'tsx' : 'ts';
expect(exported).toEqual(`./src/${p}/index.${extension}`);
expect(rootIndexTs).toBeFalsy();
expect(rootIndexTs).toBeFalsy();
});

it('exports the package.json and phovea_registry', () => {
expect(packageJson.exports['./phovea_registry']).toEqual(['./dist/phovea_registry.js', './src/phovea_registry.ts']);
expect(packageJson.exports['./phovea_registry']).toEqual('./src/phovea_registry.ts');
expect(packageJson.exports['./package.json']).toBe('./package.json');
});
});

0 comments on commit ca6fcdf

Please sign in to comment.