1
|
'use strict';
|
2
|
|
3
|
var keys = require('object-keys');
|
4
|
var forEach = require('foreach');
|
5
|
var indexOf = require('array.prototype.indexof');
|
6
|
|
7
|
module.exports = function diffOperations(actual, expected, expectedMissing) {
|
8
|
var actualKeys = keys(actual);
|
9
|
var expectedKeys = keys(expected);
|
10
|
|
11
|
var extra = [];
|
12
|
var missing = [];
|
13
|
forEach(actualKeys, function (op) {
|
14
|
if (!(op in expected)) {
|
15
|
extra.push(op);
|
16
|
} else if (indexOf(expectedMissing, op) !== -1) {
|
17
|
extra.push(op);
|
18
|
}
|
19
|
});
|
20
|
forEach(expectedKeys, function (op) {
|
21
|
if (typeof actual[op] !== 'function' && indexOf(expectedMissing, op) === -1) {
|
22
|
missing.push(op);
|
23
|
}
|
24
|
});
|
25
|
|
26
|
return { missing: missing, extra: extra };
|
27
|
};
|