mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
chore(cloudcmd) lint
This commit is contained in:
parent
8f466b4c9a
commit
111eba8c31
33 changed files with 139 additions and 155 deletions
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue