Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

still use global options when someone destructures #90

Merged
merged 1 commit into from
Sep 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions test/write-file-sync.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ describe('+ writeFileSync()', function () {
// restore default
jf.spaces = null
})

it('still uses global when context lost', function () {
var file = path.join(TEST_DIR, 'somefile.json')
var obj = {name: 'JP'}
jf.spaces = 2
var writeFileSync = jf.writeFileSync
writeFileSync(file, obj)

var data = fs.readFileSync(file, 'utf8')
assert.equal(data, '{\n "name": "JP"\n}\n')

// restore default
jf.spaces = null
})
})

describe('> when JSON replacer is set', function () {
Expand Down
17 changes: 17 additions & 0 deletions test/write-file.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,23 @@ describe('+ writeFile()', function () {
done()
})
})

it('still uses global when context lost', function (done) {
var file = path.join(TEST_DIR, 'somefile.json')
var obj = {name: 'JP'}
jf.spaces = 2
var writeFile = jf.writeFile
writeFile(file, obj, function (err) {
assert.ifError(err)

var data = fs.readFileSync(file, 'utf8')
assert.equal(data, '{\n "name": "JP"\n}\n')

// restore default
jf.spaces = null
done()
})
})
})

describe('> when JSON replacer is set', function () {
Expand Down