json-shaper
Advanced tools
Comparing version 0.1.0 to 0.2.0
import { | ||
isObject, | ||
forEach, | ||
} from './json-shaper' | ||
import sinon from 'sinon'; | ||
describe('isObject helper', () => { | ||
@@ -31,1 +35,53 @@ | ||
describe('forEach helper', () => { | ||
it('should iterate over object keys and call a function', () => { | ||
const iteratee = sinon.spy() | ||
const obj1 = { | ||
a: 123, | ||
b: 456, | ||
z: 789 | ||
} | ||
const obj2 = [ | ||
'just', | ||
'some', | ||
'array' | ||
] | ||
forEach(obj1, iteratee) | ||
forEach(obj2, iteratee) | ||
expect(iteratee.withArgs(123, 'a').calledOnce).to.be.true | ||
expect(iteratee.withArgs(456, 'b').calledOnce).to.be.true | ||
expect(iteratee.withArgs(789, 'z').calledOnce).to.be.true | ||
expect(iteratee.withArgs('just', '0').calledOnce).to.be.true | ||
expect(iteratee.withArgs('some', '1').calledOnce).to.be.true | ||
expect(iteratee.withArgs('array', '2').calledOnce).to.be.true | ||
}) | ||
it('should skip on non-objects', () => { | ||
const iteratee = sinon.spy() | ||
const obj1 = 'test' | ||
const obj2 = 123 | ||
const obj3 = null | ||
const obj4 = undefined | ||
forEach(obj1, iteratee) | ||
forEach(obj2, iteratee) | ||
forEach(obj3, iteratee) | ||
forEach(obj4, iteratee) | ||
expect(iteratee.callCount).to.equal(0) | ||
}) | ||
}) | ||
{ | ||
"name": "json-shaper", | ||
"version": "0.1.0", | ||
"version": "0.2.0", | ||
"description": "Shape a flat array into a molded json shape with deep nesting", | ||
@@ -41,4 +41,5 @@ "author": "Chris Kalmar <christian.kalmar@gmail.com>", | ||
"mocha": "^3.3.0", | ||
"nyc": "^10.3.0" | ||
"nyc": "^10.3.0", | ||
"sinon": "^2.1.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120347
175
11