Skip to content

Commit

Permalink
feat(path): Added test for whitespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Mar 13, 2019
1 parent 6dd6658 commit dc96d28
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/unit/path.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,33 @@ describe('path', () => {
})
})

describe('whitespace', () => {
it('should get value if it contains space 0x20', () => {
const val = path.getPathValue({ 'a c': 1 }, 'a c')
assert.strictEqual(val, 1)
})

it('should return null if it contains whitespace chars except space 0x20', () => {
const val = path.getPathValue({ 'a\tc': 1 }, 'a\tc')
assert.strictEqual(val, null)
})
})

describe('object', () => {
it('should get path value', () => {
const val = path.getPathValue({ a: { b: 1 } }, 'a')
assert.strictEqual(val.b, 1)
})

it('should accept space 0x20 as keypath', () => {
const val = path.getPathValue({ a: { 'b c d': 1 } }, 'a.b c d')
assert.strictEqual(val, 1)
})

it('should accept space 0x20 as keypath', () => {
const val = path.getPathValue({ a: { 'b c d': 1 } }, 'a.b c d')
assert.strictEqual(val, 1)
})
})

describe('number key in object', () => {
Expand Down

0 comments on commit dc96d28

Please sign in to comment.