git checkout ut-01-karma-jasmine-boilerplate
yarn
yarn test farmicode --watch
Implement and test a function called computeAnimalPrice
that returns the animal's price given the following rules:
- Cats are free.
- Dogs cost 300.
- Sheep cost 100.
- Females are twice the price.
Function file: apps/farmicode/src/app/compute-animal-price.ts
.
Test file: apps/farmicode/src/app/compute-animal-price.spec.ts
The example below tests the add
function. You can use it as a boilerplate.
describe('add', () => {
it('should return sum', () => {
const result = add(1, 2);
expect(result).toEqual(3);
});
});
Animal prices decrease based on their age.
Every year, the animal's price loses 20% from the initial price.
Update the function.
git checkout master
yarn test farmicode --watch