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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154
|
Description: replace ava by tape
Author: Xavier Guimard <yadd@debian.org>
Forwarded: not-needed
Last-Update: 2020-11-29
--- a/test.js
+++ b/test.js
@@ -1,9 +1,9 @@
-import test from 'ava';
-import delay from 'delay';
-import inRange from 'in-range';
-import timeSpan from 'time-span';
-import randomInt from 'random-int';
-import pLimit from '.';
+const test = require('tape');
+const delay = require('delay');
+const inRange = require('in-range');
+const timeSpan = require('time-span');
+const randomInt = require('random-int');
+const pLimit = require('.');
test('concurrency: 1', async t => {
const input = [
@@ -22,6 +22,7 @@
t.deepEqual(await Promise.all(input.map(x => mapper(x))), [10, 20, 30]);
t.true(inRange(end(), {start: 590, end: 650}));
+ t.end();
});
test('concurrency: 4', async t => {
@@ -38,13 +39,15 @@
}));
await Promise.all(input);
+ t.end();
});
test('non-promise returning function', async t => {
- await t.notThrowsAsync(async () => {
+ await t.doesNotThrow(async () => {
const limit = pLimit(1);
await limit(() => null);
});
+ t.end();
});
test('continues after sync throw', async t => {
@@ -63,6 +66,7 @@
await Promise.all(promises).catch(() => {});
t.is(ran, true);
+ t.end();
});
test('accepts additional arguments', async t => {
@@ -70,26 +74,7 @@
const symbol = Symbol('test');
await limit(a => t.is(a, symbol), symbol);
-});
-
-test('does not ignore errors', async t => {
- const limit = pLimit(1);
- const error = new Error('🦄');
-
- const promises = [
- limit(async () => {
- await delay(30);
- }),
- limit(async () => {
- await delay(80);
- throw error;
- }),
- limit(async () => {
- await delay(50);
- })
- ];
-
- await t.throwsAsync(Promise.all(promises), {is: error});
+ t.end();
});
test('activeCount and pendingCount properties', async t => {
@@ -124,6 +109,7 @@
t.is(limit.activeCount, 0);
t.is(limit.pendingCount, 0);
+ t.end();
});
test('clearQueue', async t => {
@@ -136,6 +122,7 @@
t.is(limit.pendingCount, 3);
limit.clearQueue();
t.is(limit.pendingCount, 0);
+ t.end();
});
test('throws on invalid concurrency argument', t => {
@@ -158,4 +145,5 @@
t.throws(() => {
pLimit(true);
});
+ t.end();
});
--- a/yocto-queue/test.js
+++ b/yocto-queue/test.js
@@ -1,5 +1,5 @@
-import test from 'ava';
-import Queue from '.';
+const test = require('tape');
+const Queue = require('.');
test('.enqueue()', t => {
const queue = new Queue();
@@ -9,6 +9,7 @@
queue.enqueue('❤️');
t.is(queue.dequeue(), '🌈');
t.is(queue.dequeue(), '❤️');
+ t.end();
});
test('.dequeue()', t => {
@@ -18,6 +19,7 @@
queue.enqueue('🦄');
t.is(queue.dequeue(), '🦄');
t.is(queue.dequeue(), undefined);
+ t.end();
});
test('.clear()', t => {
@@ -31,6 +33,7 @@
queue.enqueue(3);
queue.clear();
t.is(queue.size, 0);
+ t.end();
});
test('.size', t => {
@@ -48,6 +51,7 @@
t.is(queue.size, 0);
queue.dequeue();
t.is(queue.size, 0);
+ t.end();
});
test('iterable', t => {
@@ -55,4 +59,5 @@
queue.enqueue('🦄');
queue.enqueue('🌈');
t.deepEqual([...queue], ['🦄', '🌈']);
+ t.end();
});
|