2017-04-19 00:55:46 +00:00
|
|
|
import { expect } from 'chai'
|
|
|
|
import splitPath from '../../lib/util/splitPath'
|
2016-10-07 03:14:03 +00:00
|
|
|
|
|
|
|
describe('splitPath', () => {
|
|
|
|
it('treats a number as a single step path', () => {
|
2017-04-19 00:55:46 +00:00
|
|
|
const path = 1
|
|
|
|
const result = splitPath(path)
|
|
|
|
expect(result).to.deep.equal(['1'])
|
|
|
|
})
|
2016-10-07 03:14:03 +00:00
|
|
|
|
|
|
|
it('handles arrays', () => {
|
2017-04-19 00:55:46 +00:00
|
|
|
const path = ['foo', 'bar', 'x']
|
|
|
|
const result = splitPath(path)
|
|
|
|
expect(result).to.equal(path)
|
|
|
|
})
|
2016-10-07 03:14:03 +00:00
|
|
|
|
|
|
|
it('handles strings separated by dots', () => {
|
2017-04-19 00:55:46 +00:00
|
|
|
const path = 'bar.0.y'
|
|
|
|
const result = splitPath(path)
|
|
|
|
expect(result).to.deep.equal(['bar', '0', 'y'])
|
|
|
|
})
|
|
|
|
})
|