deno.land / x / rambda@v9.1.1 / source / replaceAll.spec.js

replaceAll.spec.js
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {replaceAll} from './replaceAll.js'
const replacer = '|'const patterns = [/foo/g, 'bar']const input = 'foo bar baz foo bar'
test('happy', () => { const result = replaceAll(patterns, replacer, input) const expected = '| | baz | bar'
expect(result).toEqual(expected)})
test('throws when wrong patterns', () => { expect(() => replaceAll({}, replacer, input)) .toThrowErrorMatchingInlineSnapshot(` "Failed R.ok - reason: {"input":{},"schema":"array"} all inputs: [{},"|","foo bar baz foo bar"] all schemas: ["array","string","string"]" `)})
test('throws when wrong input', () => { expect(() => replaceAll(patterns, replacer, [])) .toThrowErrorMatchingInlineSnapshot(` "Failed R.ok - reason: {"input":[],"schema":"string"} all inputs: [[{},"bar"],"|",[]] all schemas: ["array","string","string"]" `)})
test('throws when wrong replacer', () => { expect(() => replaceAll(patterns, null, input)) .toThrowErrorMatchingInlineSnapshot(` "Failed R.ok - reason: {"input":null,"schema":"string"} all inputs: [[{},"bar"],null,"foo bar baz foo bar"] all schemas: ["array","string","string"]" `)})
rambda

Version Info

Tagged at
2 months ago