mirror of https://github.com/lukechilds/ow.git
committed by
Sindre Sorhus
5 changed files with 53 additions and 1 deletions
@ -0,0 +1,8 @@ |
|||
import test from 'ava'; |
|||
import m from '..'; |
|||
|
|||
test('dataView', t => { |
|||
t.notThrows(() => m(new DataView(new ArrayBuffer(1)), m.dataView)); |
|||
t.throws(() => m(new ArrayBuffer(1) as any, m.dataView), 'Expected argument to be of type `dataView` but received type `ArrayBuffer`'); |
|||
t.throws(() => m(12 as any, m.dataView), 'Expected argument to be of type `dataView` but received type `number`'); |
|||
}); |
@ -0,0 +1,10 @@ |
|||
import test from 'ava'; |
|||
import m from '..'; |
|||
|
|||
test('nan', t => { |
|||
t.notThrows(() => m(NaN, m.nan)); |
|||
t.notThrows(() => m(Number.NaN, m.nan)); |
|||
t.notThrows(() => m(0 / 0, m.nan)); |
|||
t.throws(() => m(12, m.nan), 'Expected argument to be of type `nan` but received type `number`'); |
|||
t.throws(() => m('12' as any, m.nan), 'Expected argument to be of type `nan` but received type `string`'); |
|||
}); |
@ -0,0 +1,13 @@ |
|||
import test from 'ava'; |
|||
import m from '..'; |
|||
|
|||
test('nullOrUndefined', t => { |
|||
const x = null; |
|||
const y = undefined; |
|||
|
|||
t.notThrows(() => m(null, m.nullOrUndefined)); |
|||
t.notThrows(() => m(undefined, m.nullOrUndefined)); |
|||
t.notThrows(() => m(x, m.nullOrUndefined)); |
|||
t.notThrows(() => m(y, m.nullOrUndefined)); |
|||
t.throws(() => m('foo' as any, m.nullOrUndefined), 'Expected argument to be of type `nullOrUndefined` but received type `string`'); |
|||
}); |
Loading…
Reference in new issue