@@ -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