profile-view.component.spec.ts
1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder';
import {Profile} from "./../../models/interfaces";
import * as helpers from "../../../spec/helpers";
import {Component} from 'ng-forward'
import {ProfileView} from './profile-view.component';
import {INgForwardJQuery} from '../../../../node_modules/ng-forward/cjs/util/jqlite-extensions.d';
let htmlTemplate = '<profile-view [profile]="ctrl.profile"></profile-view>'
describe('Profile View Component', () => {
beforeEach(angular.mock.module('templates'))
@Component({
selector: 'test-profile-view-container',
directives: [ProfileView],
providers: helpers.provideFilters('translateFilter'),
template: htmlTemplate
})
class ProfileViewContainer {
profile: any = {
id: 1,
identifier: 'scarlet',
type: 'Profile',
name: 'Scarlet',
created_at: '2016-03-11'
}
}
it('render main content profile view', (done: Function) => {
helpers.createComponentFromClass(ProfileViewContainer).then((fixture) => {
expect(fixture.debugElement.query('div.profile-view').length).toEqual(1);
done();
})
.catch((e) => {
fail(e.message);
done();
});
});
it('render profile data', (done: Function) => {
helpers.createComponentFromClass(ProfileViewContainer).then((fixture) => {
let nameTag: INgForwardJQuery = fixture.debugElement.query('header > h2');
let container: ProfileViewContainer = fixture.componentInstance;
expect(nameTag.length).toEqual(1);
expect(nameTag.text()).toEqual(container.profile.name);
done();
})
});
});