Skip to content

Commit 9506205

Browse files
committed
fix: seperate the test loops of error cases
1 parent 55a04d3 commit 9506205

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

Maths/test/Determinant.test.js

Lines changed: 17 additions & 3 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 testCases = [
4+
const validTestCases = [
55
[
66
[
77
[8, 1, 6],
@@ -36,7 +36,10 @@ describe('Determinant', () => {
3636
],
3737
2476
3838
],
39-
[[[23]], 23],
39+
[[[23]], 23]
40+
]
41+
42+
const errorTestCases = [
4043
[
4144
[
4245
[1, 6],
@@ -48,7 +51,7 @@ describe('Determinant', () => {
4851
[[1, 3, 2, [5, 8, 6], 3], 'Input is not a valid 2D matrix.']
4952
]
5053

51-
test.each(testCases)(
54+
test.each(validTestCases)(
5255
'Should return the determinant of the square matrix.',
5356
(matrix, expected) => {
5457
try {
@@ -58,4 +61,15 @@ describe('Determinant', () => {
5861
}
5962
}
6063
)
64+
65+
test.each(errorTestCases)(
66+
'Should return the error message.',
67+
(matrix, expected) => {
68+
try {
69+
expect(determinant(matrix)).toEqual(expected)
70+
} catch (err) {
71+
expect(err.message).toEqual(expected)
72+
}
73+
}
74+
)
6175
})

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