Skip to content

Commit

Permalink
test: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanfiss committed Nov 5, 2022
1 parent 380c009 commit bc23e51
Show file tree
Hide file tree
Showing 4 changed files with 139 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/test/dw/BankingBusinessTest.dwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
%dw 2.0
import * from dw::test::Tests
import * from dw::test::Asserts

import * from BankingBusiness
---
"BankingBusiness" describedBy [
"isBankingHoliday" describedBy [
"Must validate if it is not a holiday" in do {
isBankingHoliday("2022-11-04" as Date) must equalTo(false)
},
"Must validate if it is a holiday" in do {
isBankingHoliday("2022-11-15" as Date) must equalTo(true)
},
"Must validate if it is a carnival holiday" in do {
isBankingHoliday("2023-02-21" as Date) must equalTo(true)
},
"Must validate if it is a Carnival Monday holiday" in do {
isBankingHoliday("2023-02-20" as Date) must equalTo(true)
},
],
"isBankingBusinessDay" describedBy [
"Must validate if a working day" in do {
isBankingBusinessDay("2022-11-04" as Date) must equalTo(true)
},
"Must validate if a working day, when it is Saturday" in do {
isBankingBusinessDay("2022-11-05" as Date) must equalTo(false)
},
"Must validate if a working day, when it is Sunday" in do {
isBankingBusinessDay("2022-11-06" as Date) must equalTo(false)
},
"Must validate if it's a business day, when it's a Carnival" in do {
isBankingBusinessDay("2023-02-21" as Date) must equalTo(false)
},
],
"countBankingBusinessDays" describedBy [
"Must count the number of working days between the dates" in do {
countBankingBusinessDays("2022-02-01" as Date, "2022-03-01" as Date) must equalTo(19)
},
],
"nextBankingBusinessDay" describedBy [
"Must return next business day" in do {
nextBankingBusinessDay("2023-02-17" as Date) must equalTo("2023-02-22" as Date)
},
],
]
56 changes: 56 additions & 0 deletions src/test/dw/CommonsTest.dwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
%dw 2.0
import * from dw::test::Tests
import * from dw::test::Asserts

import * from Commons
---
"Commons" describedBy [
"monthDay" describedBy [
"Must convert to MM-dd" in do {
monthDay("2022-11-05" as Date) must equalTo("11-05")
},
],
"isNationalHoliday" describedBy [
"Must validate if it is not a holiday" in do {
isNationalHoliday("2022-11-05" as Date) must equalTo(false)
},
"Must validate if it is a holiday" in do {
isNationalHoliday("2022-11-15" as Date) must equalTo(true)
},
"Must validate if it is a Friday holiday" in do {
isNationalHoliday("2023-04-07" as Date) must equalTo(true)
},
],
"isBusinessDay" describedBy [
"Must validate if a working day, when it is Saturday" in do {
isBusinessDay("2022-11-05" as Date) must equalTo(false)
},
"Must validate if it is a business day, considering Saturday" in do {
isBusinessDay("2022-11-05" as Date, true) must equalTo(true)
},
"Must validate if a working day, when it is Sunday" in do {
isBusinessDay("2022-11-06" as Date) must equalTo(false)
},
"Must validate if it's a business day, when it's a holiday" in do {
isBusinessDay("2022-12-25" as Date) must equalTo(false)
},
],
"allDates" describedBy [
"Must return an array of dates" in do {
allDates("2022-12-01" as Date, "2022-12-25" as Date) must beArray()
},
],
"countBusinessDays" describedBy [
"Must count the number of working days between the dates" in do {
countBusinessDays("2022-12-01" as Date, "2022-12-25" as Date) must equalTo(17)
},
],
"nextBusinessDay" describedBy [
"Must return next business day" in do {
nextBusinessDay("2022-11-04" as Date) must equalTo("2022-11-07" as Date)
},
"Must return the next business day, considering Saturday business day" in do {
nextBusinessDay("2022-11-04" as Date, true) must equalTo("2022-11-05" as Date)
},
],
]
28 changes: 28 additions & 0 deletions src/test/dw/MobileHolidaysEventsTest.dwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
%dw 2.0
import * from dw::test::Tests
import * from dw::test::Asserts

import * from MobileHolidaysEvents
---
"MobileHolidaysEvents" describedBy [
"yearToEasterDate" describedBy [
"Must calculate what day Easter will be" in do {
yearToEasterDate("2023-01-01" as Date) must equalTo("2023-04-09" as Date)
},
],
"yearToCarnivalDate" describedBy [
"Must calculate on what day will Carnival be" in do {
yearToCarnivalDate("2023-01-01" as Date) must equalTo("2023-02-21" as Date)
},
],
"yearToGoodFridayDate" describedBy [
"Must calculate what day will be Good Friday" in do {
yearToGoodFridayDate("2023-01-01" as Date) must equalTo("2023-04-07" as Date)
},
],
"yearToCorpusChristiDate" describedBy [
"Must calculate what day it will be Corpus Christi" in do {
yearToCorpusChristiDate("2023-01-01" as Date) must equalTo("2023-06-08" as Date)
},
],
]
9 changes: 9 additions & 0 deletions src/test/dw/RunFunctions.dwl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/**
* This mapping won't be shared through your library, but you can use it to try out your module and create integration tests.
*/
%dw 2.0
output application/json
var dayOfWeek = ("2022-11-05" as Date) as String {format: "e"}
import * from BankingBusiness
---
nextBankingBusinessDay("2023-02-17" as Date)

0 comments on commit bc23e51

Please sign in to comment.