diff --git a/step2-01/src/async/index.ts b/step2-01/src/async/index.ts index efcf1d5..bc9d239 100644 --- a/step2-01/src/async/index.ts +++ b/step2-01/src/async/index.ts @@ -3,6 +3,7 @@ async function fetchSomething() { return await response.text(); } +// Async functions always returns Promise fetchSomething().then(text => { console.log('hello ' + text); }); diff --git a/step2-04/index.html b/step2-04/index.html new file mode 100644 index 0000000..be1bd8a --- /dev/null +++ b/step2-04/index.html @@ -0,0 +1,8 @@ + + + + For this step, we look at unit testing. Run +
npm test
+ in the command line. + + diff --git a/step2-04/index.spec.ts b/step2-04/index.spec.ts new file mode 100644 index 0000000..2b48abb --- /dev/null +++ b/step2-04/index.spec.ts @@ -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); + }); +}); diff --git a/step2-04/index.ts b/step2-04/index.ts new file mode 100644 index 0000000..4d99754 --- /dev/null +++ b/step2-04/index.ts @@ -0,0 +1,3 @@ +export function square(x: number) { + return x * x; +}