mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
33 lines
697 B
TypeScript
33 lines
697 B
TypeScript
import { square } from '.';
|
|
|
|
describe('jest example', () => {
|
|
beforeEach(() => {
|
|
jest.resetModules();
|
|
});
|
|
|
|
it('should be able to give the square of two numbers', () => {
|
|
console.log('test');
|
|
expect(square(5)).toBe(25);
|
|
});
|
|
|
|
it('should increment counter', () => {
|
|
const { increment } = require('.');
|
|
expect(increment()).toBe(1);
|
|
});
|
|
|
|
it('should decrement counter', () => {
|
|
const { decrement } = require('.');
|
|
expect(decrement()).toBe(-1);
|
|
});
|
|
|
|
it('should retrieve count', () => {
|
|
const { decrement, getCount, increment } = require('.');
|
|
increment();
|
|
increment();
|
|
decrement();
|
|
increment();
|
|
|
|
expect(getCount()).toBe(2);
|
|
});
|
|
});
|