UNPKG

moy-fp

Version:
48 lines (40 loc) 1.2 kB
import __ from '../../src/Function/__' /** * RegExp | String -> String | (($0, $1, ..., index, String) -> String) -> String -> String */ import replace from '../../src/String/replace' test('replace(not using __), string and string', () => { expect( replace('a')('e')('murakami') ).toBe('murekami') }) test('replace(not using __), regexp without flag g and string', () => { expect( replace(/a/)('e')('murakami') ).toBe('murekami') }) test('replace(not using __), regexp with flag g and string', () => { expect( replace(/a/g)('e')('murakami') ).toBe('murekemi') }) test('replace(not using __), string and function', () => { expect( replace('a')($0 => $0 + 'g')('murakami') ).toBe('muragkami') }) test('replace(not using __), regexp without flag g and function', () => { expect( replace(/([kr])a/)(($0, $1) => 'g' + $0 + $1)('murakami') ).toBe('mugrarkami') }) test('replace(not using __), regexp whth flag g and function', () => { expect( replace(/([kr])a/g)(($0, $1) => 'g' + $0 + $1)('murakami') ).toBe('mugrargkakmi') }) test('replace(using __), string and string', () => { expect( replace('a', __, 'murakami')('e') ).toBe('murekami') })