Skip to content

Commit 1e07b0c

Browse files
committed
addget-modules-list-for-target-version tests
1 parent eff765f commit 1e07b0c

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1234,7 +1234,7 @@ module.exports = {
12341234
{
12351235
files: [
12361236
'scripts/**',
1237-
'tests/*.mjs',
1237+
'tests/**/*.mjs',
12381238
],
12391239
// zx
12401240
globals: {

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,10 @@
121121
"test-entries-basic": "zx tests/commonjs.mjs",
122122
"test-entries-content": "zx tests/commonjs-entries-content.mjs",
123123
"test-entries-standalone": "run-s init test-entries",
124-
"test-compat-tools": "run-p test-compat-tool test-targets-parser",
125-
"test-compat-tool": "zx tests/compat-tool.mjs",
126-
"test-targets-parser": "zx tests/targets-parser.mjs",
124+
"test-compat-tools": "run-p test-compat-tool test-compat-targets-parser test-compat-get-modules-list-for-target-version",
125+
"test-compat-tool": "zx tests/compat-tools/compat.mjs",
126+
"test-compat-targets-parser": "zx tests/compat-tools/targets-parser.mjs",
127+
"test-compat-get-modules-list-for-target-version": "zx tests/compat-tools/get-modules-list-for-target-version.mjs",
127128
"test": "run-s init test-lint bundle test-unit test-promises test-observables test-entries test-compat-tools check",
128129
"ci-karma": "run-s init bundle test-unit-karma",
129130
"ci-tests": "run-s init bundle test-unit-node test-promises test-observables test-entries test-compat-tools",
File renamed without changes.
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { deepStrictEqual, throws } from 'assert';
2+
import getModulesListForTargetVersion from 'core-js-compat/get-modules-list-for-target-version.js';
3+
4+
const modules = require('core-js-compat/modules');
5+
const modulesByVersions = require('../../packages/core-js-compat/modules-by-versions');
6+
7+
const modules30 = modulesByVersions['3.0'];
8+
const filter = new Set([...modules30, ...modulesByVersions['3.1']]);
9+
const modules31 = modules.filter(it => filter.has(it));
10+
11+
deepStrictEqual(getModulesListForTargetVersion(3), modules30, 'num 3'); // TODO: Make it throw in core-js@4
12+
deepStrictEqual(getModulesListForTargetVersion('3'), modules30, '3'); // TODO: Make it throw in core-js@4
13+
deepStrictEqual(getModulesListForTargetVersion('3.0'), modules30, '3.0');
14+
deepStrictEqual(getModulesListForTargetVersion('3.0.0'), modules30, '3.0.0');
15+
deepStrictEqual(getModulesListForTargetVersion('3.0.1'), modules30, '3.0.1');
16+
deepStrictEqual(getModulesListForTargetVersion('3.0.0-alpha.1'), modules30, '3.0.0-alpha.1');
17+
deepStrictEqual(getModulesListForTargetVersion('3.1'), modules31, '3.1');
18+
deepStrictEqual(getModulesListForTargetVersion('3.1.0'), modules31, '3.1.0');
19+
deepStrictEqual(getModulesListForTargetVersion('3.1.1'), modules31, '3.1.1');
20+
21+
throws(() => getModulesListForTargetVersion('2.0'), RangeError, '2.0');
22+
throws(() => getModulesListForTargetVersion('4.0'), RangeError, '4.0');
23+
throws(() => getModulesListForTargetVersion('x'), TypeError, 'x');
24+
throws(() => getModulesListForTargetVersion('*'), TypeError, '*');
25+
throws(() => getModulesListForTargetVersion(), TypeError, 'no arg');
26+
27+
console.log(chalk.green('get-modules-list-for-target-version tested'));
File renamed without changes.

tests/compat/deno-runner.mjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/* eslint-disable no-console -- output */
21
import './tests.js';
32

43
var tests = globalThis.tests;

0 commit comments

Comments
 (0)