Skip to content

Commit

Permalink
chore(main) add top-level import test (#298)
Browse files Browse the repository at this point in the history
* chore(main) add top-level import test

* fix(tests) disable node tests
  • Loading branch information
chrisgervang authored Feb 5, 2025
1 parent 19e4303 commit d591170
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 2 deletions.
13 changes: 12 additions & 1 deletion modules/main/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
// Copyright (c) vis.gl contributors

export {
VERSION,
// Adapter
DeckAdapter,
// Encoders
GifEncoder,
PNGSequenceEncoder,
JPEGSequenceEncoder,
JPEGEncoder,
Expand Down Expand Up @@ -37,5 +39,14 @@ export {
useHubbleGl,
BasicControls,
EncoderDropdown,
QuickAnimation
QuickAnimation,
ExportVideoModal,
ExportVideoPanelContainer,
InjectKeplerUI,
KeplerUIContext,
RenderPlayer,
ResolutionGuide,
WithKeplerUI,
createKeplerLayers,
injectKeplerUI
} from '@hubble.gl/react';
50 changes: 50 additions & 0 deletions test/imports-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// hubble.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors

import test from 'tape-promise/tape';

import * as hubble from 'hubble.gl';
import * as core from '@hubble.gl/core';
import * as react from '@hubble.gl/react';

test('Top-level imports', t0 => {
const hasEmptyExports = obj => {
for (const key in obj) {
if (obj[key] === undefined) {
return key;
}
}
return false;
};

t0.test('import "hubble.gl"', t => {
t.notOk(hasEmptyExports(hubble), 'No empty top-level export in hubble.gl');
t.notOk(hasEmptyExports(core), 'No empty top-level export in @hubble.gl/core');
t.notOk(hasEmptyExports(react), 'No empty top-level export in @hubble.gl/react');
t.end();
});

t0.end();
});

test('hubble.gl re-exports', t => {
const findMissingExports = (source, target) => {
const missingExports = [];
for (const key in source) {
// Exclude experimental exports
if (key[0] !== '_' && key !== 'experimental' && target[key] !== source[key]) {
missingExports.push(key);
}
}
return missingExports.length ? missingExports : null;
};

t.notOk(findMissingExports(core, hubble), 'hubble.gl re-exports everything from @hubble.gl/core');
t.notOk(
findMissingExports(react, hubble),
'hubble.gl re-exports everything from @hubble.gl/react'
);

t.end();
});
1 change: 1 addition & 0 deletions test/modules.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// hubble.gl
// SPDX-License-Identifier: MIT
// Copyright (c) vis.gl contributors
import './imports-spec';
import '../modules/core/test/index';
import '../modules/main/test/index';
import '../modules/react/test/index';
2 changes: 1 addition & 1 deletion test/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ _global.HTMLVideoElement = dom.window.HTMLVideoElement;
_global.requestAnimationFrame = cb => setTimeout(cb, 0);
_global.cancelAnimationFrame = t => clearTimeout(t);

import './modules';
// import './imports-spec';

0 comments on commit d591170

Please sign in to comment.