Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Commit

Permalink
fix(proxy): make sure proxy corner-cases work ok
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Aug 16, 2018
1 parent fafc5a8 commit 8c66e45
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -169,7 +169,7 @@ const proxyHandler = {
throw new Error('figgyPudding options cannot be modified. Use .concat() instead.')
}
},
delete () {
deleteProperty () {
throw new Error('figgyPudding options cannot be deleted. Use .concat() and shadow them instead.')
}
}
Expand Down
9 changes: 9 additions & 0 deletions test/index.js
Expand Up @@ -9,11 +9,20 @@ test('basic property fetching', t => {
})
const opts = testOpts({a: 1, b: 2})
t.equal(opts.get('a'), 1, 'defined opt fetched')
t.equal(opts.a, 1, 'works through a proxy too')
t.ok('a' in opts, 'supports `in` keyword')
t.notOk('b' in opts, '`in` false for non-declared props')
t.throws(() => {
opts.get('b')
}, /invalid config key requested: b/i)
t.throws(() => {
opts.b // eslint-disable-line
}, /invalid config key requested: b/i)
t.throws(() => {
delete opts.a
}, /cannot be deleted/)
// NOTE: The following doesn't seem to work, and it seems to be a Node/V8 bug
// t.deepEqual(Object.keys(opts), ['a'], 'got keys correctly')
t.done()
})

Expand Down

0 comments on commit 8c66e45

Please sign in to comment.