Example #1
0
 it('should match elements', function(){
   assert('element' === type(document.createElement('div')))
 })
Example #2
0
 it('should match textnodes', function(){
   assert('text-node' === type(document.createTextNode('div')))
 })
Example #3
0
 it('should allow shorter patterns', function(){
   assert(!match([1,2], [1,2,3]))
   assert(match([1,2], [1]))
 })
Example #4
0
 it('should match strings', function(){
   assert('string' === type("test"))
   assert('string' === type(new String('whoop')))
 })
Example #5
0
it('boolean', function(){
  assert(!match(true, false))
  assert(match(true, true))
})
Example #6
0
 it('should deeply match', function(){
   assert(!match({a:1,b:2}, {a:2}))
   assert(match({a:1,b:2}, {a:1}))
   assert(match({a:{a:1},b:2}, {a:{a:1}}))
   assert(match({a:'abc'}, {a:/^\w+$/}))
 })
Example #7
0
 it('should match regexps', function(){
   assert('regexp' === type(/asdf/))
   assert('regexp' === type(new RegExp('weee')))
 })
Example #8
0
 if (typeof Blob == 'function') it('should match blobs', function(){
   assert('blob' === type(new Blob))
 })
Example #9
0
 it('should match undefined', function(){
   assert('undefined' === type(undefined))
 })
Example #10
0
 it('should match arrays', function(){
   assert('array' === type([]))
 })
Example #11
0
 it('should match null', function(){
   assert('null' === type(null))
 })
Example #12
0
 it('should match booleans', function(){
   assert('boolean' === type(true))
   assert('boolean' === type(false))
   assert('boolean' === type(new Boolean(false)))
 })
Example #13
0
 it('should match dates', function(){
   assert('date' === type(new Date))
 })
Example #14
0
 if (typeof FormData == 'function') it('should match from data', function(){
   assert('form-data' === type(new FormData))
 })
Example #15
0
 it('should match functions', function(){
   assert('function' === type(function(){}))
 })
Example #16
0
 if (typeof File == 'function') it.skip('should match files', function(){
   assert('file' === type(new File)) // TODO: fix test
 })
Example #17
0
 it('should match objects', function(){
   function Foo(){}
   assert('object' === type({}))
   assert('object' === type(new Foo))
 })
Example #18
0
it('regexp', function(){
  assert(!match(/a/, /ab/))
  assert(match(/a/, /a/))
  assert(!match('a', /b/))
  assert(match('a', /a/))
})
Example #19
0
 it('should match arguments', function(){
   assert('arguments' === type((function(){ return arguments })()))
 })
Example #20
0
it('functions', function(){
  function add(){ return 1 + 1 }
  assert(match(add, /\+/))
  assert(match(add, function add(){ return 1 + 1 }))
})
Example #21
0
 it('should match typed arrays', function () {
   assert('bit-array' === type(new Uint8Array))
   assert('bit-array' === type(new Uint16Array))
   assert('bit-array' === type(new Uint32Array))
 })
Example #22
0
it('strings', function(){
  assert(!match('a', 'b'))
  assert(match('a', 'a'))
})
Example #23
0
 it('should match errors', function(){
   assert('error' === type(new Error))
   assert('error' === type(new TypeError))
   assert('error' === type(new RangeError))
   assert('error' === type(new SyntaxError))
 })
Example #24
0
it('numbers', function(){
  assert(!match(1, 2))
  assert(match(1, 1))
})
Example #25
0
 it('should match numbers', function(){
   assert('number' === type(12))
   assert('number' === type(new Number(12)))
 })