These are chat archives for AngularClass/angular2-webpack-starter

16th
Oct 2016
tuckerjt07
@tuckerjt07
Oct 16 2016 02:33

I am attempting to write unit tests using a templateUrl but am getting this error message

Failed: Uncaught (in promise): Failed to load forgot-password.template.html
    Error: Uncaught (in promise): Failed to load forgot-password.template.html

for my HTML template

Here is the component file
import {Component, ViewContainerRef} from '@angular/core';
import {MdDialog, MdDialogConfig, MdDialogRef} from '@angular/material';

@Component({
    selector: 'forgot-password',
    styleUrls: ['./forgot-password.style.scss'.toString()],
    templateUrl: './forgot-password.template.html'
})

export class ForgotPasswordDialog {
    public emailAddress;

    constructor(public dialogRef: MdDialogRef<ForgotPasswordDialog>) {

    }

    ngOnInit() {
        this.emailAddress = '';
    }

    cancel() {
        this.dialogRef.close();
    }

    submit(model: string, isValid: boolean) {
        if (isValid) {
            this.dialogRef.close(model);
        }
    }
}
and the spec
import { async, TestBed } from '@angular/core/testing';
import { Component, ViewContainerRef } from '@angular/core';
import { MaterialModule } from '@angular/material';
import { ForgotPasswordDialog } from './forgot-password.component';

describe('ForgotPasswordDialog', () => {
   let forgotPassword: ForgotPasswordDialog;

    beforeEach(async(() => {
        TestBed.configureTestingModule({
            declarations: [ForgotPasswordDialog],
            imports: [MaterialModule]
        }).compileComponents();
    }));

    beforeEach(() => {
        let fixture = TestBed.createComponent(ForgotPasswordDialog);
        forgotPassword = fixture.componentInstance;
    });

    it('module should be defined', () => {
        expect(forgotPassword).toBeDefined();
    });
});
Does anyone have any idea on how to correct those errors?
johnespn
@johnespn
Oct 16 2016 16:57
@marinho will take a look and try that out, you save my day! Thanks a lot!!!