-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
42 changed files
with
2,233 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import theoretically from "jest-theories"; | ||
|
||
import asDecision from "./convert-decision"; | ||
import { CreditAssessmentDecision } from "./types"; | ||
|
||
describe("Convert decision text to decision", () => { | ||
const theories = [ | ||
{ | ||
text: "approved", | ||
expectedDecision: CreditAssessmentDecision.Approved, | ||
}, | ||
{ | ||
text: "rejected", | ||
expectedDecision: CreditAssessmentDecision.Rejected, | ||
}, | ||
{ text: "asdf", expectedDecision: CreditAssessmentDecision.Unknown }, | ||
{ text: undefined, expectedDecision: CreditAssessmentDecision.Unknown }, | ||
]; | ||
|
||
theoretically( | ||
"Given '{text}', should be '{expectedDecision}'", | ||
theories, | ||
(theory) => { | ||
const decision = asDecision(theory.text); | ||
expect(decision).toBe(theory.expectedDecision); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { CreditAssessmentDecision } from "./types"; | ||
|
||
const asDecision = (text?: string) => { | ||
switch (text) { | ||
case "approved": | ||
return CreditAssessmentDecision.Approved; | ||
case "rejected": | ||
return CreditAssessmentDecision.Rejected; | ||
default: | ||
return CreditAssessmentDecision.Unknown; | ||
} | ||
}; | ||
|
||
export default asDecision; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import theoretically from "jest-theories"; | ||
|
||
import asRecommendation from "./convert-recommendation"; | ||
import { CreditAssessmentRecommendation } from "./types"; | ||
|
||
describe("Convert recommendation text to recommendation", () => { | ||
const theories = [ | ||
{ | ||
text: "approve", | ||
expectedRecommendation: CreditAssessmentRecommendation.Approve, | ||
}, | ||
{ | ||
text: "assessManually", | ||
expectedRecommendation: | ||
CreditAssessmentRecommendation.AssessManually, | ||
}, | ||
{ | ||
text: "reject", | ||
expectedRecommendation: CreditAssessmentRecommendation.Reject, | ||
}, | ||
{ | ||
text: "asdf", | ||
expectedRecommendation: CreditAssessmentRecommendation.Unknown, | ||
}, | ||
{ | ||
text: undefined, | ||
expectedRecommendation: CreditAssessmentRecommendation.Unknown, | ||
}, | ||
]; | ||
|
||
theoretically( | ||
"Given '{text}', should be '{expectedRecommendation}'", | ||
theories, | ||
(theory) => { | ||
const recommendation = asRecommendation(theory.text); | ||
expect(recommendation).toBe(theory.expectedRecommendation); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { CreditAssessmentRecommendation } from "./types"; | ||
|
||
const asRecommendation = (text?: string) => { | ||
switch (text) { | ||
case "approve": | ||
return CreditAssessmentRecommendation.Approve; | ||
case "assessManually": | ||
return CreditAssessmentRecommendation.AssessManually; | ||
case "reject": | ||
return CreditAssessmentRecommendation.Reject; | ||
default: | ||
return CreditAssessmentRecommendation.Unknown; | ||
} | ||
}; | ||
|
||
export default asRecommendation; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import theoretically from "jest-theories"; | ||
|
||
import asStatus from "./convert-status"; | ||
import { CreditAssessmentStatus } from "./types"; | ||
|
||
describe("Convert status text to status", () => { | ||
const theories = [ | ||
{ text: "received", expectedStatus: CreditAssessmentStatus.Received }, | ||
{ | ||
text: "signingInitiated", | ||
expectedStatus: CreditAssessmentStatus.SigningInitiated, | ||
}, | ||
{ | ||
text: "signingFailed", | ||
expectedStatus: CreditAssessmentStatus.SigningFailed, | ||
}, | ||
{ text: "signed", expectedStatus: CreditAssessmentStatus.Signed }, | ||
{ | ||
text: "scoringInitiated", | ||
expectedStatus: CreditAssessmentStatus.ScoringInitiated, | ||
}, | ||
{ text: "scored", expectedStatus: CreditAssessmentStatus.Scored }, | ||
{ text: "notScored", expectedStatus: CreditAssessmentStatus.NotScored }, | ||
{ text: "accepted", expectedStatus: CreditAssessmentStatus.Accepted }, | ||
{ text: "declined", expectedStatus: CreditAssessmentStatus.Declined }, | ||
{ text: "unknown", expectedStatus: CreditAssessmentStatus.Unknown }, | ||
{ text: "asdf", expectedStatus: CreditAssessmentStatus.Unknown }, | ||
]; | ||
|
||
theoretically( | ||
"Given '{text}', should be '{expectedStatus}'", | ||
theories, | ||
(theory) => { | ||
const status = asStatus(theory.text); | ||
expect(status).toBe(theory.expectedStatus); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { CreditAssessmentStatus } from "./types"; | ||
|
||
const asStatus = (statusString: string) => { | ||
switch (statusString) { | ||
case "received": | ||
return CreditAssessmentStatus.Received; | ||
case "signingInitiated": | ||
return CreditAssessmentStatus.SigningInitiated; | ||
case "signingFailed": | ||
return CreditAssessmentStatus.SigningFailed; | ||
case "signed": | ||
return CreditAssessmentStatus.Signed; | ||
case "scoringInitiated": | ||
return CreditAssessmentStatus.ScoringInitiated; | ||
case "scored": | ||
return CreditAssessmentStatus.Scored; | ||
case "notScored": | ||
return CreditAssessmentStatus.NotScored; | ||
case "accepted": | ||
return CreditAssessmentStatus.Accepted; | ||
case "declined": | ||
return CreditAssessmentStatus.Declined; | ||
default: | ||
return CreditAssessmentStatus.Unknown; | ||
} | ||
}; | ||
|
||
export default asStatus; |
Oops, something went wrong.