Skip to content

Commit

Permalink
test: add custom format with no newlines
Browse files Browse the repository at this point in the history
  • Loading branch information
ruyadorno committed Jun 25, 2021
1 parent 6e7c0ea commit ae4a765
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tap-snapshots/test/index.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
* Make sure to inspect the output below. Do not ignore changes!
*/
'use strict'
exports[`test/index.js TAP custom formatting > should save back custom format to package.json 1`] = `
{"name":"foo","version":"1.0.1","description":"Lorem ipsum dolor"}
`

exports[`test/index.js TAP invalid package.json data > should save updated content to package.json and ignore invalid data 1`] = `
this! is! not! json!
`
Expand Down
21 changes: 21 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,24 @@ t.test('update package.json with invalid content', async t => {
'should throw if trying to update an invalid manifest'
)
})

t.test('custom formatting', async t => {
const path = t.testdir({
'package.json': JSON.stringify({
name: 'foo',
version: '1.0.0',
}, null, 0),
})

const pkgJson = await PackageJson.load(path)
pkgJson.update({
version: '1.0.1',
description: 'Lorem ipsum dolor',
})
await pkgJson.save()

t.matchSnapshot(
fs.readFileSync(resolve(path, 'package.json'), 'utf8'),
'should save back custom format to package.json'
)
})

0 comments on commit ae4a765

Please sign in to comment.