Skip to content

Commit bd9cfa8

Browse files
committed
style: use it.each
1 parent cee9652 commit bd9cfa8

File tree

1 file changed

+19
-32
lines changed

1 file changed

+19
-32
lines changed

Hashes/tests/SHA1.test.js

+19-32
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,24 @@ import { describe, test } from 'vitest'
22
import { SHA1 } from '../SHA1'
33

44
describe('Testing SHA1 function', () => {
5-
const TEST_CASES = [
6-
{ args: [''], expected: 'da39a3ee5e6b4b0d3255bfef95601890afd80709' },
7-
{
8-
args: ['The quick brown fox jumps over the lazy dog'],
9-
expected: '2fd4e1c67a2d28fced849ee1bb76e7391b93eb12'
10-
},
11-
{
12-
args: ['The quick brown fox jumps over the lazy cog'],
13-
expected: 'de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3'
14-
},
15-
{ args: ['a'], expected: '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8' },
16-
{
17-
args: ['Today is 29.01.2024!'],
18-
expected: 'ae829b60d11fb5ab527d5db2501e06da3402718d'
19-
},
20-
{
21-
args: ['Have a nice day.'],
22-
expected: 'ed51dd3909281c25db5e1d8b1ce6fc701fda20ab'
23-
},
24-
{
25-
args: [
26-
'12345678901234567890123456789012345678901234567890123456789012345678901234567890'
27-
],
28-
expected: '50abf5706a150990a08b2c5ea40fa0e585554732'
29-
}
30-
]
31-
32-
TEST_CASES.forEach((testCase) => {
33-
it(`check with ${JSON.stringify(testCase.args)}`, () => {
34-
const result = SHA1.apply(this, testCase.args)
35-
expect(testCase.expected).toEqual(result)
36-
})
5+
it.each([
6+
['', 'da39a3ee5e6b4b0d3255bfef95601890afd80709'],
7+
[
8+
'The quick brown fox jumps over the lazy dog',
9+
'2fd4e1c67a2d28fced849ee1bb76e7391b93eb12'
10+
],
11+
[
12+
'The quick brown fox jumps over the lazy cog',
13+
'de9f2c7fd25e1b3afad3e85a0bd17d9b100db4b3'
14+
],
15+
['a', '86f7e437faa5a7fce15d1ddcb9eaeaea377667b8'],
16+
['Today is 29.01.2024!', 'ae829b60d11fb5ab527d5db2501e06da3402718d'],
17+
['Have a nice day.', 'ed51dd3909281c25db5e1d8b1ce6fc701fda20ab'],
18+
[
19+
'12345678901234567890123456789012345678901234567890123456789012345678901234567890',
20+
'50abf5706a150990a08b2c5ea40fa0e585554732'
21+
]
22+
])('check with %j', (input, expected) => {
23+
expect(SHA1(input)).toBe(expected)
3724
})
3825
})

0 commit comments

Comments
 (0)