Skip to content

Commit

Permalink
feat(elements): add new LazyElementsTestingModule
Browse files Browse the repository at this point in the history
- use ng-packager sub-entries
- import using @angular-extensions/elements/testing
- overrides *axLazyElement and *axLazyElementDynamic for testing
  • Loading branch information
tomastrajan committed Feb 21, 2020
1 parent dbd0f76 commit 9926ae7
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 8 deletions.
2 changes: 1 addition & 1 deletion angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/elements/src/test.ts",
"main": "projects/elements/test.ts",
"tsConfig": "projects/elements/tsconfig.spec.json",
"karmaConfig": "projects/elements/karma.conf.js"
}
Expand Down
2 changes: 1 addition & 1 deletion projects/elements/ng-package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
"dest": "../../dist/elements",
"lib": {
"entryFile": "src/public-api.ts"
"entryFile": "src/public_api.ts"
}
}
1 change: 1 addition & 0 deletions projects/elements/src/lib/lazy-elements/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './public_api';
7 changes: 7 additions & 0 deletions projects/elements/src/lib/lazy-elements/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ngPackage": {
"lib": {
"entryFile": "public_api.ts"
}
}
}
1 change: 1 addition & 0 deletions projects/elements/src/lib/lazy-elements/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lazy-elements.module';
5 changes: 0 additions & 5 deletions projects/elements/src/public-api.ts

This file was deleted.

5 changes: 5 additions & 0 deletions projects/elements/src/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/*
* Public API Surface of elements
*/

export * from './lib/lazy-elements';
File renamed without changes.
1 change: 1 addition & 0 deletions projects/elements/testing/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './public_api';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
Directive,
OnInit,
TemplateRef,
ViewContainerRef
} from '@angular/core';

@Directive({
selector: '[axLazyElementDynamic]'
})
export class LazyElementDynamicTestingDirective implements OnInit {
constructor(
private vcr: ViewContainerRef,
private template: TemplateRef<any>
) {}

ngOnInit() {
this.vcr.createEmbeddedView(this.template);
}
}
20 changes: 20 additions & 0 deletions projects/elements/testing/lazy-element-testing.directive.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {
Directive,
OnInit,
TemplateRef,
ViewContainerRef
} from '@angular/core';

@Directive({
selector: '[axLazyElement]'
})
export class LazyElementTestingDirective implements OnInit {
constructor(
private vcr: ViewContainerRef,
private template: TemplateRef<any>
) {}

ngOnInit() {
this.vcr.createEmbeddedView(this.template);
}
}
13 changes: 13 additions & 0 deletions projects/elements/testing/lazy-elements-testing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';

import { LazyElementTestingDirective } from './lazy-element-testing.directive';
import { LazyElementDynamicTestingDirective } from './lazy-element-dynamic-testing.directive';

@NgModule({
declarations: [
LazyElementTestingDirective,
LazyElementDynamicTestingDirective
],
exports: [LazyElementTestingDirective, LazyElementDynamicTestingDirective]
})
export class LazyElementsTestingModule {}
7 changes: 7 additions & 0 deletions projects/elements/testing/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"ngPackage": {
"lib": {
"entryFile": "public_api.ts"
}
}
}
3 changes: 3 additions & 0 deletions projects/elements/testing/public_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * from './lazy-elements-testing.module';
export * from './lazy-element-testing.directive';
export * from './lazy-element-dynamic-testing.directive';
2 changes: 1 addition & 1 deletion projects/elements/tsconfig.spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"outDir": "../../out-tsc/spec",
"types": ["jasmine", "node"]
},
"files": ["src/test.ts"],
"files": ["test.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
}

0 comments on commit 9926ae7

Please sign in to comment.