Skip to content

Commit 2d8bd45

Browse files
committed
chore(readify) lint
1 parent 365c98b commit 2d8bd45

File tree

3 files changed

+22
-15
lines changed

3 files changed

+22
-15
lines changed

.madrun.js renamed to .madrun.mjs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
import {run} from 'madrun';
22

3-
const {run} = require('madrun');
4-
5-
module.exports = {
3+
export default {
64
'lint': () => 'putout .',
75
'fresh:lint': () => run('lint', '--fresh'),
86
'lint:fresh': () => run('lint', '--fresh'),

.nycrc.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"check-coverage": true,
3+
"all": true,
4+
"exclude": [
5+
"**/*.spec.js",
6+
"**/fixture",
7+
"test",
8+
".*.{js,mjs}"
9+
],
10+
"branches": 100,
11+
"lines": 100,
12+
"functions": 100,
13+
"statements": 100
14+
}

test/readify.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
const test = require('supertape');
44
const stub = require('@cloudcmd/stub');
55
const tryToCatch = require('try-to-catch');
6-
const tryCatch = require('try-catch');
76
const mockRequire = require('mock-require');
87
const shortdate = require('shortdate');
98
const {reRequire} = mockRequire;
@@ -227,17 +226,13 @@ test('result: files should have fields name, size, date, owner, mode, type', asy
227226
});
228227

229228
test('result: file names should not be empty', async (t) => {
230-
const [e, json] = await tryToCatch(readify, '.');
229+
const [, json] = await tryToCatch(readify, '.');
231230
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);
237231

238-
t.notOk(e, 'no error');
239-
t.notOk(isThrow, 'should not throw');
232+
const noFileName = ({name}) => !name;
233+
const result = files.filter(noFileName);
240234

235+
t.deepEqual(result, []);
241236
t.end();
242237
});
243238

@@ -408,7 +403,7 @@ test('readify sort: size asc', async (t) => {
408403
const {files} = await readify('./test/fixture/attr_sort', {sort: 'size', order: 'asc'});
409404
const sorted = files.map((file) => file.name);
410405

411-
t.deepEqual(expected, sorted, 'correct order');
406+
t.deepEqual(sorted, expected, 'correct order');
412407
t.end();
413408
});
414409

@@ -441,7 +436,7 @@ test('readify: nicki: error ', async (t) => {
441436

442437
mockRequire.stop('nicki');
443438

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');
445440
t.end();
446441
});
447442

0 commit comments

Comments
 (0)