Skip to content

Commit

Permalink
migrate unit tests to vitest
Browse files Browse the repository at this point in the history
  • Loading branch information
k-yle committed Sep 3, 2024
1 parent 7afecd3 commit 7bc94d6
Show file tree
Hide file tree
Showing 9 changed files with 3,599 additions and 5,529 deletions.
109 changes: 0 additions & 109 deletions config/karma.conf.js

This file was deleted.

4 changes: 3 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ export default [
languageOptions: {
globals: {
...globals.node,
...globals.mocha,
...globals.jest,
'before': 'readonly',
'after': 'readonly',
'd3': 'readonly',
'iD': 'readonly',
'sinon': 'readonly',
Expand Down
4 changes: 3 additions & 1 deletion modules/core/file_fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ export function coreFileFetcher() {
function getUrl(url, which) {
let prom = _inflight[url];
if (!prom) {
_inflight[url] = prom = fetch(url)
_inflight[url] = prom = (window.VITEST ? import(`../${url}`) : fetch(url))
.then(response => {
if (window.VITEST) return response.default;

if (!response.ok || !response.json) {
throw new Error(response.status + ' ' + response.statusText);
}
Expand Down
12 changes: 12 additions & 0 deletions modules/globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { FetchMockStatic } from 'fetch-mock';

declare global {
declare var iD: typeof import('.');
declare var d3: import('d3');
declare var fetchMock: FetchMockStatic;
declare var before: typeof beforeEach;
declare var after: typeof afterEach;
declare var VITEST: true;
}

export {};
Loading

0 comments on commit 7bc94d6

Please sign in to comment.