Skip to content

Commit

Permalink
Test the primitive-checker
Browse files Browse the repository at this point in the history
  • Loading branch information
searls committed Jun 24, 2017
1 parent 76093c1 commit 2fce02b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
4 changes: 0 additions & 4 deletions test/safe/imitate/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ import _ from 'lodash'
import explain from '../../../src/explain'
import subject from '../../../src/imitate'

// WARNING: this is not a unit test! This is a functional test to prove out an
// algorithm. Ideally I would have broken this up, but I really
// struggled at first and wanted to prove it out wired up to the td@3 impl

module.exports = {
'strict equal stuff (not objects typically)': () => {
[
Expand Down
32 changes: 32 additions & 0 deletions test/unit/imitate/overwrite-children/is-primitive-like.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import subject from '../../../../src/imitate/overwrite-children/is-primitive-like'

module.exports = {
'identifies primitive things': () => {
assert.equal(subject(), true)
assert.equal(subject(false), true)
assert.equal(subject(true), true)
assert.equal(subject(undefined), true)
assert.equal(subject(null), true)
assert.equal(subject(1), true)
assert.equal(subject('hi'), true)
assert.equal(subject(NaN), true)
},
'identifies symbols': () => {
if (!global.Symbol) return

assert.equal(subject(Symbol.species), true)
},
'identifies boxed types and basic value types': () => {
assert.equal(subject(new String('hi')), true) // eslint-disable-line
assert.equal(subject(new Boolean(true)), true) // eslint-disable-line
assert.equal(subject(new Number(0)), true) // eslint-disable-line
assert.equal(subject(/hi/), true)
assert.equal(subject(new Date()), true)
},
'gives functions, arrays, and custom objects a pass': () => {
assert.equal(subject(new Object()), false) // eslint-disable-line
assert.equal(subject(function () {}), false)
assert.equal(subject([]), false)
assert.equal(subject({}), false)
}
}

0 comments on commit 2fce02b

Please sign in to comment.