File: test.js

package info (click to toggle)
node-is-equal-shallow 0.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 108 kB
  • ctags: 6
  • sloc: makefile: 4; sh: 2
file content (38 lines) | stat: -rw-r--r-- 1,269 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*!
 * is-equal-shallow <https://github.com/jonschlinkert/is-equal-shallow>
 *
 * Copyright (c) 2015, Jon Schlinkert.
 * Licensed under the MIT License.
 */

'use strict';

/* deps: mocha */
var assert = require('assert');
var should = require('should');
var equals = require('./');

describe('equals', function () {
  it('should return true when keys and values are the same:', function () {
    equals({a: true, b: true}, {a: true, b: true}).should.be.true;
  });

  it('should return false when keys are different:', function () {
    equals({a: true, b: false}, {c: false, b: false}).should.be.false;
  });

  it('should return false when values are different:', function () {
    equals({a: true, b: false}, {a: false, b: false}).should.be.false;
    equals({a: true, b: true}, {a: true, b: 'true'}).should.be.false;
  });

  it('should return false when a value is not a primitive:', function () {
    equals({ b: {}}, { b: {}}).should.be.false;
    equals({ b: []}, { b: []}).should.be.false;
  });

  it('should return false when a value is present in one object but not the other', function () {
    equals({a: true, b: true, c: true}, {a: true, b: true}).should.be.false;
    equals({a: true, b: true}, {a: true, b: true, c: true}).should.be.false;
  });
});