Skip to content

Fix the order of actual result and expected result #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
503 changes: 266 additions & 237 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hckrnews/arrays",
"version": "3.1.1",
"version": "3.1.2",
"description": "Usefull array helpers.",
"files": [
"src/helpers.js",
Expand Down
10 changes: 5 additions & 5 deletions test/diff-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ test('Diff array with objects', async (t) => {
await t.test(
'One side: Should return the difference, in this example should it be John.',
() => {
assert.deepEqual([{ name: 'John' }], a.diff(b));
assert.deepEqual(a.diff(b), [{ name: 'John' }]);
}
);

await t.test(
'Average both sides: Should return the difference of both sides, in this example should it be John and Paul.',
() => {
assert.deepEqual(
[{ name: 'John' }, { name: 'Paul' }],
a.diff(b, true)
);
assert.deepEqual(a.diff(b, true), [
{ name: 'John' },
{ name: 'Paul' },
]);
}
);
});
4 changes: 2 additions & 2 deletions test/diff.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ test('Diff', async (t) => {
await t.test(
'One side: Should return the difference, in this example should it be John.',
() => {
assert.deepEqual(['John'], a.diff(b));
assert.deepEqual(a.diff(b), ['John']);
}
);

await t.test(
'Average both sides: Should return the difference of both sides, in this example should it be John and Paul.',
() => {
assert.deepEqual(['John', 'Paul'], a.diff(b, true));
assert.deepEqual(a.diff(b, true), ['John', 'Paul']);
}
);
});
10 changes: 5 additions & 5 deletions test/intersect-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ test('Intersect array with objects', async (t) => {
await t.test(
'One side: Should return the intersect, in this example should it be Peter and Luke.',
() => {
assert.deepEqual(
[{ name: 'Peter' }, { name: 'Luke' }],
a.intersect(b)
);
assert.deepEqual(a.intersect(b), [
{ name: 'Peter' },
{ name: 'Luke' },
]);
}
);

await t.test(
'Average both sides: Should return the intersect of more than 2 arrays, in this example should it be Luke.',
() => {
assert.deepEqual([{ name: 'Luke' }], a.intersect([b, c], true));
assert.deepEqual(a.intersect([b, c], true), [{ name: 'Luke' }]);
}
);
});
4 changes: 2 additions & 2 deletions test/intersect.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ test('Intersect', async (t) => {
await t.test(
'One side: Should return the intersect, in this example should it be Peter and Luke.',
() => {
assert.deepEqual(['Peter', 'Luke'], a.intersect(b));
assert.deepEqual(a.intersect(b), ['Peter', 'Luke']);
}
);
await t.test(
'Average both sides: Should return the intersect of more than 2 arrays, in this example should it be Luke.',
() => {
assert.deepEqual(['Luke'], a.intersect([b, c], true));
assert.deepEqual(a.intersect([b, c], true), ['Luke']);
}
);
});
24 changes: 12 additions & 12 deletions test/multifilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ test('Test 1 (==)', async (t) => {
'Should return 2 items from the array, where age is 62.',
() => {
assert.deepEqual(
expectedResults.test1,
exampleArray.multifilter('age', 62)
exampleArray.multifilter('age', 62),
expectedResults.test1
);
}
);
Expand All @@ -249,8 +249,8 @@ test('Test 2 (!=)', async (t) => {
'Should return 2 items from the array, where age is not 62.',
() => {
assert.deepEqual(
expectedResults.test2,
exampleArray.multifilter('age', 62, '!=')
exampleArray.multifilter('age', 62, '!='),
expectedResults.test2
);
}
);
Expand All @@ -261,8 +261,8 @@ test('Test 3 (>)', async (t) => {
'Should return 2 items from the array, where age is more than 62.',
() => {
assert.deepEqual(
expectedResults.test3,
exampleArray.multifilter('age', 62, '>')
exampleArray.multifilter('age', 62, '>'),
expectedResults.test3
);
}
);
Expand Down Expand Up @@ -309,8 +309,8 @@ test('Test 7 (multiple ==)', async (t) => {
'Should return 2 items from the array, where the name is John or Peter.',
() => {
assert.deepEqual(
expectedResults.test7,
exampleArray.multifilter('name', ['John', 'Peter'])
exampleArray.multifilter('name', ['John', 'Peter']),
expectedResults.test7
);
}
);
Expand All @@ -321,8 +321,8 @@ test('Test 8 (multiple !=)', async (t) => {
'Should return 2 items from the array, where the name is not John or Peter.',
() => {
assert.deepEqual(
expectedResults.test8,
exampleArray.multifilter('name', ['John', 'Peter'], '!=')
exampleArray.multifilter('name', ['John', 'Peter'], '!='),
expectedResults.test8
);
}
);
Expand All @@ -333,8 +333,8 @@ test('Test 9 (multiple >)', async (t) => {
'Should return 2 items from the array, where age is more than 62 and 63.',
() => {
assert.deepEqual(
expectedResults.test9,
exampleArray.multifilter('age', ['62', '63'], '>')
exampleArray.multifilter('age', ['62', '63'], '>'),
expectedResults.test9
);
}
);
Expand Down
8 changes: 4 additions & 4 deletions test/multikey.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ test('Multikey', async (t) => {
'Test 1 (single): Should return the max, in this example should it be 3.',
() => {
assert.deepEqual(
expectedResults.test1,
exampleArray.multikey('name')
exampleArray.multikey('name'),
expectedResults.test1
);
}
);
Expand All @@ -66,8 +66,8 @@ test('Multikey', async (t) => {
'Test 2 (multiple): Should return the max, in this example should it be 3.',
() => {
assert.deepEqual(
expectedResults.test2,
exampleArray.multikey(['name', 'age'])
exampleArray.multikey(['name', 'age']),
expectedResults.test2
);
}
);
Expand Down
12 changes: 6 additions & 6 deletions test/multisort.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ test('Multisort', async (t) => {
'Test 1 (ASC): Should return the array, sorted by age asc.',
() => {
assert.deepEqual(
expectedResults.test1,
exampleArray.multisort('age', 'asc')
exampleArray.multisort('age', 'asc'),
expectedResults.test1
);
}
);
Expand All @@ -127,8 +127,8 @@ test('Multisort', async (t) => {
'Test 2 (DESC): Should return the array, sorted by age desc.',
() => {
assert.deepEqual(
expectedResults.test2,
exampleArray.multisort('age', 'desc')
exampleArray.multisort('age', 'desc'),
expectedResults.test2
);
}
);
Expand All @@ -137,8 +137,8 @@ test('Multisort', async (t) => {
'Test 3 (sort text ASC): Should return the array, sorted by age asc.',
() => {
assert.deepEqual(
expectedResults.test3,
exampleArray.multisort('name', 'asc')
exampleArray.multisort('name', 'asc'),
expectedResults.test3
);
}
);
Expand Down
2 changes: 1 addition & 1 deletion test/unique.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ test('Unique', async (t) => {
await t.test(
'Should return the unique items from the array, in this example 4 items.',
() => {
assert.deepEqual(expectedResults, a.unique);
assert.deepEqual(a.unique, expectedResults);
}
);
});