-
Notifications
You must be signed in to change notification settings - Fork 2
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
7 changed files
with
66 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,11 @@ const invoiceResponse: InvoiceApiResponse = { | |
}, | ||
}; | ||
|
||
const membership = { | ||
id: "membership-1", | ||
email: "[email protected]", | ||
}; | ||
|
||
const appTester = createAppTester(App); | ||
nock.disableNetConnect(); | ||
const trigger = App.triggers[triggerInvoiceCreated.key] as HookTrigger; | ||
|
@@ -106,30 +111,36 @@ describe("triggerInvoiceCreated", () => { | |
const userResponse: UserApiResponse = { | ||
included: [{ id: "space-1", attributes: { subdomain: "trial" } }], | ||
}; | ||
const scope = nock("https://api.cobot.me"); | ||
scope.get("/user?include=adminOf").reply(200, userResponse); | ||
scope | ||
const api2Scope = nock("https://api.cobot.me"); | ||
const api1Scope = nock("https://trial.cobot.me"); | ||
api2Scope.get("/user?include=adminOf").reply(200, userResponse); | ||
api1Scope.get("/api/memberships/membership-1").reply(200, membership); | ||
api2Scope | ||
.get(/\/spaces\/space-1\/invoices/) | ||
.reply(200, { data: [invoiceResponse] }); | ||
|
||
const listRecentEvents = trigger.operation.performList; | ||
|
||
const results = await appTester(listRecentEvents as any, bundle as any); | ||
|
||
expect(nock.isDone()).toBe(true); | ||
expect(results).toStrictEqual([ | ||
{ | ||
...attributes, | ||
id: "1", | ||
membershipId: "membership-1", | ||
membership: { | ||
id: "membership-1", | ||
email: "[email protected]", | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
||
it("triggers on new invoice", async () => { | ||
const bundle = prepareBundle(); | ||
const scope = nock("https://api.cobot.me"); | ||
scope.get("/invoices/12345").reply(200, { data: invoiceResponse }); | ||
|
||
const api1Scope = nock("https://trial.cobot.me"); | ||
const api2Scope = nock("https://api.cobot.me"); | ||
api2Scope.get("/invoices/12345").reply(200, { data: invoiceResponse }); | ||
api1Scope.get("/api/memberships/membership-1").reply(200, membership); | ||
const results = await appTester( | ||
triggerInvoiceCreated.operation.perform as any, | ||
bundle as any, | ||
|
@@ -141,7 +152,10 @@ describe("triggerInvoiceCreated", () => { | |
{ | ||
...attributes, | ||
id: "1", | ||
membershipId: "membership-1", | ||
membership: { | ||
id: "membership-1", | ||
email: "[email protected]", | ||
}, | ||
}, | ||
]); | ||
}); | ||
|
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
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 |
---|---|---|
|
@@ -74,7 +74,10 @@ export const invoiceSample: InvoiceOutput = { | |
taxId: "DE12345", | ||
taxIdName: "UID", | ||
customerNumber: "100", | ||
membershipId: "c9a99a71ac8df98d29de357180d273d3", | ||
membership: { | ||
id: "14c12f62ac8df98d29de357180d673e1", | ||
email: "[email protected]", | ||
}, | ||
recipientAddress: { | ||
name: "Jane Smith", | ||
company: "Acme Inc.", | ||
|