Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hanging ngModule in container specs? #64

Closed
BrainCrumbz opened this issue Sep 16, 2016 · 3 comments
Closed

Hanging ngModule in container specs? #64

BrainCrumbz opened this issue Sep 16, 2016 · 3 comments

Comments

@BrainCrumbz
Copy link

In toaster-container.component.spec.ts, after TestComponent class there seems to be a @NgModule decorator not attached to any class definition:

export class TestComponent {
    toasterService: ToasterService;

    constructor(toasterService: ToasterService) {
        this.toasterService = toasterService;
    }

    public toasterconfig: ToasterConfig = new ToasterConfig({ showCloseButton: true, tapToDismiss: false, timeout: 0, toastContainerId: 1 });
    public toasterconfig2: ToasterConfig = new ToasterConfig({ showCloseButton: true, tapToDismiss: false, timeout: 0, toastContainerId: 2 });
}
@NgModule({
    imports: [ToasterModule],
    declarations: [TestComponent]
})


// Mock component for testing bodyOutputType Component rendering
@Component({
    selector: 'test-dynamic-component',
    template: `<div>loaded via component</div>`
})

Is that intended? While working at a PR to remove typings from source control, we incurred in a build error on toaster-container.component.spec.ngfactory.ts:

Error: Error at D:/WS/JS/Angular2-Toaster/src/toaster-container.component.spec.ngfactory.ts:97:14: Cannot redeclare block-scoped variable 'TestDynamicComponentNgFactory'.
Error at D:/WS/JS/Angular2-Toaster/src/toaster-container.component.spec.ngfactory.ts:361:14: Cannot redeclare block-scoped variable 'TestDynamicComponentNgFactory'.
at check (D:\WS\JS\Angular2-Toaster\node_modules@angular\tsc-wrapped\src\tsc.js:31:15)
at Tsc.typeCheck (D:\WS\JS\Angular2-Toaster\node_modules@angular\tsc-wrapped\src\tsc.js:86:9)
at D:\WS\JS\Angular2-Toaster\node_modules@angular\tsc-wrapped\src\main.js:33:23
at process._tickCallback (internal/process/next_tick.js:103:7)
at Module.runMain (module.js:577:11)
at run (node.js:348:7)
at startup (node.js:140:9)
at node.js:463:3
Compilation failed

Not sure if it's due to this issue, though.

@BrainCrumbz
Copy link
Author

Adding the following fixes build:

@NgModule({
    imports: [ToasterModule],
    declarations: [TestComponent]
})
export class ComponentSpecModule { }  // <-- added

but not sure what happens to tests then...

Chrome 53.0.2785 (Windows 10 0.0.0) ERROR: '(SystemJS) XHR error (404 Not Found) loading http://localhost:9876/base/node_modules/@angular/core/bundles/core.umd.js/src/linker/ng_module_factory
Error: XHR error (404 Not Found) loading http://localhost:9876/base/node_modules/@angular/core/bundles/core.umd.js/src/linker/ng_module_factory
at XMLHttpRequest.wrapFn as _onreadystatechange
at ZoneDelegate.invokeTask (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?02524aa211d9378ad861942509a2e2b9e3622f53:225:37)
at Zone.runTask (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?02524aa211d9378ad861942509a2e2b9e3622f53:125:47)
at XMLHttpRequest.ZoneTask.invoke (http://localhost:9876/base/node_modules/zone.js/dist/zone.js?02524aa211d9378ad861942509a2e2b9e3622f53:293:33)
Error loading http://localhost:9876/base/node_modules/@angular/core/bundles/core.umd.js/src/linker/ng_module_factory as "@angular/core/src/linker/ng_module_factory" from http://localhost:9876/base/lib/toaster-container.component.spec.ngfactory.js'

@Stabzs
Copy link
Owner

Stabzs commented Sep 16, 2016

Yes, this is absolutely intended. This is the NgModule definition for the TestComponent class (hence the TestComponent declaration). Removing or modifying this will break the tests, as you found.

@Stabzs
Copy link
Owner

Stabzs commented Sep 16, 2016

The issue here is that there needed to be a declared exported class for TestComponent as well.

Stabzs added a commit that referenced this issue Sep 16, 2016
The library has been updated to Angular `2.0.0` and the version has been
bumped to `1.0.0` as a result. Closes
#63.
The library has been updated from tsd to typings.  Typings have been
updated and wired into the build and are now re-installed on `npm
install`. In addition, typings are no longer checked into source.
Closes #60.
The main entrance has been updated to `angular2-toaster.js`.  Addresses
#60.
The `bodyOutputType` property is public to enable AoT compilation on the
template. Closes #62.
The `TestComponent` module was improperly defined, causing errors in the
corresponding `ngFactory` file.  This has been corrected, closing
#64.
@Stabzs Stabzs closed this as completed Sep 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants