@@ -118,4 +118,63 @@ describe('manifest', () => {
118118 expect . stringMatching ( 'The snap manifest file has been updated.' ) ,
119119 ) ;
120120 } ) ;
121+
122+ it ( 'formats a snap manifest with Prettier' , async ( ) => {
123+ const error = jest . spyOn ( console , 'error' ) . mockImplementation ( ) ;
124+ const log = jest . spyOn ( console , 'log' ) . mockImplementation ( ) ;
125+
126+ await fs . writeFile (
127+ '/snap/snap.manifest.json' ,
128+ JSON . stringify (
129+ getSnapManifest ( {
130+ shasum : 'G/W5b2JZVv+epgNX9pkN63X6Lye9EJVJ4NLSgAw/afd=' ,
131+ initialPermissions : {
132+ 'endowment:name-lookup' : {
133+ chains : [ 'eip155:1' , 'eip155:2' , 'eip155:3' ] ,
134+ } ,
135+ } ,
136+ } ) ,
137+ ) ,
138+ ) ;
139+
140+ const spinner = ora ( ) ;
141+ const result = await manifest ( '/snap/snap.manifest.json' , true , spinner ) ;
142+ expect ( result ) . toBe ( true ) ;
143+
144+ expect ( error ) . not . toHaveBeenCalled ( ) ;
145+ expect ( log ) . toHaveBeenCalledWith (
146+ expect . stringMatching ( 'The snap manifest file has been updated.' ) ,
147+ ) ;
148+
149+ expect ( await fs . readFile ( '/snap/snap.manifest.json' , 'utf8' ) )
150+ . toMatchInlineSnapshot ( `
151+ "{
152+ "version": "1.0.0",
153+ "description": "The test example snap!",
154+ "proposedName": "@metamask/example-snap",
155+ "repository": {
156+ "type": "git",
157+ "url": "https://github.com/MetaMask/example-snap.git"
158+ },
159+ "source": {
160+ "shasum": "d4W7f1lzpVGMj8jjCn1lYhhHmKc/9TSk5QLH5ldKQoI=",
161+ "location": {
162+ "npm": {
163+ "filePath": "dist/bundle.js",
164+ "packageName": "@metamask/example-snap",
165+ "registry": "https://registry.npmjs.org",
166+ "iconPath": "images/icon.svg"
167+ }
168+ }
169+ },
170+ "initialPermissions": {
171+ "endowment:name-lookup": {
172+ "chains": ["eip155:1", "eip155:2", "eip155:3"]
173+ }
174+ },
175+ "manifestVersion": "0.1"
176+ }
177+ "
178+ ` ) ;
179+ } ) ;
121180} ) ;
0 commit comments