UNPKG

1.02 kBJavaScriptView Raw
1const add = (n1, n2) => {
2 return n1 + n2;
3};
4
5describe("Each", () => {
6 test("simple test", () => {
7 expect(add(1, 1)).toEqual(2);
8 });
9
10 test.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(".add(%p, %p)", (a, b, expected) => {
11 expect(add(a, b)).toBe(expected);
12 });
13});
14
15describe.each([[1, 1, 2], [1, 2, 3], [2, 1, 3]])(".add(%p, %p)", (a, b, expected) => {
16 test(`returns ${expected}`, () => {
17 expect(add(a, b)).toBe(expected);
18 });
19
20 test(`returned value not be greater than ${expected}`, () => {
21 expect(add(a, b)).not.toBeGreaterThan(expected);
22 });
23
24 test(`returned value not be less than ${expected}`, () => {
25 expect(add(a, b)).not.toBeLessThan(expected);
26 });
27
28 it(`returns ${expected}`, () => {
29 expect(add(a, b)).toBe(expected);
30 });
31
32 it(`returned value not be greater than ${expected}`, () => {
33 expect(add(a, b)).not.toBeGreaterThan(expected);
34 });
35
36 it(`returned value not be less than ${expected}`, () => {
37 expect(add(a, b)).not.toBeLessThan(expected);
38 });
39});