From 5b641a7dfc193bbb7d1cc58fcd0c317d2b612628 Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Wed, 27 Feb 2019 09:33:14 -0500 Subject: [PATCH 1/2] Add tests for the build pipeline. --- .../tests/build-pipeline-dynamic-import.tsx | 3 ++ frontend/lib/tests/build-pipeline.test.tsx | 43 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 frontend/lib/tests/build-pipeline-dynamic-import.tsx create mode 100644 frontend/lib/tests/build-pipeline.test.tsx diff --git a/frontend/lib/tests/build-pipeline-dynamic-import.tsx b/frontend/lib/tests/build-pipeline-dynamic-import.tsx new file mode 100644 index 000000000..2462e8a8c --- /dev/null +++ b/frontend/lib/tests/build-pipeline-dynamic-import.tsx @@ -0,0 +1,3 @@ +export function blah(x: number) { + return x + 1; +} diff --git a/frontend/lib/tests/build-pipeline.test.tsx b/frontend/lib/tests/build-pipeline.test.tsx new file mode 100644 index 000000000..9e1755f9e --- /dev/null +++ b/frontend/lib/tests/build-pipeline.test.tsx @@ -0,0 +1,43 @@ +import autobind from 'autobind-decorator'; + +test("dynamic import works", () => { + return import('./build-pipeline-dynamic-import').then(mod => { + expect(mod.blah(5)).toEqual(6); + }); +}); + +test('autobind decorator works', () => { + class Blarg { + constructor(readonly base: number) {} + + @autobind + boop(x: number) { + return this.base + x; + } + } + + const blarg = new Blarg(6); + + expect(blarg.boop(1)).toEqual(7); +}); + +test('super() works', () => { + class Foo { + thingy: number; + + constructor() { + this.thingy = 1; + } + } + + class Bar extends Foo { + constructor() { + super() + this.thingy += 1; + } + } + + const bar = new Bar(); + + expect(bar.thingy).toEqual(2); +}); From 7fceeacceed9765dab452b217748602c9a1c1f44 Mon Sep 17 00:00:00 2001 From: Atul Varma Date: Wed, 27 Feb 2019 12:38:02 -0500 Subject: [PATCH 2/2] Improve autobind decorator test. --- frontend/lib/tests/build-pipeline.test.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/lib/tests/build-pipeline.test.tsx b/frontend/lib/tests/build-pipeline.test.tsx index 9e1755f9e..b0bf2a4a9 100644 --- a/frontend/lib/tests/build-pipeline.test.tsx +++ b/frontend/lib/tests/build-pipeline.test.tsx @@ -17,8 +17,9 @@ test('autobind decorator works', () => { } const blarg = new Blarg(6); + const boop = blarg.boop; - expect(blarg.boop(1)).toEqual(7); + expect(boop(1)).toEqual(7); }); test('super() works', () => {