Debian Codegraph @

packages/babel-helper-compilation-targets/test/targets-supported.skip-bundled.js

raw symbols SCIP
1 import { targetsSupported } from "../lib/filter-items.js";
2
3 describe("targetsSupported", () => {
4 const MAX_VERSION = `${Number.MAX_SAFE_INTEGER}.0.0`;
5
6 it("returns false if no targets are specified", () => {
7 expect(targetsSupported({}, {})).toBe(false);
8 });
9
10 it("returns false if plugin feature is not implemented in one or more targets", () => {
11 let targets;
12 const plugin = {
13 edge: false,
14 firefox: 45,
15 chrome: 49,
16 };
17
18 targets = {
19 chrome: MAX_VERSION,
20 firefox: MAX_VERSION,
21 };
22 expect(targetsSupported(targets, plugin)).toBe(true);
23
24 targets = {
25 edge: "12",
26 };
27 expect(targetsSupported(targets, plugin)).toBe(false);
28 });
29
30 it("returns true if plugin feature is implemented by lower than target", () => {
31 const plugin = {
32 chrome: 49,
33 };
34 const targets = {
35 chrome: MAX_VERSION,
36 };
37
38 expect(targetsSupported(targets, plugin)).toBe(true);
39 });
40
41 it("returns true if plugin feature is implemented is equal to target", () => {
42 const plugin = {
43 chrome: 49,
44 };
45 const targets = {
46 chrome: "49.0.0",
47 };
48 expect(targetsSupported(targets, plugin)).toBe(true);
49 });
50
51 it("returns false if plugin feature is implemented is greater than target", () => {
52 const plugin = {
53 chrome: 50,
54 };
55 const targets = {
56 chrome: "49.0.0",
57 };
58 expect(targetsSupported(targets, plugin)).toBe(false);
59 });
60
61 it("returns when target is a decimal", () => {
62 const plugin = {
63 node: 6.9,
64 };
65 const targets = {
66 node: "6.10.0",
67 };
68 expect(targetsSupported(targets, plugin)).toBe(true);
69 });
70
71 it("throws an error if target version is invalid", () => {
72 const plugin = {
73 chrome: 50,
74 };
75 const targets = {
76 chrome: 55,
77 };
78 expect(() => targetsSupported(targets, plugin)).toThrow();
79 });
80 });