mirror of
https://github.com/microsoft/frontend-bootcamp.git
synced 2026-01-26 14:56:42 +08:00
adding basic jest tests
This commit is contained in:
8
step2-04/index.html
Normal file
8
step2-04/index.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<body>
|
||||
For this step, we look at unit testing. Run
|
||||
<pre>npm test</pre>
|
||||
in the command line.
|
||||
</body>
|
||||
</html>
|
||||
16
step2-04/index.spec.ts
Normal file
16
step2-04/index.spec.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { square } from '.';
|
||||
|
||||
describe('square', () => {
|
||||
beforeEach(() => {
|
||||
console.log('this happens before each test');
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
console.log('this happens after each test');
|
||||
});
|
||||
|
||||
it('should be able to give the square of two numbers', () => {
|
||||
console.log('test');
|
||||
expect(square(5)).toBe(25);
|
||||
});
|
||||
});
|
||||
3
step2-04/index.ts
Normal file
3
step2-04/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function square(x: number) {
|
||||
return x * x;
|
||||
}
|
||||
Reference in New Issue
Block a user