-
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.
add confirmed_at to memberships (#147)
- Loading branch information
Showing
6 changed files
with
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,50 @@ | ||
import { createAppTester } from "zapier-platform-core"; | ||
import * as nock from "nock"; | ||
import App from "../../index"; | ||
import { prepareMocksForWebhookSubscribeTest } from "../utils/prepareMocksForWebhookSubscribeTest"; | ||
import { | ||
prepareBundle, | ||
prepareMocksForWebhookSubscribeTest, | ||
} from "../utils/prepareMocksForWebhookSubscribeTest"; | ||
import triggerMembershipConfirmed from "../../triggers/triggerMembershipConfirmed"; | ||
import { HookTrigger } from "../../types/trigger"; | ||
import { MembershipApiResponse } from "../../types/api-responses"; | ||
import { MembershipOutput } from "../../types/outputs"; | ||
import trigger from "../../triggers/triggerMembershipConfirmed"; | ||
|
||
const appTester = createAppTester(App); | ||
nock.disableNetConnect(); | ||
|
||
const membershipResponse: MembershipApiResponse = { | ||
id: "003b37a3-f205-5d9e-9caf-c4ca612075d4", | ||
name: "Sam Duncan", | ||
email: "[email protected]", | ||
phone: null, | ||
address: { | ||
company: "Acme inc", | ||
name: "Sam Duncan", | ||
full_address: "982 Ruguw Terrace", | ||
}, | ||
payment_method: { | ||
name: "Credit Card", | ||
}, | ||
plan: { | ||
name: "Full Time", | ||
}, | ||
customer_number: "123", | ||
confirmed_at: "2012/04/12 12:00:00 +0000", | ||
}; | ||
|
||
const membershipOutput: MembershipOutput = { | ||
id: "003b37a3-f205-5d9e-9caf-c4ca612075d4", | ||
name: "Sam Duncan", | ||
company: "Acme inc", | ||
email: "[email protected]", | ||
customer_number: "123", | ||
plan_name: "Full Time", | ||
payment_method_name: "Credit Card", | ||
confirmed_at: "2012-04-12", | ||
}; | ||
|
||
afterEach(() => nock.cleanAll()); | ||
|
||
describe("triggerMembershipConfirmed", () => { | ||
|
@@ -27,4 +64,32 @@ describe("triggerMembershipConfirmed", () => { | |
} | ||
`); | ||
}); | ||
|
||
it("lists recent memberships", async () => { | ||
const bundle = prepareBundle(); | ||
const api1Scope = nock("https://trial.cobot.me"); | ||
api1Scope.get("/api/memberships").reply(200, [membershipResponse]); | ||
|
||
const listMemberships = trigger.operation.performList; | ||
|
||
const results = await appTester(listMemberships as any, bundle as any); | ||
expect(nock.isDone()).toBe(true); | ||
expect(results).toStrictEqual([membershipOutput]); | ||
}); | ||
|
||
it("triggers on membership confirmed", async () => { | ||
const bundle = prepareBundle({ | ||
url: "https://trial.cobot.me/api/memberships/m1", | ||
}); | ||
const api1Scope = nock("https://trial.cobot.me"); | ||
api1Scope.get("/api/memberships/m1").reply(200, membershipResponse); | ||
const results = await appTester( | ||
triggerMembershipConfirmed.operation.perform as any, | ||
bundle as any, | ||
); | ||
|
||
expect(nock.isDone()).toBe(true); | ||
|
||
expect(results).toStrictEqual([membershipOutput]); | ||
}); | ||
}); |
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