profile-data.component.spec.ts
2.1 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
55
56
57
58
59
60
61
62
import * as helpers from "./../../../spec/helpers";
import {Injectable, Provider, provide} from "ng-forward";
import {providers} from 'ng-forward/cjs/testing/providers';
import {ComponentFixture} from 'ng-forward/cjs/testing/test-component-builder';
import {ProfileDataComponent} from "./profile-data.component";
import {TranslateProfile} from '../../shared/pipes/translate-profile.filter';
let templateHtml = '<profile-data [profile]="ctrl.profile"></profile-data>';
describe('Profile data component', () => {
let profileMock = <noosfero.Profile>{
id: 1,
name: 'Profile Test',
identifier: 'profile-test',
type: 'Person'
};
beforeEach(() => {
angular.mock.module("templates");
angular.mock.module("angularMoment");
providers((provide: any) => {
return <any>helpers.provideFilters('TranslateProfile', 'translateFilter');
});
});
let buildComponent = (): Promise<ComponentFixture> => {
return helpers.quickCreateComponent({
directives: [ProfileDataComponent],
template: templateHtml,
properties: {
profile: profileMock
}
});
};
it('renders profile-data directive', () => {
buildComponent().then((fixture: ComponentFixture) => {
let profileData: ProfileDataComponent = fixture.debugElement.componentViewChildren[0].componentInstance;
expect(fixture.debugElement.query('div.table-responsive').length).toEqual(1);
expect(fixture.debugElement.query('span.label-info').length).toEqual(1);
});
});
it('renders profile-data directive with custom fields', () => {
profileMock.additional_data = {
'Address': 'Street A, Number 102'
};
buildComponent().then((fixture: ComponentFixture) => {
let profileData: ProfileDataComponent = fixture.debugElement.componentViewChildren[0].componentInstance;
profileData.profile = profileMock;
expect(fixture.debugElement.query('div.profile-custom-fields').length).toEqual(1);
});
});
});