|
1 | | -import { processContainers } from "../src/logical-container"; |
| 1 | +import { |
| 2 | + isLogicalOr, |
| 3 | + isLogicalAnd, |
| 4 | + isSimple, |
| 5 | + processContainers, |
| 6 | +} from "../src/logical-container"; |
2 | 7 |
|
3 | 8 | describe("LogicalContainer", () => { |
| 9 | + describe("isLogicalOr()", () => { |
| 10 | + test.each([ |
| 11 | + true, |
| 12 | + false, |
| 13 | + 0, |
| 14 | + 1, |
| 15 | + "", |
| 16 | + "test", |
| 17 | + null, |
| 18 | + undefined, |
| 19 | + [], |
| 20 | + [1], |
| 21 | + {}, |
| 22 | + { and: [] }, |
| 23 | + ])("should return false when has no 'or' property %#", (value) => { |
| 24 | + expect(isLogicalOr(value)).toBe(false); |
| 25 | + }); |
| 26 | + |
| 27 | + test.each([{ or: [] }, { or: [1] }, { or: [1, 2, 3] }])( |
| 28 | + "should return true for object with 'or' property %#", |
| 29 | + (value) => { |
| 30 | + expect(isLogicalOr(value)).toBe(true); |
| 31 | + }, |
| 32 | + ); |
| 33 | + }); |
| 34 | + |
| 35 | + describe("isLogicalAnd()", () => { |
| 36 | + test.each([ |
| 37 | + true, |
| 38 | + false, |
| 39 | + 0, |
| 40 | + 1, |
| 41 | + "", |
| 42 | + "test", |
| 43 | + null, |
| 44 | + undefined, |
| 45 | + [], |
| 46 | + [1], |
| 47 | + {}, |
| 48 | + { or: [] }, |
| 49 | + ])("should return false when has no 'and' property %#", (value) => { |
| 50 | + expect(isLogicalAnd(value)).toBe(false); |
| 51 | + }); |
| 52 | + |
| 53 | + test.each([{ and: [] }, { and: [1] }, { and: [1, 2, 3] }])( |
| 54 | + "should return true for object with 'and' property %#", |
| 55 | + (value) => { |
| 56 | + expect(isLogicalAnd(value)).toBe(true); |
| 57 | + }, |
| 58 | + ); |
| 59 | + }); |
| 60 | + |
| 61 | + describe("isSimple()", () => { |
| 62 | + test.each([true, false, 0, 1, "", "test", null, undefined, [], [1], {}])( |
| 63 | + "should return true for non-logical values %#", |
| 64 | + (value) => { |
| 65 | + expect(isSimple(value)).toBe(true); |
| 66 | + }, |
| 67 | + ); |
| 68 | + |
| 69 | + test.each([{ or: [] }, { or: [1] }, { and: [] }, { and: [1] }])( |
| 70 | + "should return false for logical containers %#", |
| 71 | + (value) => { |
| 72 | + expect(isSimple(value)).toBe(false); |
| 73 | + }, |
| 74 | + ); |
| 75 | + }); |
| 76 | + |
4 | 77 | describe("processContainers()", () => { |
5 | 78 | test("should process simples", () => { |
6 | 79 | expect(processContainers([1])).toEqual([[1]]); |
|
0 commit comments