mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(for-each-key) add
This commit is contained in:
parent
68e9bd813e
commit
bfcb075480
4 changed files with 72 additions and 15 deletions
49
test/common/for-each-key.spec.js
Normal file
49
test/common/for-each-key.spec.js
Normal 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();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue