"...shared-renderer/components/json-renderer.component.html" did not exist on "763be760fce3262aaf3a271b918abe5e67a644e6"
Newer
Older
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import { Component, Input } from '@angular/core';
import { TestBed, waitForAsync, ComponentFixture } from '@angular/core/testing';
import { RouterTestingModule } from '@angular/router/testing';
import { of } from 'rxjs';
import { provideMockStore, MockStore } from '@ngrx/store/testing';
import { DocumentationComponent } from './documentation.component';
import { AppConfigService } from 'src/app/app-config.service';
import * as authActions from 'src/app/auth/auth.actions';
import { Attribute } from '../../../metamodel/models';
import * as attributeActions from '../../../metamodel/actions/attribute.actions';
describe('DocumentationComponent', () => {
@Component({ selector: 'app-spinner', template: '' })
class SpinnerStubComponent { }
@Component({ selector: '<app-output-list', template: '' })
class OutputListStubComponent {
@Input() datasetSelected: string;
@Input() attributeList: Attribute[];
}
let component: DocumentationComponent;
let fixture: ComponentFixture<DocumentationComponent>;
let store: MockStore;
let config: AppConfigService
beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [RouterTestingModule],
declarations: [
DocumentationComponent,
SpinnerStubComponent,
OutputListStubComponent
],
providers: [
provideMockStore({ }),
AppConfigService
]
}).compileComponents();
fixture = TestBed.createComponent(DocumentationComponent);
component = fixture.componentInstance;
store = TestBed.inject(MockStore);
config = TestBed.inject(AppConfigService);
}));
it('should create the component', () => {
expect(component).toBeDefined();
});
it('should execute ngOnInit lifecycle', () => {
const spy = jest.spyOn(store, 'dispatch');
component.ngOnInit();
expect(spy).toHaveBeenCalledTimes(1);
expect(spy).toHaveBeenCalledWith(attributeActions.loadAttributeList());
});
it('#getUrlServer() should return server URL address', () => {
// console.log(component.getUrlServer());
expect(component.getUrlServer()).toBeTruthy();
});
// it('login() should dispatch login action', () => {
// const spy = jest.spyOn(store, 'dispatch');
// component.login();
// expect(spy).toHaveBeenCalledTimes(1);
// expect(spy).toHaveBeenCalledWith(authActions.login());
// });
//
// it('logout() should dispatch logout action', () => {
// const spy = jest.spyOn(store, 'dispatch');
// component.logout();
// expect(spy).toHaveBeenCalledTimes(1);
// expect(spy).toHaveBeenCalledWith(authActions.logout());
// });
//
// it('openEditProfile() should dispatch open edit profile action', () => {
// const spy = jest.spyOn(store, 'dispatch');
// component.openEditProfile();
// expect(spy).toHaveBeenCalledTimes(1);
// expect(spy).toHaveBeenCalledWith(authActions.openEditProfile());
// });
//
// it('isAnisAdmin() should return observable true if user is authenticated', () => {
// component.userRoles = of(['user']);
// component.isAnisAdmin().subscribe(isAuthenticated => expect(isAuthenticated).toBeFalsy());
// component.userRoles = of(['user', 'anis_admin']);
// component.isAnisAdmin().subscribe(isAuthenticated => expect(isAuthenticated).toBeTruthy());
// });
});