-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Allow number for path * Fix typos * Add more tests
- Loading branch information
Showing
3 changed files
with
66 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
var dotProp = require('..'); | ||
|
||
describe('dot-prop-immutable.number.spec.js', function () { | ||
|
||
var arr = [1, {a: false}]; | ||
|
||
var result; | ||
describe('when have an array', () => { | ||
|
||
describe('when set prop using number as path', () => { | ||
|
||
before(function () { | ||
result = dotProp.set(arr, 1, 3); | ||
}); | ||
|
||
it('should replace prop', () => { | ||
expect(result).to.eql([ | ||
1, | ||
3 | ||
]); | ||
}); | ||
|
||
it('invariant', arrInvariant); | ||
}); | ||
|
||
|
||
describe('when get prop using number as path', () => { | ||
|
||
before(function () { | ||
result = dotProp.get(arr, 1); | ||
}); | ||
|
||
it('should get prop', () => { | ||
expect(result).to.eql({a: false}); | ||
}); | ||
|
||
it('invariant', arrInvariant); | ||
}); | ||
|
||
describe('when delete prop using number as path', () => { | ||
|
||
before(function () { | ||
result = dotProp.delete(arr, 1); | ||
}); | ||
|
||
it('should remove prop', () => { | ||
expect(result).to.eql([ | ||
1 | ||
]); | ||
}); | ||
it('invariant', arrInvariant); | ||
}); | ||
}); | ||
|
||
function arrInvariant() { | ||
expect(arr).to.eql( | ||
[1, {a: false}] | ||
); | ||
} | ||
}); | ||
|
||
|