@@ -8,10 +8,11 @@ import { runWrangler } from "./../helpers/run-wrangler";
88import type { Deployment } from "./../../pages/types" ;
99
1010describe ( "pages deployment list" , ( ) => {
11+ vi . unmock ( "../../wrangler-banner" ) ;
1112 runInTempDir ( ) ;
1213 mockAccountId ( ) ;
1314 mockApiToken ( ) ;
14- mockConsoleMethods ( ) ;
15+ const std = mockConsoleMethods ( ) ;
1516
1617 afterEach ( async ( ) => {
1718 // Force a tick to ensure that all promises resolve
@@ -46,6 +47,61 @@ describe("pages deployment list", () => {
4647 await runWrangler ( "pages deployment list --project-name=images" ) ;
4748
4849 expect ( requests . count ) . toBe ( 1 ) ;
50+ expect ( std . out ) . toMatchInlineSnapshot ( `
51+ "
52+ ⛅️ wrangler x.x.x
53+ ──────────────────
54+ ┌─┬─┬─┬─┬─┬─┬─┐
55+ │ Id │ Environment │ Branch │ Source │ Deployment │ Status │ Build │
56+ ├─┼─┼─┼─┼─┼─┼─┤
57+ │ 87bbc8fe-16be-45cd-81e0-63d722e82cdf │ Preview │ main │ c764936 │ https://87bbc8fe.images.pages.dev │ 3 years ago │ https://dash.cloudflare.com/some-account-id/pages/view/images/87bbc8fe-16be-45cd-81e0-63d722e82cdf │
58+ └─┴─┴─┴─┴─┴─┴─┘"
59+ ` ) ;
60+ } ) ;
61+
62+ it ( "should make request to list deployments and return result as json" , async ( ) => {
63+ const deployments : Deployment [ ] = [
64+ {
65+ id : "87bbc8fe-16be-45cd-81e0-63d722e82cdf" ,
66+ url : "https://87bbc8fe.images.pages.dev" ,
67+ environment : "preview" ,
68+ created_on : "2021-11-17T14:52:26.133835Z" ,
69+ latest_stage : {
70+ ended_on : "2021-11-17T14:52:26.133835Z" ,
71+ status : "success" ,
72+ } ,
73+ deployment_trigger : {
74+ metadata : {
75+ branch : "main" ,
76+ commit_hash : "c7649364c4cb32ad4f65b530b9424e8be5bec9d6" ,
77+ } ,
78+ } ,
79+ project_name : "images" ,
80+ } ,
81+ ] ;
82+
83+ const requests = mockDeploymentListRequest ( deployments ) ;
84+ await runWrangler ( "pages deployment list --project-name=images --json" ) ;
85+
86+ expect ( requests . count ) . toBe ( 1 ) ;
87+ const output = JSON . parse ( std . out ) ;
88+
89+ expect ( output [ 0 ] . Status ) . toBeTypeOf ( "string" ) ;
90+ output [ 0 ] . Status = "SNAPSHOT_VALUE" ; // This value would drift from snapshot if not hardcoded as is
91+
92+ expect ( JSON . stringify ( output , null , 2 ) ) . toMatchInlineSnapshot ( `
93+ "[
94+ {
95+ \\"Id\\": \\"87bbc8fe-16be-45cd-81e0-63d722e82cdf\\",
96+ \\"Environment\\": \\"Preview\\",
97+ \\"Branch\\": \\"main\\",
98+ \\"Source\\": \\"c764936\\",
99+ \\"Deployment\\": \\"https://87bbc8fe.images.pages.dev\\",
100+ \\"Status\\": \\"SNAPSHOT_VALUE\\",
101+ \\"Build\\": \\"https://dash.cloudflare.com/some-account-id/pages/view/images/87bbc8fe-16be-45cd-81e0-63d722e82cdf\\"
102+ }
103+ ]"
104+ ` ) ;
49105 } ) ;
50106
51107 it ( "should pass no environment" , async ( ) => {
0 commit comments