Skip to content

Commit f9bb739

Browse files
test: add example of testing unique numbers
1 parent ce65742 commit f9bb739

1 file changed

Lines changed: 85 additions & 5 deletions

File tree

src/test/testing.spec.ts

Lines changed: 85 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,101 @@ import { Testing } from '../lib/testing.class';
66
* Initialize testing.
77
*/
88
const testing = new Testing(
9-
true, // Allows executing the `describe()` method globally.
10-
true, // Allows executing the `it()` method globally.
9+
false, // Disallows executing the `describe()` method globally.
10+
false, // Disallows executing the `it()` method globally.
1111
{
12-
describe: [], // Executable unique numbers of `describe()` methods to execute when globally is disallowed.
13-
it: [], // Executable unique numbers of `it()` methods to execute when globally is disallowed.
12+
describe: [1, 2, 3, 5], // Executable unique numbers of `describe()` methods to execute when globally is disallowed.
13+
it: [1], // Executable unique numbers of `it()` methods inside the `describe()` to execute when globally is disallowed.
1414
}
1515
);
16+
17+
testing.describe('[counter] First describe', () => {
18+
testing
19+
.it('[counter] First it() in first describe 1-1', () =>
20+
expect(false).toBeFalse()
21+
)
22+
.it('[counter] Second it() in first describe 1-2', () =>
23+
expect(true).toBeTrue()
24+
)
25+
.it('[counter] Second it() in first describe 1-3', () =>
26+
expect(true).toBeTrue()
27+
)
28+
.it('[counter] Fourth it() in first describe() 1-4', () =>
29+
expect(true).toBeTrue()
30+
)
31+
.describe('[counter] Second describe()', () => {
32+
testing.it('[counter] First it() in second describe() 2-1', () =>
33+
expect(true).toBeTrue()
34+
);
35+
})
36+
.describe('[counter] Third describe()', () => {
37+
testing.it('[counter] First it() in third describe() 3-1', () =>
38+
expect(true).toBeTrue()
39+
);
40+
})
41+
.describe('[counter] Fourth describe()', () => {
42+
testing.it('[counter] First it() in fourth describe() 3-1', () =>
43+
expect(true).toBeTrue()
44+
);
45+
});
46+
});
47+
testing.describe('[counter] Fifth describe', () =>
48+
testing.it('[counter] First it() in fifth describe 5-1', () =>
49+
expect(false).toBeFalse()
50+
)
51+
);
52+
53+
/**
54+
* Testing.defineDescribe()
55+
*/
56+
const testingDescribe = Testing.defineDescribe('defineDescribe()', () => {
57+
const numberSpec = Testing.defineIt(
58+
'The value must be a number type',
59+
() => {
60+
expect(is.number(5)).toBeTruthy();
61+
},
62+
3000
63+
);
64+
numberSpec(false); // Do not execute.
65+
numberSpec(false); // Execute.
66+
});
67+
68+
testingDescribe(false); // Do not execute.
69+
testingDescribe(false); // Execute.
70+
71+
/**
72+
* describe().
73+
*/
74+
testing.describe(
75+
'[counter] describe()',
76+
() => {},
77+
false // Whether or not execute suite
78+
);
79+
80+
/**
81+
* it().
82+
*/
83+
testing.describe(
84+
'[counter] describe()',
85+
() =>
86+
testing.it(
87+
'[counter] it()',
88+
() => {
89+
expect(true).toBeTruthy();
90+
},
91+
false // Whether or not execute spec
92+
),
93+
false // Whether or not execute suite
94+
);
95+
1696
/**
1797
* toBe()
1898
*/
1999
testing.describe('string', () => {
20100
testing.toBe(
21101
`Checks the value against the string`,
22102
is.stringType('my name'),
23-
true
103+
false
24104
);
25105
});
26106

0 commit comments

Comments
 (0)