register.component.spec.ts
1.93 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
import { ComponentTestHelper, createClass } from "../../spec/component-test-helper";
import * as helpers from "../../spec/helpers";
import { RegisterComponent } from "./register.component";
// import {RegisterService} from "../../lib/ng-noosfero-api/http/register.service"
describe("Register Component", () => {
const htmlTemplate: string = '<noosfero-register></noosfero-register>';
let helper: ComponentTestHelper<RegisterComponent>;
let registerService = helpers.mocks.registerService;
let stateService = jasmine.createSpyObj("$state", ["transitionTo"]);
let notificationService = helpers.mocks.notificationService;
notificationService.success = jasmine.createSpy('success');
notificationService.error = jasmine.createSpy('error');
let account: any = {
id: 1,
login: 'test',
email: 'test@email.com',
password: 'xxx',
passwordConfirmation: 'xxx'
};
beforeEach(() => {
angular.mock.module('templates');
angular.mock.module('ngSanitize');
angular.mock.module('ngMessages');
angular.mock.module('ngPassword');
});
beforeEach((done) => {
let cls = createClass({
template: htmlTemplate,
directives: [RegisterComponent],
providers: [
helpers.createProviderToValue('$state', stateService),
helpers.createProviderToValue('$uibModal', helpers.mocks.$modal),
helpers.createProviderToValue('RegisterService', registerService),
helpers.createProviderToValue('NotificationService', notificationService),
helpers.createProviderToValue('EnvironmentService', helpers.mocks.environmentService)
]
});
helper = new ComponentTestHelper<RegisterComponent>(cls, done);
});
it('register page was rendered', () => {
expect(helper.debugElement.query('div.register-page').length).toEqual(1);
});
});