Last active
August 29, 2015 14:10
-
-
Save vaclavbohac/6bd41750c681f8624568 to your computer and use it in GitHub Desktop.
Cyclic Reference Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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