This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const somePromise = () => Promise.resolve('Done!'); | |
test('Promise', t => { | |
return somePromise().then(result => { | |
t.is(result, 'Done!'); | |
}); | |
}); | |
// ou |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = (name = 'people') => { | |
return `Hello, ${name}!` | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = () => {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const test = require('ava') | |
const greet = require('./greet') | |
test('method: greet', t => { | |
t.is(typeof greet, 'function', 'greet is a function') | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import test from 'ava'; | |
test('foo', t => { | |
t.pass(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fitch from 'fitch'; | |
const config = { | |
body: { cat: 'grumpy' }, | |
cache: 'no-cache', | |
mode: 'no-cors', | |
params: { | |
categ: 10, | |
type: 5, | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fitch from 'fitch'; | |
fitch.get('file.json') | |
.then(response => { | |
console.log(response.data); | |
}) | |
.catch(err => { | |
console.log(err.message); | |
}); |
NewerOlder