11const createLookup = require ( "./lookup.js" ) ;
22
3- test . todo ( "creates a country currency code lookup for multiple codes" ) ;
3+ describe ( "when given invalid inputs" , ( ) => {
4+ test ( "should return invalid input error, if the input is an empty array" , ( ) => {
5+ expect ( ( ) => createLookup ( [ ] ) ) . toThrow (
6+ "Input should not be an empty array"
7+ ) ;
8+ } ) ;
9+ test ( "should return invalid input error, if the input isn't an array of arrays" , ( ) => {
10+ expect ( ( ) => createLookup ( [ "hi" , "hello" ] ) ) . toThrow (
11+ "Invalid input. All elements should be arrays"
12+ ) ;
13+ } ) ;
14+ test ( "should return invalid input error, if the input isn't an array of arrays" , ( ) => {
15+ expect ( ( ) => createLookup ( "hi" ) ) . toThrow (
16+ "Invalid input. It should be an array"
17+ ) ;
18+ } ) ;
19+ test ( "should return invalid input error, if the input isn't an array of arrays" , ( ) => {
20+ expect ( ( ) => createLookup ( 2 ) ) . toThrow (
21+ "Invalid input. It should be an array"
22+ ) ;
23+ } ) ;
24+ } ) ;
25+
26+ describe ( "when given valid inputs" , ( ) => {
27+ test ( "should return an object where (Input ==> Output): keys:values ==> country code: corresponding currency" , ( ) => {
28+ expect (
29+ createLookup ( [
30+ [ "US" , "USD" ] ,
31+ [ "CA" , "CAD" ] ,
32+ ] )
33+ ) . toEqual ( {
34+ US : "USD" ,
35+ CA : "CAD" ,
36+ } ) ;
37+ } ) ;
38+ } ) ;
439
540/*
641
@@ -9,7 +44,7 @@ Create a lookup object of key value pairs from an array of code pairs
944Acceptance Criteria:
1045
1146Given
12- - An array of arrays representing country code and currency code pairs
47+ - An array of arrays representing when given invalid inputs code pairs
1348 e.g. [['US', 'USD'], ['CA', 'CAD']]
1449
1550When
0 commit comments