|
| 1 | +import { deepStrictEqual } from 'assert'; |
| 2 | +const compat = require('core-js-compat/compat'); |
| 3 | + |
| 4 | +deepStrictEqual(compat({ |
| 5 | + modules: [ |
| 6 | + 'core-js/es/math', |
| 7 | + 'es.array.at', |
| 8 | + /^es\.reflect/, |
| 9 | + ], |
| 10 | + exclude: [ |
| 11 | + 'es.reflect.prevent-extensions', |
| 12 | + ], |
| 13 | + targets: 'firefox 27', |
| 14 | +}), { |
| 15 | + list: [ |
| 16 | + 'es.array.at', |
| 17 | + 'es.math.clz32', |
| 18 | + 'es.math.expm1', |
| 19 | + 'es.math.to-string-tag', |
| 20 | + 'es.reflect.apply', |
| 21 | + 'es.reflect.construct', |
| 22 | + 'es.reflect.define-property', |
| 23 | + 'es.reflect.delete-property', |
| 24 | + 'es.reflect.get', |
| 25 | + 'es.reflect.get-own-property-descriptor', |
| 26 | + 'es.reflect.get-prototype-of', |
| 27 | + 'es.reflect.has', |
| 28 | + 'es.reflect.is-extensible', |
| 29 | + 'es.reflect.own-keys', |
| 30 | + 'es.reflect.set', |
| 31 | + 'es.reflect.set-prototype-of', |
| 32 | + 'es.reflect.to-string-tag', |
| 33 | + ], |
| 34 | + targets: { |
| 35 | + 'es.array.at': { firefox: '27' }, |
| 36 | + 'es.math.clz32': { firefox: '27' }, |
| 37 | + 'es.math.expm1': { firefox: '27' }, |
| 38 | + 'es.math.to-string-tag': { firefox: '27' }, |
| 39 | + 'es.reflect.apply': { firefox: '27' }, |
| 40 | + 'es.reflect.construct': { firefox: '27' }, |
| 41 | + 'es.reflect.define-property': { firefox: '27' }, |
| 42 | + 'es.reflect.delete-property': { firefox: '27' }, |
| 43 | + 'es.reflect.get': { firefox: '27' }, |
| 44 | + 'es.reflect.get-own-property-descriptor': { firefox: '27' }, |
| 45 | + 'es.reflect.get-prototype-of': { firefox: '27' }, |
| 46 | + 'es.reflect.has': { firefox: '27' }, |
| 47 | + 'es.reflect.is-extensible': { firefox: '27' }, |
| 48 | + 'es.reflect.own-keys': { firefox: '27' }, |
| 49 | + 'es.reflect.set': { firefox: '27' }, |
| 50 | + 'es.reflect.set-prototype-of': { firefox: '27' }, |
| 51 | + 'es.reflect.to-string-tag': { firefox: '27' }, |
| 52 | + }, |
| 53 | +}, 'basic'); |
| 54 | + |
| 55 | +deepStrictEqual(compat({ |
| 56 | + modules: [ |
| 57 | + /^es\.math\.a/, |
| 58 | + /^es\.math\.c/, |
| 59 | + ], |
| 60 | + exclude: 'es.math.asinh', |
| 61 | +}), { |
| 62 | + list: [ |
| 63 | + 'es.math.acosh', |
| 64 | + 'es.math.atanh', |
| 65 | + 'es.math.cbrt', |
| 66 | + 'es.math.clz32', |
| 67 | + 'es.math.cosh', |
| 68 | + ], |
| 69 | + targets: { |
| 70 | + 'es.math.acosh': {}, |
| 71 | + 'es.math.atanh': {}, |
| 72 | + 'es.math.cbrt': {}, |
| 73 | + 'es.math.clz32': {}, |
| 74 | + 'es.math.cosh': {}, |
| 75 | + }, |
| 76 | +}, 'no target'); |
| 77 | + |
| 78 | +deepStrictEqual(compat({ |
| 79 | + modules: /^es\.math\.a/, |
| 80 | +}), { |
| 81 | + list: [ |
| 82 | + 'es.math.acosh', |
| 83 | + 'es.math.asinh', |
| 84 | + 'es.math.atanh', |
| 85 | + ], |
| 86 | + targets: { |
| 87 | + 'es.math.acosh': {}, |
| 88 | + 'es.math.asinh': {}, |
| 89 | + 'es.math.atanh': {}, |
| 90 | + }, |
| 91 | +}, 'no exclude'); |
| 92 | + |
| 93 | +deepStrictEqual( |
| 94 | + compat({ targets: { chrome: 93 } }), |
| 95 | + compat({ modules: 'core-js', targets: { chrome: 93 } }), |
| 96 | + 'no modules', |
| 97 | +); |
| 98 | + |
| 99 | +deepStrictEqual(compat({ |
| 100 | + modules: 'core-js/es/math', |
| 101 | + targets: { |
| 102 | + chrome: 40, |
| 103 | + firefox: 27, |
| 104 | + }, |
| 105 | +}), { |
| 106 | + list: [ |
| 107 | + 'es.math.acosh', |
| 108 | + 'es.math.clz32', |
| 109 | + 'es.math.expm1', |
| 110 | + 'es.math.hypot', |
| 111 | + 'es.math.to-string-tag', |
| 112 | + ], |
| 113 | + targets: { |
| 114 | + 'es.math.acosh': { chrome: '40' }, |
| 115 | + 'es.math.clz32': { firefox: '27' }, |
| 116 | + 'es.math.expm1': { firefox: '27' }, |
| 117 | + 'es.math.hypot': { chrome: '40' }, |
| 118 | + 'es.math.to-string-tag': { chrome: '40', firefox: '27' }, |
| 119 | + }, |
| 120 | +}, 'some targets'); |
| 121 | + |
| 122 | +console.log(chalk.green('compat tool tested')); |
0 commit comments