UNPKG

moy-fp

Version:
98 lines (82 loc) 1.83 kB
import __ from '../../src/Function/__' /** * * -> String */ import toString from '../../src/String/toString' test('toString(not using __), boolean', () => { expect( toString(true) ).toBe('true') }) test('toString(not using __), date', () => { expect( toString(new Date(1994, 11, 15)) ).toBe('787420800000') }) test('toString(not using __), Number(not NaN)', () => { expect( toString(12) ).toBe('12') }) test('toString(not using __), Number(NaN)', () => { expect( toString(NaN) ).toBe('NaN') }) test('toString(not using __), string', () => { expect( toString('murakami') ).toBe('murakami') }) test('toString(not using __), regexp', () => { expect( toString(/rfg(erg)$/gi) ).toBe('/rfg(erg)$/gi') }) test('toString(not using __), null', () => { expect( toString(null) ).toBe('null') }) test('toString(not using __), undefined', () => { expect( toString(undefined) ).toBe('undefined') }) test('toString(not using __), array', () => { expect( toString([1, 2, 3, 4]) ).toBe('[1, 2, 3, 4]') }) test('toString(not using __), object', () => { expect( toString({a: 1, b: 2, c: 3}) ).toBe('{a: 1, b: 2, c: 3}') }) test('toString(not using __), funciton(anonymous)', () => { expect( toString(x => x + 1) ).toBe('anonymous') }) test('toString(not using __), funciton(named)', () => { expect( toString(function addOne(x){return x + 1}) ).toBe('addOne') }) test('toString(not using __), Map', () => { expect( toString(new Map()) ).toBe('[object Map]') }) test('toString(not using __), custom Map', () => { const customMap = new Map() customMap.toString = undefined expect( toString(customMap) ).toBe('unknownType') }) test('toString(using __), boolean', () => { expect( toString(__)(true) ).toBe('true') })