chore(cloudcmd) lint

This commit is contained in:
coderaiser 2021-09-30 17:22:59 +03:00
parent 8f466b4c9a
commit 111eba8c31
33 changed files with 139 additions and 155 deletions

View file

@ -1,31 +1,32 @@
'use strict';
const test = require('supertape');
const tryToCatch = require('try-to-catch');
const {
test,
stub,
} = require('supertape');
const callbackify = require('./callbackify');
const {promisify} = require('util');
test('cloudcmd: common: callbackify: error', (t) => {
const promise = async () => {
throw Error('hello');
};
test('cloudcmd: common: callbackify: error', async (t) => {
const promise = stub().rejects(Error('hello'));
const fn = callbackify(promise);
const [error] = await tryToCatch(promisify(fn));
fn((e) => {
t.equal(e.message, 'hello');
t.end();
});
t.equal(error.message, 'hello');
t.end();
});
test('cloudcmd: common: callbackify', (t) => {
const promise = async () => {
return 'hi';
};
test('cloudcmd: common: callbackify', async (t) => {
const promise = stub().resolves('hi');
const fn = callbackify(promise);
const promiseAgain = promisify(fn);
const data = await promiseAgain();
fn((e, data) => {
t.equal(data, 'hi');
t.end();
});
t.equal(data, 'hi');
t.end();
});