Add content tests to AppComponent
[portal/nonrtric-controlpanel.git] / webapp-frontend / src / app / app.component.spec.ts
1 /*-
2  * ========================LICENSE_START=================================
3  * O-RAN-SC
4  * %%
5  * Copyright (C) 2019 AT&T Intellectual Property
6  * %%
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ========================LICENSE_END===================================
19  */
20 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
21 import { TestBed, async, ComponentFixture } from '@angular/core/testing';
22 import { RouterTestingModule } from '@angular/router/testing';
23 import { CookieService } from 'ngx-cookie';
24 import { AppComponent } from './app.component';
25 import { UiService } from './services/ui/ui.service';
26
27 describe('AppComponent', () => {
28   let fixture: ComponentFixture<AppComponent>;
29
30   beforeEach(async(() => {
31     const cookieSpy = jasmine.createSpyObj('CookieService', [ 'get' ]);
32     TestBed.configureTestingModule({
33       imports: [
34         RouterTestingModule
35       ],
36       schemas: [
37         CUSTOM_ELEMENTS_SCHEMA
38       ],
39       declarations: [
40         AppComponent
41       ],
42       providers: [
43         { provide: CookieService, useValue: cookieSpy },
44         UiService
45       ]
46     }).compileComponents();
47   }));
48
49   beforeEach(() => {
50     fixture = TestBed.createComponent(AppComponent);
51     fixture.detectChanges();
52   });
53
54   it('should create the app', () => {
55     const app = fixture.componentInstance;
56     expect(app).toBeTruthy();
57   });
58
59   describe('#content', () => {
60     it('should contain oran logo', async(() => {
61       const ele = fixture.debugElement.nativeElement.querySelector('img');
62       expect(ele.src).toContain('assets/oran-logo.png');
63     }));
64
65     it('should contain heading', async(() => {
66       const ele = fixture.debugElement.nativeElement.querySelector('tspan');
67       expect(ele.textContent.trim()).toBe('Non-RT RIC Control Panel');
68     }));
69
70     it('should contain router-outlet', async(() => {
71       const ele = fixture.debugElement.nativeElement.querySelector('router-outlet');
72       expect(ele).toBeTruthy();
73     }));
74
75     it('should contain nrcp-footer', async(() => {
76       const ele = fixture.debugElement.nativeElement.querySelector('nrcp-footer');
77       expect(ele).toBeTruthy();
78     }));
79   });
80 });