Skip to content

Commit ccd8283

Browse files
committed
Make _.omitPath tests easier to read by using indentation (#177)
1 parent 8ee77a3 commit ccd8283

File tree

1 file changed

+108
-12
lines changed

1 file changed

+108
-12
lines changed

test/object.builders.js

Lines changed: 108 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,113 @@ $(document).ready(function() {
8080
});
8181

8282
QUnit.test("omitPath", function(assert){
83-
var a = {foo: true, bar: false, baz: 42, dada: {carlos: { pepe: 9 }, pedro: 'pedro', list: [{file: '..', more: {other: { a: 1, b: 2}}, name: 'aa'}, {file: '..', name: 'bb'}]}};
84-
85-
assert.deepEqual(_.omitPath(a, 'dada.carlos.pepe'), {foo: true, bar: false, baz: 42, dada: {carlos: {}, pedro: 'pedro', list: [{file: '..', more: {other: { a: 1, b: 2}} , name: 'aa'}, {file: '..', name: 'bb'}]}}, "should return an object without the value that represent the path");
86-
assert.deepEqual(_.omitPath(a, 'dada.carlos'), {foo: true, bar: false, baz: 42, dada: {pedro: 'pedro', list: [{file: '..', more: {other: { a: 1, b: 2}} , name: 'aa'}, {file: '..', name: 'bb'}]}}, "should return an object without the value that represent the path");
87-
assert.deepEqual(_.omitPath(a, ''), {foo: true, bar: false, baz: 42, dada: {carlos: { pepe: 9 }, pedro: 'pedro', list: [{file: '..', more: {other: { a: 1, b: 2}} , name: 'aa'}, {file: '..', name: 'bb'}]}}, "should return the whole object because the path is empty");
88-
89-
assert.deepEqual(_.omitPath(a, 'dada.list.file'), {foo: true, bar: false, baz: 42, dada: {carlos: { pepe: 9 }, pedro: 'pedro', list: [{name: 'aa', more: {other: { a: 1, b: 2}}}, {name: 'bb'}]}}, "should return an object without the value in each object of the list");
90-
assert.deepEqual(_.omitPath(a, 'dada.list.name'), {foo: true, bar: false, baz: 42, dada: {carlos: { pepe: 9 }, pedro: 'pedro', list: [{file: '..', more: {other: { a: 1, b: 2}}}, {file: '..'}]}}, "should return an object without the value in each object of the list");
91-
92-
assert.deepEqual(_.omitPath(a, 'dada.list'), {foo: true, bar: false, baz: 42, dada: {carlos: { pepe: 9 }, pedro: 'pedro'}}, "should return an object without the list");
93-
94-
assert.deepEqual(_.omitPath(a, 'dada.list.more.other.a'), {foo: true, bar: false, baz: 42, dada: {carlos: { pepe: 9 }, pedro: 'pedro', list: [{file: '..', more: {other: { b: 2}} , name: 'aa'}, {file: '..', name: 'bb'}]}}, "should return an object without the value inside the values of the list");
83+
var a = {
84+
foo: true,
85+
bar: false,
86+
baz: 42,
87+
dada: {
88+
carlos: { pepe: 9 },
89+
pedro: 'pedro',
90+
list: [
91+
{file: '..', more: {other: { a: 1, b: 2}}, name: 'aa'},
92+
{file: '..', name: 'bb'}
93+
]
94+
}
95+
};
96+
97+
assert.deepEqual(_.omitPath(a, 'dada.carlos.pepe'), {
98+
foo: true,
99+
bar: false,
100+
baz: 42,
101+
dada: {
102+
carlos: {},
103+
pedro: 'pedro',
104+
list: [
105+
{file: '..', more: {other: { a: 1, b: 2}} , name: 'aa'},
106+
{file: '..', name: 'bb'}
107+
]
108+
}
109+
}, "should return an object without the value that represent the path");
110+
111+
assert.deepEqual(_.omitPath(a, 'dada.carlos'), {
112+
foo: true,
113+
bar: false,
114+
baz: 42,
115+
dada: {
116+
pedro: 'pedro',
117+
list: [
118+
{file: '..', more: {other: { a: 1, b: 2}} , name: 'aa'},
119+
{file: '..', name: 'bb'}
120+
]
121+
}
122+
}, "should return an object without the value that represent the path");
123+
124+
assert.deepEqual(_.omitPath(a, ''), {
125+
foo: true,
126+
bar: false,
127+
baz: 42,
128+
dada: {
129+
carlos: { pepe: 9 },
130+
pedro: 'pedro',
131+
list: [
132+
{file: '..', more: {other: { a: 1, b: 2}} , name: 'aa'},
133+
{file: '..', name: 'bb'}
134+
]
135+
}
136+
}, "should return the whole object because the path is empty");
137+
138+
assert.deepEqual(_.omitPath(a, 'dada.list.file'), {
139+
foo: true,
140+
bar: false,
141+
baz: 42,
142+
dada: {
143+
carlos: { pepe: 9 },
144+
pedro: 'pedro',
145+
list: [
146+
{name: 'aa', more: {other: { a: 1, b: 2}}},
147+
{name: 'bb'}
148+
]
149+
}
150+
}, "should return an object without the value in each object of the list");
151+
152+
assert.deepEqual(_.omitPath(a, 'dada.list.name'), {
153+
foo: true,
154+
bar: false,
155+
baz: 42,
156+
dada: {
157+
carlos: { pepe: 9 },
158+
pedro: 'pedro',
159+
list: [
160+
{file: '..', more: {other: { a: 1, b: 2}}},
161+
{file: '..'}
162+
]
163+
}
164+
}, "should return an object without the value in each object of the list");
165+
166+
assert.deepEqual(_.omitPath(a, 'dada.list'), {
167+
foo: true,
168+
bar: false,
169+
baz: 42,
170+
dada: {
171+
carlos: { pepe: 9 },
172+
pedro: 'pedro'
173+
}
174+
}, "should return an object without the list");
175+
176+
assert.deepEqual(_.omitPath(a, 'dada.list.more.other.a'), {
177+
foo: true,
178+
bar: false,
179+
baz: 42,
180+
dada: {
181+
carlos: { pepe: 9 },
182+
pedro: 'pedro',
183+
list: [
184+
{file: '..', more: {other: { b: 2}} , name: 'aa'},
185+
{file: '..', name: 'bb'}
186+
]
187+
}
188+
},
189+
"should return an object without the value inside the values of the list"
190+
);
95191
});
96192
});

0 commit comments

Comments
 (0)