deno.land / x / rambda@v9.1.1 / files / waiting / flattenObject.spec.js

flattenObject.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import { flattenObject, flattenObjectHelper, transformFlatObject,} from './flattenObject.js'
test('happy', () => { const obj = { c : 3, d : { 'd.e' : [ 5, 6, 7 ], 'd.z' : 4, 'd.f' : { 'd.f.h' : 6 }, }, } const result = transformFlatObject(obj) console.log(result) // expect(result).toEqual({ // 'c' : 3, // 'd.e' : [ 5, 6, 7 ], // 'd.z' : 4, // 'd.f.h' : 6, // })})
test('happy', () => { const result = flattenObject({ a : 1, b : { c : 3, d : { e : 5, z : 4, f : { h : 6, i : 7, j : { k : 8, l : 9, }, }, }, }, }) console.log('result', result)
// const expected = { // 'a' : 1, // 'b.c' : 3, // 'b.d.e' : 5, // 'b.d.z' : 4, // 'b.d.f.h' : 6, // 'b.d.f.i' : 7, // 'b.d.f.j.k' : 8, // 'b.d.f.j.l' : 9, // } // expect(result).toEqual(expected)})
test('flattenObjectHelper', () => { const result = flattenObjectHelper({ a : 1, b : { c : 3, d : { e : 5, z : 4, f : { h : 6 }, }, }, }) console.log('result', result) // const expected = { // a : 1, // b : { // 'b.c' : 3, // 'b.d' : { // 'b.d.e' : 5, // 'b.d.z' : 4, // 'b.d.f' : { 'b.d.f.h' : 6 }, // }, // }, // } // expect(result).toEqual(expected)})
rambda

Version Info

Tagged at
a year ago