-
-
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.
feat(settlement): create types representing the result of a promise
- Loading branch information
1 parent
823a8d7
commit 269075e
Showing
2 changed files
with
65 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** @format */ | ||
|
||
import { Fulfillment, Rejection } from "./types"; | ||
import _ from "lodash"; | ||
|
||
describe("Fulfillment", () => { | ||
_.forEach([true, { foo: true }], (arg) => { | ||
describe(`when passed the ${typeof arg} argument '${JSON.stringify( | ||
arg | ||
)}'`, () => { | ||
const fulfillment = new Fulfillment(arg); | ||
|
||
it("exposes the argument on the 'value' property", () => { | ||
expect(fulfillment).toHaveProperty("value", arg); | ||
}); | ||
|
||
it("has a 'status' property of 'fulfilled'", () => { | ||
expect(fulfillment).toHaveProperty("status", "fulfilled"); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("Rejection", () => { | ||
_.forEach(["BOOM!", new Error("BOOM!")], (arg) => { | ||
describe(`when passed the ${typeof arg} argument: '${arg}'`, () => { | ||
const rejection = new Rejection(arg); | ||
|
||
it("returns the argument in the 'reason' property", () => { | ||
expect(rejection).toHaveProperty("reason", arg); | ||
}); | ||
|
||
it("has a 'status' property whose value is 'rejected'", () => { | ||
expect(rejection).toHaveProperty("status", "rejected"); | ||
}); | ||
}); | ||
}); | ||
}); |
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