@@ -11,7 +11,7 @@ describe("pages deployment list", () => {
1111 runInTempDir ( ) ;
1212 mockAccountId ( ) ;
1313 mockApiToken ( ) ;
14- mockConsoleMethods ( ) ;
14+ const std = mockConsoleMethods ( ) ;
1515
1616 afterEach ( async ( ) => {
1717 // Force a tick to ensure that all promises resolve
@@ -48,6 +48,51 @@ describe("pages deployment list", () => {
4848 expect ( requests . count ) . toBe ( 1 ) ;
4949 } ) ;
5050
51+ it ( "should make request to list deployments and return result as json" , async ( ) => {
52+ const deployments : Deployment [ ] = [
53+ {
54+ id : "87bbc8fe-16be-45cd-81e0-63d722e82cdf" ,
55+ url : "https://87bbc8fe.images.pages.dev" ,
56+ environment : "preview" ,
57+ created_on : "2021-11-17T14:52:26.133835Z" ,
58+ latest_stage : {
59+ ended_on : "2021-11-17T14:52:26.133835Z" ,
60+ status : "success" ,
61+ } ,
62+ deployment_trigger : {
63+ metadata : {
64+ branch : "main" ,
65+ commit_hash : "c7649364c4cb32ad4f65b530b9424e8be5bec9d6" ,
66+ } ,
67+ } ,
68+ project_name : "images" ,
69+ } ,
70+ ] ;
71+
72+ const requests = mockDeploymentListRequest ( deployments ) ;
73+ await runWrangler ( "pages deployment list --project-name=images --json" ) ;
74+
75+ expect ( requests . count ) . toBe ( 1 ) ;
76+ const output = JSON . parse ( std . out ) ;
77+
78+ expect ( output [ 0 ] . Status ) . toBeTypeOf ( "string" ) ;
79+ output [ 0 ] . Status = "SNAPSHOT_VALUE" ; // This value would drift from snapshot if not hardcoded as is
80+
81+ expect ( JSON . stringify ( output , null , 2 ) ) . toMatchInlineSnapshot ( `
82+ "[
83+ {
84+ \\"Id\\": \\"87bbc8fe-16be-45cd-81e0-63d722e82cdf\\",
85+ \\"Environment\\": \\"Preview\\",
86+ \\"Branch\\": \\"main\\",
87+ \\"Source\\": \\"c764936\\",
88+ \\"Deployment\\": \\"https://87bbc8fe.images.pages.dev\\",
89+ \\"Status\\": \\"SNAPSHOT_VALUE\\",
90+ \\"Build\\": \\"https://dash.cloudflare.com/some-account-id/pages/view/images/87bbc8fe-16be-45cd-81e0-63d722e82cdf\\"
91+ }
92+ ]"
93+ ` ) ;
94+ } ) ;
95+
5196 it ( "should pass no environment" , async ( ) => {
5297 const deployments : Deployment [ ] = [
5398 {
0 commit comments