@@ -10,21 +10,41 @@ const imageNoHand =
1010 "https://upload.wikimedia.org/wikipedia/commons/thumb/5/50/Black_colour.jpg/640px-Black_colour.jpg" ;
1111
1212describe ( "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+ } ) ;
1522
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 ) ;
1825
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+ } ) ;
2132
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+ } ) ;
2341 } ) ;
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 ) ;
2446
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+ } ) ;
2949 } ) ;
3050} ) ;
0 commit comments