-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
32 lines (24 loc) · 1018 Bytes
/
test.js
File metadata and controls
32 lines (24 loc) · 1018 Bytes
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
'usa strict'
let chai = require('chai')
let expect = chai.expect
let CopyMachine = require('./index.js')
describe('.copy()', () => {
it('makes a deep copy of any object', (done) => {
let objectToCopy = { someString: "Certainly a string.", horse: true, potion: 1 }
let newObject = CopyMachine.copy(objectToCopy)
expect(newObject).to.deep.equal(objectToCopy)
done()
})
it('explodes when passed something that is not an object', (done) => {
let numbertoCopy = 20
expect(CopyMachine.copy).to.throw(Error, 'Item to copy must be an object.')
done()
})
it('passes back a new object that has no reference to the old object', (done) => {
let objectToCopy = { someString: "Certainly a string.", horse: true, potion: 1 }
let newObject = CopyMachine.copy(objectToCopy)
newObject.horse = false
expect(newObject.horse).to.not.equal(objectToCopy.horse)
done()
})
})