From c51db11dee1c004f7ba0d2197ea4390a32f1b79c Mon Sep 17 00:00:00 2001 From: Mychal Thompson Date: Sat, 1 Feb 2020 21:51:26 -0500 Subject: [PATCH] 4.0.1-beta-0: - Renamed AotAware to LiComponent --- spec/aot.spec.ts | 23 ++++++----------------- spec/component.spec.ts | 27 +++++++++++++++++++++++++++ src/aot.ts | 20 ++++++-------------- src/component.ts | 16 ++++++++++++++++ 4 files changed, 55 insertions(+), 31 deletions(-) create mode 100644 spec/component.spec.ts diff --git a/spec/aot.spec.ts b/spec/aot.spec.ts index 51ad42a..c8d2dc1 100644 --- a/spec/aot.spec.ts +++ b/spec/aot.spec.ts @@ -1,23 +1,12 @@ -import { Template, Spec } from "detest-bdd"; +import { Spec } from "detest-bdd"; import { AotAware } from "../src/aot"; -import { AngularLifecycleType } from "../src/lifecycle-event"; +import { LiComponent } from "../src/component"; -const spec = Spec.create<{ - targetClass: AotAware -}>(); +const spec = Spec.create<{}>(); describe("Given an AotAware class", () => { - Template.withInputs<{ methodName: AngularLifecycleType }>(["methodName"], (methodName: AngularLifecycleType) => { - - spec.beforeEach(params => { params.targetClass = new class extends AotAware {} }); - - spec.it(`should define a ${methodName} method`, (params) => { - const angularFn = params.targetClass[methodName]; - - expect(() => angularFn()).not.toThrow(); - - expect(params.targetClass[methodName]).toEqual(jasmine.any(Function)); - }); - }, ...AngularLifecycleType.values.map(methodName => ({ methodName })))(); + spec.it("it should equal LiComponent", () => { + expect(AotAware).toBe(LiComponent) + }); }); \ No newline at end of file diff --git a/spec/component.spec.ts b/spec/component.spec.ts new file mode 100644 index 0000000..a6c5dea --- /dev/null +++ b/spec/component.spec.ts @@ -0,0 +1,27 @@ +import { Template, Spec } from "detest-bdd"; +import { LiComponent } from "../src/component"; +import { AngularLifecycleType } from "../src/lifecycle-event"; + +const spec = Spec.create<{ + targetClass: LiComponent +}>(); + +describe("Given a LiComponent class", () => { + + spec.it("it should extend TemplateDynamic", () => { + expect(Object.getPrototypeOf(LiComponent).name).toEqual("TemplateDynamic"); + }); + + Template.withInputs<{ methodName: AngularLifecycleType }>(["methodName"], (methodName: AngularLifecycleType) => { + + spec.beforeEach(params => { params.targetClass = new class extends LiComponent {} }); + + spec.it(`should define a ${methodName} method`, (params) => { + const angularFn = params.targetClass[methodName]; + + expect(() => angularFn()).not.toThrow(); + + expect(params.targetClass[methodName]).toEqual(jasmine.any(Function)); + }); + }, ...AngularLifecycleType.values.map(methodName => ({ methodName })))(); +}); \ No newline at end of file diff --git a/src/aot.ts b/src/aot.ts index ccad157..f97f523 100644 --- a/src/aot.ts +++ b/src/aot.ts @@ -1,15 +1,7 @@ -// Enable dynamic templating in AoT compiled components -export function AotDynamic(): new(...args: any[]) => { [K in keyof any]: any[K]; } { - return class {}; -} +import { LiComponent } from "./component"; -export class AotAware extends AotDynamic() { - public ngOnChanges() { } - public ngOnInit() { } - public ngOnDestroy() { } - public ngDoCheck() { } - public ngAfterContentInit() { } - public ngAfterContentChecked() { } - public ngAfterViewInit() { } - public ngAfterViewChecked() { } -} \ No newline at end of file +/** + * @deprecated + * @see LiComponent + */ +export const AotAware = LiComponent; diff --git a/src/component.ts b/src/component.ts index 441c40e..357a0e3 100644 --- a/src/component.ts +++ b/src/component.ts @@ -1,3 +1,19 @@ +// Enable dynamic templating for Ivy-compiled components: +export function TemplateDynamic(): new(...args: any[]) => { [K in keyof any]: any[K]; } { + return class TemplateDynamic{}; +} + +export abstract class LiComponent extends TemplateDynamic() { + public ngOnChanges() { } + public ngOnInit() { } + public ngOnDestroy() { } + public ngDoCheck() { } + public ngAfterContentInit() { } + public ngAfterContentChecked() { } + public ngAfterViewInit() { } + public ngAfterViewChecked() { } +} + /** @ClassDecoratorFactory */ export function Reactive(): ClassDecorator { console.info("DEPRECATION NOTICE: The @Reactive() class decorator is no longer used and can be removed from your code. It will be removed in a future version of @lithiumjs/angular.");