From 7f941b9f05b8b3dd458d98f20594f11342883dc5 Mon Sep 17 00:00:00 2001 From: Meirion Hughes Date: Fri, 17 Feb 2017 11:42:03 +0000 Subject: [PATCH] spec: validate inheritence support ref #167 --- spec/binding.spec.ts | 79 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 2 deletions(-) diff --git a/spec/binding.spec.ts b/spec/binding.spec.ts index a3a350a..919ee7f 100644 --- a/spec/binding.spec.ts +++ b/spec/binding.spec.ts @@ -1608,11 +1608,86 @@ describe("Static-Type Binding Tests", () => { reflection.add("./path/foo.ts", viewmodel); linter.lint(view, "./path/foo.html") .then((issues) => { - expect(issues.length).toBe(0); + expect(issues.length).toBe(0); done(); }); }); - + + // #167 + it("Support inheritence (different files)", (done) => { + + let viewmodel = ` + import {Bar} from './bar'; + export class Foo extends Bar { + myProp = "Lorem Ipsum"; + }`; + + let base = ` + export class Bar { + toggled = false; + + toggle() { + this.toggled = !this.toggled; + } + }`; + + let view = ` + `; + + let reflection = new Reflection(); + let rule = new BindingRule(reflection, new AureliaReflection(), { + }); + let linter = new Linter([rule]); + reflection.add("./path/foo.ts", viewmodel); + reflection.add("./path/bar.ts", base); + linter.lint(view, "./path/foo.html") + .then((issues) => { + expect(issues.length).toBe(1); + expect(issues[0].message).toBe("cannot find 'invalid' in type 'Foo'"); + done(); + }); + }); + + // #167 + it("Support inheritence (same file)", (done) => { + + let viewmodel = ` + export class Foo extends Bar { + myProp = "Lorem Ipsum"; + } + + export class Bar { + toggled = false; + + toggle() { + this.toggled = !this.toggled; + } + }`; + + let view = ` + `; + + let reflection = new Reflection(); + let rule = new BindingRule(reflection, new AureliaReflection(), { + }); + let linter = new Linter([rule]); + reflection.add("./path/foo.ts", viewmodel); + linter.lint(view, "./path/foo.html") + .then((issues) => { + expect(issues.length).toBe(1); + expect(issues[0].message).toBe("cannot find 'invalid' in type 'Foo'"); + done(); + }); + }); + /*it("rejects more than one class in view-model file", (done) => {