Skip to content

Instantly share code, notes, and snippets.

View raphaelpor's full-sized avatar
:octocat:

Raphael Porto raphaelpor

:octocat:
  • Viaplay Group
  • Stockholm, Sweden.
View GitHub Profile
const somePromise = () => Promise.resolve('Done!');
test('Promise', t => {
return somePromise().then(result => {
t.is(result, 'Done!');
});
});
// ou
module.exports = (name = 'people') => {
return `Hello, ${name}!`
}
const test = require('ava')
const greet = require('./greet')
test('method: greet', t => {
t.is(typeof greet, 'function', 'greet is a function')
t.is(greet(), 'Hello, people!', 'greet returns a default name')
t.is(greet('Raphael Porto'), 'Hello, Raphael Porto!', 'greet returns the name')
})
module.exports = () => {}
const test = require('ava')
const greet = require('./greet')
test('method: greet', t => {
t.is(typeof greet, 'function', 'greet is a function')
})
export default function transformParams(source) {
if (source) {
const params = Object.entries(source);
const paramsList = [];
params.forEach((item) => {
const key = encodeURIComponent(item[0]);
const value = encodeURIComponent(item[1]);
paramsList.push(`${key}=${value}`);
import test from 'ava';
test('foo', t => {
t.pass();
});
# usando npm
npm i -g ava
# ou usando o yarn
yarn global add ava
# após a instalação, inicie o ava com o comando:
ava --init
import fitch from 'fitch';
const config = {
body: { cat: 'grumpy' },
cache: 'no-cache',
mode: 'no-cors',
params: {
categ: 10,
type: 5,
},
import fitch from 'fitch';
fitch.get('file.json')
.then(response => {
console.log(response.data);
})
.catch(err => {
console.log(err.message);
});