Skip to content

Instantly share code, notes, and snippets.

export const fetch = async () => {
return await axios.get('/users')
}
export const fetchUsers = async () => {
return await axios.get('/users')
}
// Find student from lists, with the given id
const student = students.find(s => s.id === id)
// Calculate tax based on the income and wealth value and ....
const income = document.getElementById('income').value;
const wealth = document.getElementById('wealth').value;
tax.value = (0.15 * income) + (0.25 * wealth);
// ...
function calculateTax(income, wealth) {
return (0.15 * income) + (0.25 * wealth);
}
export const getAnimal = (code) => {
if (code === 1) return 'CATS'
if (code === 2) return 'DOGS'
if (code === 3) return 'RABBITS'
return null
}
import { getAnimal } from './util';
describe('getAnimal', () => {
it('passes', () => {
expect(getAnimal(1)).toEqual('CATS')
})
})
describe('getAnimal', () => {
it('should get CATS when passing code 1', () => {
expect(getAnimal(1)).toEqual('CATS')
})
})
describe('getAnimal', () => {
context('when passing code 1', () => {
it('should get CATS', () => {
expect(getAnimal(1)).toEqual('CATS')
})
})
})
describe('getAnimal', () => {
context('when passing code 1', () => {
beforeEach(() => {
// arrange
// prepare data here
})
it('should get CATS', () => {
// act
const result = getAnimal(1)