4
4
expect ,
5
5
} from 'vitest' ;
6
6
7
+ import Attempt from '@/library/Attempt' ;
8
+
7
9
import {
8
10
numberTaxonomy ,
9
11
} from '../../numberTaxonomy' ;
@@ -72,8 +74,10 @@ describe(greatestCommonDivisor, () => {
72
74
73
75
describe ( 'when generated' , ( ) => {
74
76
describe ( 'due to fractional operands' , ( ) => {
77
+ const eulers = numberTaxonomy . fractional . transcendental ; // c-spell:words eulers
78
+
75
79
const combosOfFractionalNumbers = symmetricPairCombos ( {
76
- of : numberTaxonomy . fractional . transcendental ,
80
+ of : eulers ,
77
81
filler : primeA ,
78
82
} ) ;
79
83
@@ -83,9 +87,32 @@ describe(greatestCommonDivisor, () => {
83
87
expect ( ( ) => greatestCommonDivisor ( ...$0 ) ) . toThrow ( Error ) ;
84
88
} ) ;
85
89
86
- it . todo ( 'should safely propagate the error' ) ;
90
+ it . each ( combosOfFractionalNumbers ) ( 'should safely propagate the error' , ( ...$0 ) => {
91
+ expect . assertions ( 1 ) ;
92
+
93
+ expect ( ( ) => greatestCommonDivisor ( ...$0 ) ) . toThrow ( Attempt . NonActionableError ) ;
94
+ } ) ;
95
+
96
+ const fractionalCombosWithMessage = [
97
+ {
98
+ numbers : [ eulers , primeA ] as const ,
99
+ message : 'Left operand must be whole.' ,
100
+ } ,
101
+ {
102
+ numbers : [ eulers , eulers ] as const ,
103
+ message : 'Left operand must be whole.' ,
104
+ } ,
105
+ {
106
+ numbers : [ primeA , eulers ] as const ,
107
+ message : 'Right operand must be whole.' ,
108
+ } ,
109
+ ] ;
110
+
111
+ it . each ( fractionalCombosWithMessage ) ( 'should communicate clearly with developers' , ( $0 ) => {
112
+ expect . assertions ( 1 ) ;
87
113
88
- it . todo ( 'should communicate clearly with developers' ) ;
114
+ expect ( ( ) => greatestCommonDivisor ( ...$0 . numbers ) ) . toThrow ( $0 . message ) ;
115
+ } ) ;
89
116
} ) ;
90
117
} ) ;
91
118
} ) ;
0 commit comments