Skip to content

Commit 43d1d66

Browse files
gnekichpetebacondarwin
authored andcommitted
test: 🧪 add test for --json flag and changeset
1 parent 7ae4cb5 commit 43d1d66

File tree

2 files changed

+50
-0
lines changed

2 files changed

+50
-0
lines changed

.changeset/young-mammals-spend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
Introduce json output flag for wrangler pages deployment list

packages/wrangler/src/__tests__/pages/deployment-list.test.ts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,51 @@ describe("pages deployment list", () => {
5555
`);
5656
});
5757

58+
it("should make request to list deployments and return result as json", async () => {
59+
const deployments: Deployment[] = [
60+
{
61+
id: "87bbc8fe-16be-45cd-81e0-63d722e82cdf",
62+
url: "https://87bbc8fe.images.pages.dev",
63+
environment: "preview",
64+
created_on: "2021-11-17T14:52:26.133835Z",
65+
latest_stage: {
66+
ended_on: "2021-11-17T14:52:26.133835Z",
67+
status: "success",
68+
},
69+
deployment_trigger: {
70+
metadata: {
71+
branch: "main",
72+
commit_hash: "c7649364c4cb32ad4f65b530b9424e8be5bec9d6",
73+
},
74+
},
75+
project_name: "images",
76+
},
77+
];
78+
79+
const requests = mockDeploymentListRequest(deployments);
80+
await runWrangler("pages deployment list --project-name=images --json");
81+
82+
expect(requests.count).toBe(1);
83+
const output = JSON.parse(std.out);
84+
85+
expect(output[0].Status).toBeTypeOf("string");
86+
output[0].Status = "SNAPSHOT_VALUE"; // This value would drift from snapshot if not hardcoded as is
87+
88+
expect(JSON.stringify(output, null, 2)).toMatchInlineSnapshot(`
89+
"[
90+
{
91+
\\"Id\\": \\"87bbc8fe-16be-45cd-81e0-63d722e82cdf\\",
92+
\\"Environment\\": \\"Preview\\",
93+
\\"Branch\\": \\"main\\",
94+
\\"Source\\": \\"c764936\\",
95+
\\"Deployment\\": \\"https://87bbc8fe.images.pages.dev\\",
96+
\\"Status\\": \\"SNAPSHOT_VALUE\\",
97+
\\"Build\\": \\"https://dash.cloudflare.com/some-account-id/pages/view/images/87bbc8fe-16be-45cd-81e0-63d722e82cdf\\"
98+
}
99+
]"
100+
`);
101+
});
102+
58103
it("should pass no environment", async () => {
59104
const deployments: Deployment[] = [
60105
{

0 commit comments

Comments
 (0)