-
Notifications
You must be signed in to change notification settings - Fork 142
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test the thing that creates the root fakes
These are just the node-level replacement, their properties (or for arrays, elements) will be replaced by overwriteChildren Simplied somewhat, when I learned through the test that underscore's clone works well enough for primitives (one would trust, efficiently enough)
- Loading branch information
Showing
3 changed files
with
50 additions
and
14 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
let tdFunction, subject | ||
module.exports = { | ||
beforeEach: () => { | ||
tdFunction = td.replace('../../../src/function').default | ||
subject = require('../../../src/imitate/create-imitation').default | ||
}, | ||
'an array type': () => { | ||
assert.deepEqual(subject([], []), []) | ||
}, | ||
'an arguments type': () => { | ||
let args = (function () { return arguments })() | ||
assert.deepEqual(subject(args, []), []) | ||
}, | ||
'a function without names': () => { | ||
td.when(tdFunction('(anonymous function)')).thenReturn('fake thing') | ||
|
||
const result = subject(() => {}, []) | ||
|
||
assert.deepEqual(result, 'fake thing') | ||
}, | ||
'a function with names': () => { | ||
td.when(tdFunction('AOK')).thenReturn('fake thing') | ||
|
||
const result = subject(() => {}, ['A', 'OK']) | ||
|
||
assert.deepEqual(result, 'fake thing') | ||
}, | ||
'other instances': () => { | ||
const original = {a: 'b'} | ||
|
||
const result = subject(original) | ||
|
||
assert.deepEqual(result, original) | ||
assert.notStrictEqual(result, original) | ||
}, | ||
'primitives': () => { | ||
assert.strictEqual(subject(true), true) | ||
assert.strictEqual(subject(5), 5) | ||
assert.strictEqual(subject('hi'), 'hi') | ||
assert.strictEqual(subject(null), null) | ||
assert.strictEqual(subject(undefined), undefined) | ||
}, | ||
'symbols': () => { | ||
if (!global.Symbol) return | ||
assert.strictEqual(subject(Symbol.species), Symbol.species) | ||
} | ||
} |
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