Skip to content

Commit dd43ae4

Browse files
authored
clean up a bit
1 parent 9506205 commit dd43ae4

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

Maths/test/Determinant.test.js

Lines changed: 10 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { expect } from 'vitest'
22
import { determinant } from '../Determinant'
33
describe('Determinant', () => {
4-
const validTestCases = [
4+
test.each([
55
[
66
[
77
[8, 1, 6],
@@ -37,9 +37,14 @@ describe('Determinant', () => {
3737
2476
3838
],
3939
[[[23]], 23]
40-
]
40+
])(
41+
'Should return the determinant of the square matrix.',
42+
(matrix, expected) => {
43+
expect(determinant(matrix)).toEqual(expected)
44+
}
45+
)
4146

42-
const errorTestCases = [
47+
test.each([
4348
[
4449
[
4550
[1, 6],
@@ -49,27 +54,10 @@ describe('Determinant', () => {
4954
'Square matrix is required.'
5055
],
5156
[[1, 3, 2, [5, 8, 6], 3], 'Input is not a valid 2D matrix.']
52-
]
53-
54-
test.each(validTestCases)(
55-
'Should return the determinant of the square matrix.',
56-
(matrix, expected) => {
57-
try {
58-
expect(determinant(matrix)).toEqual(expected)
59-
} catch (err) {
60-
expect(err.message).toEqual(expected)
61-
}
62-
}
63-
)
64-
65-
test.each(errorTestCases)(
57+
])(
6658
'Should return the error message.',
6759
(matrix, expected) => {
68-
try {
69-
expect(determinant(matrix)).toEqual(expected)
70-
} catch (err) {
71-
expect(err.message).toEqual(expected)
72-
}
60+
expect(() => determinant(matrix)).toThrowError(expected)
7361
}
7462
)
7563
})

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy