feature(for-each-key) add

This commit is contained in:
coderaiser 2018-03-27 12:27:33 +03:00
parent 68e9bd813e
commit bfcb075480
4 changed files with 72 additions and 15 deletions

View file

@ -0,0 +1,49 @@
'use strict';
const test = require('tape');
const diff = require('sinon-called-with-diff');
const sinon = diff(require('sinon'));
const forEachKey = require('../../common/for-each-key');
test('forEachKey: on property', (t) => {
const obj = {
a: 'hello',
};
const fn = sinon.stub();
forEachKey(fn, obj);
t.ok(fn.calledWith('a', 'hello'), 'should call fn');
t.end();
});
test('forEachKey: a couple properties', (t) => {
const obj = {
a: 'hello',
b: 'world',
};
const fn = sinon.stub();
forEachKey(fn, obj);
t.ok(fn.calledWith('b', 'world'), 'should call fn');
t.end();
});
test('forEachKey: count', (t) => {
const obj = {
a: 'hello',
b: 'world',
c: 'some',
};
const fn = sinon.stub();
forEachKey(fn, obj);
t.equal(fn.callCount, 3, 'should ');
t.end();
});