@@ -4,7 +4,7 @@ import transactions from "../../data/transactions";
4
4
import { EUR_TO_NOK } from "../constants" ;
5
5
import { currencyFilter , toAmount } from "./__spoilers/dontopen" ;
6
6
7
- import { filterByCurrency } from "./currying-partial-application" ;
7
+ import { dkkToSek , ninetyDkkInNok } from "./currying-partial-application" ;
8
8
import * as CPA from "./currying-partial-application" ;
9
9
10
10
describe ( "OPPGAVE 3.1" , ( ) => {
@@ -18,38 +18,26 @@ describe("OPPGAVE 3.1", () => {
18
18
. slice ( 0 , 5 ) ;
19
19
20
20
expect ( result ) . toEqual ( [
21
- - 176572.8336 , - 180234.66 , - 195101.136 , - 292522.99919999996 ,
22
- - 42670.547999999995 ,
21
+ - 176572.8336 , - 180234.66 , - 195101.136 , - 292522.99919999996 , - 42670.547999999995 ,
23
22
] ) ;
24
23
} ) ;
25
24
} ) ;
26
25
27
26
describe ( "OPPGAVE 3.2" , ( ) => {
27
+ it ( "tell if transaction is the given currency" , ( ) => {
28
+ const isCurrency = CPA . isCurrencyCurried ( "NOK" ) ;
28
29
29
- } ) ;
30
-
31
- describe ( "TODO maybe use, maybe garb" , ( ) => {
32
- it ( "filters out all transactions in NOK" , ( ) => {
33
- expect ( filterByCurrency ( "NOK" , transactions ) ) . toHaveLength ( 165 ) ;
34
- } ) ;
35
-
36
- it ( "filters out all transactions in SEK" , ( ) => {
37
- expect ( filterByCurrency ( "SEK" , transactions ) ) . toHaveLength ( 150 ) ;
38
- } ) ;
39
-
40
- it ( "filters out all transactions in DKK" , ( ) => {
41
- expect ( filterByCurrency ( "DKK" , transactions ) ) . toHaveLength ( 195 ) ;
42
- } ) ;
43
-
44
- it ( "filters out all transactions in EUR" , ( ) => {
45
- expect ( filterByCurrency ( "EUR" , transactions ) ) . toHaveLength ( 159 ) ;
30
+ expect ( isCurrency ( transactions [ 0 ] ) ) . toBe ( true ) ;
31
+ expect ( isCurrency ( transactions [ 1 ] ) ) . toBe ( false ) ;
46
32
} ) ;
33
+ } ) ;
47
34
48
- it ( "filters out all transactions in USD" , ( ) => {
49
- expect ( filterByCurrency ( "USD" , transactions ) ) . toHaveLength ( 172 ) ;
35
+ describe ( "OPPGAVE 3.3" , ( ) => {
36
+ it ( "convert from DKK to SEK" , ( ) => {
37
+ expect ( dkkToSek ( 100 ) ) . toBe ( 154 ) ;
50
38
} ) ;
51
39
52
- it ( "filters out all transactions in GBP " , ( ) => {
53
- expect ( filterByCurrency ( "GBP" , transactions ) ) . toHaveLength ( 171 ) ;
40
+ it ( "should have the correct NOK " , ( ) => {
41
+ expect ( Number ( ninetyDkkInNok . toFixed ( 1 ) ) ) . toBe ( 151.3 ) ;
54
42
} ) ;
55
43
} ) ;
0 commit comments