Skip to content

Instantly share code, notes, and snippets.

@vaclavbohac
Last active August 29, 2015 14:10
Show Gist options
  • Save vaclavbohac/6bd41750c681f8624568 to your computer and use it in GitHub Desktop.
Save vaclavbohac/6bd41750c681f8624568 to your computer and use it in GitHub Desktop.
Cyclic Reference Example
{
"name": "cyclic-reference-example",
"version": "1.0.0",
"description": "Example of the cyclic reference example",
"main": "index.js",
"scripts": {
"test": "mocha test"
},
"author": "[email protected]",
"license": "MIT",
"dependencies": {
"chai": "^1.10.0",
"mocha": "^2.0.1"
}
}
var assert = require("chai").assert,
createCyclicReference = function (name, place) {
var customer = { name: name };
var address = { name: place };
customer.address = address;
address.customer = customer;
return customer;
};
describe('assert', function () {
describe('#deepEqual()', function () {
it('should handle cyclic references', function () {
var actual = createCyclicReference('Harry Potter', 'Diagon Alley'),
expected = createCyclicReference('Harry Potter', 'Diagon Alley');
assert.deepEqual(actual, expected, 'Given objects are not deep equal.');
});
});
describe('#notDeepEqual()', function() {
it('should handle cyclic references', function () {
var actual = createCyclicReference('Harry Potter', 'Diagon Alley'),
expected = createCyclicReference('Hermione Granger', 'Diagon Alley');
assert.notDeepEqual(actual, expected, 'Given objects are not deep equal.');
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment