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 87 88
|
Description: replace ava by tape
Author: Xavier Guimard <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2022-08-18
--- a/test.js
+++ b/test.js
@@ -1,16 +1,18 @@
-import test from 'ava';
+import test from 'tape';
import mapObject, {mapObjectSkip} from './index.js';
test('main', t => {
t.is(mapObject({foo: 'bar'}, key => [key, 'unicorn']).foo, 'unicorn');
t.is(mapObject({foo: 'bar'}, (key, value) => ['unicorn', value]).unicorn, 'bar');
t.is(mapObject({foo: 'bar'}, (key, value) => [value, key]).bar, 'foo');
+ t.end();
});
test('target option', t => {
const target = {};
t.is(mapObject({foo: 'bar'}, (key, value) => [value, key], {target}), target);
t.is(target.bar, 'foo');
+ t.end();
});
test('deep option', t => {
@@ -45,6 +47,7 @@
const mapper = (key, value) => [key, typeof value === 'number' ? value * 2 : value];
const actual = mapObject(object, mapper, {deep: true});
t.deepEqual(actual, expected);
+ t.end();
});
test('shouldRecurse mapper option', t => {
@@ -86,6 +89,7 @@
const actual = mapObject(object, mapper, {deep: true});
t.deepEqual(actual, expected);
+ t.end();
});
test('nested arrays', t => {
@@ -118,6 +122,7 @@
const mapper = (key, value) => [key, typeof value === 'number' ? value * 2 : value];
const actual = mapObject(object, mapper, {deep: true});
t.deepEqual(actual, expected);
+ t.end();
});
test('handles circular references', t => {
@@ -145,20 +150,18 @@
expected.ARRAY.push(expected);
t.deepEqual(actual, expected);
+ t.end();
});
test('validates input', t => {
t.throws(() => {
mapObject(1, () => {});
- }, {
- instanceOf: TypeError,
});
t.throws(() => {
mapObject([1, 2], (key, value) => [value, key]);
- }, {
- instanceOf: TypeError,
});
+ t.end();
});
test('__proto__ keys are safely dropped', t => {
@@ -170,6 +173,7 @@
// between plain objects as prototypes and Object.prototype, so we also check
// the prototype by identity
t.is(Object.getPrototypeOf(output), Object.prototype);
+ t.end();
});
test('remove keys (#36)', t => {
@@ -185,4 +189,5 @@
const mapper = (key, value) => value === 1 ? [key, value] : mapObjectSkip;
const actual = mapObject(object, mapper, {deep: true});
t.deepEqual(actual, expected);
+ t.end();
});
|