|
| 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')); |
0 commit comments