feature(package) add for-each-key from npm

This commit is contained in:
coderaiser 2018-04-04 18:03:12 +03:00
parent f694857e63
commit 11c249c8f0
5 changed files with 4 additions and 64 deletions

View file

@ -1,49 +0,0 @@
'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();
});