@@ -10,21 +10,41 @@ const imageNoHand =
10
10
"https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Black_colour.jpg/640px-Black_colour.jpg" ;
11
11
12
12
describe ( "classifyImage function" , async ( ) => {
13
- it ( "returns hand when shown a picture of a hand" , async ( ) => {
14
- const result = await classifyImage ( model , imageHand , metadata ) ;
13
+ describe ( "returns" , async ( ) => {
14
+ it ( "returns hand when shown a picture of a hand" , async ( ) => {
15
+ const result = await classifyImage ( model , imageHand , metadata ) ;
16
+ if ( result instanceof Error ) {
17
+ return new Error ( ) ;
18
+ } else {
19
+ assert . equal ( result [ 0 ] . label , "Hand" ) ;
20
+ }
21
+ } ) ;
15
22
16
- assert . equal ( result [ 0 ] . label , "Hand" ) ;
17
- } ) ;
23
+ it ( "returns 'No hand' when shown a picture not including hand" , async ( ) => {
24
+ const result = await classifyImage ( model , imageNoHand , metadata ) ;
18
25
19
- it ( "returns 'No hand' when shown a picture not including hand" , async ( ) => {
20
- const result = await classifyImage ( model , imageNoHand , metadata ) ;
26
+ if ( result instanceof Error ) {
27
+ return new Error ( ) ;
28
+ } else {
29
+ assert . equal ( result [ 0 ] . label , "No hand" ) ;
30
+ }
31
+ } ) ;
21
32
22
- assert . equal ( result [ 0 ] . label , "No hand" ) ;
33
+ it ( "returns a probability level" , async ( ) => {
34
+ const result = await classifyImage ( model , imageNoHand , metadata ) ;
35
+ if ( result instanceof Error ) {
36
+ return new Error ( ) ;
37
+ } else {
38
+ assert . notEqual ( result [ 0 ] . probability , null ) ;
39
+ }
40
+ } ) ;
23
41
} ) ;
42
+ describe ( "Error boundries" , async ( ) => {
43
+ it ( "returns an error when missing a parameter" , async ( ) => {
44
+ //@ts -expect-error
45
+ const result = await classifyImage ( imageNoHand , metadata ) ;
24
46
25
- it ( "returns a probability level" , async ( ) => {
26
- const result = await classifyImage ( model , imageNoHand , metadata ) ;
27
-
28
- assert . notEqual ( result [ 0 ] . probability , null ) ;
47
+ assert . ok ( result instanceof Error ) ;
48
+ } ) ;
29
49
} ) ;
30
50
} ) ;
0 commit comments