|
3 | 3 | const test = require('supertape');
|
4 | 4 | const stub = require('@cloudcmd/stub');
|
5 | 5 | const tryToCatch = require('try-to-catch');
|
6 |
| -const tryCatch = require('try-catch'); |
7 | 6 | const mockRequire = require('mock-require');
|
8 | 7 | const shortdate = require('shortdate');
|
9 | 8 | const {reRequire} = mockRequire;
|
@@ -227,17 +226,13 @@ test('result: files should have fields name, size, date, owner, mode, type', asy
|
227 | 226 | });
|
228 | 227 |
|
229 | 228 | test('result: file names should not be empty', async (t) => {
|
230 |
| - const [e, json] = await tryToCatch(readify, '.'); |
| 229 | + const [, json] = await tryToCatch(readify, '.'); |
231 | 230 | const {files} = json;
|
232 |
| - const check = () => files.filter((file) => !file.name).forEach((file) => { |
233 |
| - throw Error('Filename should not be empty!\n' + JSON.stringify(file)); |
234 |
| - }); |
235 |
| - |
236 |
| - const [isThrow] = tryCatch(check); |
237 | 231 |
|
238 |
| - t.notOk(e, 'no error'); |
239 |
| - t.notOk(isThrow, 'should not throw'); |
| 232 | + const noFileName = ({name}) => !name; |
| 233 | + const result = files.filter(noFileName); |
240 | 234 |
|
| 235 | + t.deepEqual(result, []); |
241 | 236 | t.end();
|
242 | 237 | });
|
243 | 238 |
|
@@ -408,7 +403,7 @@ test('readify sort: size asc', async (t) => {
|
408 | 403 | const {files} = await readify('./test/fixture/attr_sort', {sort: 'size', order: 'asc'});
|
409 | 404 | const sorted = files.map((file) => file.name);
|
410 | 405 |
|
411 |
| - t.deepEqual(expected, sorted, 'correct order'); |
| 406 | + t.deepEqual(sorted, expected, 'correct order'); |
412 | 407 | t.end();
|
413 | 408 | });
|
414 | 409 |
|
@@ -441,7 +436,7 @@ test('readify: nicki: error ', async (t) => {
|
441 | 436 |
|
442 | 437 | mockRequire.stop('nicki');
|
443 | 438 |
|
444 |
| - t.ok(fn.calledWith(e), 'should call callback when nicki has error'); |
| 439 | + t.calledWith(fn, [e], 'should call callback when nicki has error'); |
445 | 440 | t.end();
|
446 | 441 | });
|
447 | 442 |
|
|
0 commit comments