Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / chain-able-deps   js

Repository URL to install this package:

Version: 6.0.4 

/ src / fp / __tests__ / replace.ts

import replace from '../../fp/replace'

test('replaces substrings of the input string', () => {
  expect(replace('1', 'one', '1 two three')).toEqual('one two three')
})

test('replaces regex matches of the input string', () => {
  expect(replace(/\d+/g, 'num', '1 2 three')).toEqual('num num three')
})

test('is curried up to 3 arguments', () => {
  expect(replace('').constructor, Function)
  expect(replace('', '').constructor, Function)

  const replaceSemicolon = replace(';')
  const removeSemicolon = replaceSemicolon('')
  expect(removeSemicolon('return 42;')).toEqual('return 42')
})