blob: bf13589b9712fea5caeee987880d10f3735503ab [file] [log] [blame]
Sean Condon2aa86092018-07-16 09:04:05 +01001/*
2 * Copyright 2018-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16import { async, ComponentFixture, TestBed } from '@angular/core/testing';
17import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
18import { DebugElement } from '@angular/core';
19import { By } from '@angular/platform-browser';
prai9d445962018-07-27 13:27:43 +053020import { LionService } from '../../../fw/util/lion.service';
Sean Condon2aa86092018-07-16 09:04:05 +010021
22import { ConsoleLoggerService } from '../../../consolelogger.service';
23import { LogService } from '../../../log.service';
24import { ConfirmComponent } from './confirm.component';
25
26/**
27 * ONOS GUI -- Layer -- Confirm Component - Unit Tests
28 */
29describe('ConfirmComponent', () => {
30 let log: LogService;
31 let component: ConfirmComponent;
32 let fixture: ComponentFixture<ConfirmComponent>;
prai9d445962018-07-27 13:27:43 +053033 const bundleObj = {
34 'core.view.App': {
35 test: 'test1'
36 }
37 };
38 const mockLion = (key) => {
39 return bundleObj[key] || '%' + key + '%';
40 };
Sean Condon2aa86092018-07-16 09:04:05 +010041
42 beforeEach(async(() => {
43 log = new ConsoleLoggerService();
44 TestBed.configureTestingModule({
45 imports: [ BrowserAnimationsModule ],
46 declarations: [ ConfirmComponent ],
47 providers: [
48 { provide: LogService, useValue: log },
prai9d445962018-07-27 13:27:43 +053049 {
50 provide: LionService, useFactory: (() => {
51 return {
52 bundle: ((bundleId) => mockLion),
53 ubercache: new Array(),
54 loadCbs: new Map<string, () => void>([])
55 };
56 })
57 },
Sean Condon2aa86092018-07-16 09:04:05 +010058 ]
59 });
60 }));
61
62 beforeEach(() => {
63 fixture = TestBed.createComponent(ConfirmComponent);
64 component = fixture.debugElement.componentInstance;
65 fixture.detectChanges();
66 });
67
68 it('should create', () => {
69 expect(component).toBeTruthy();
70 });
71
prai9d445962018-07-27 13:27:43 +053072 it('should have a h3 inside a div#app-dialog', () => {
73 const appDe: DebugElement = fixture.debugElement;
74 const divDe = appDe.query(By.css('div#app-dialog h3'));
75 const div: HTMLElement = divDe.nativeElement;
76 expect(div.textContent).toEqual(' %dlg_confirm_action% ');
77 });
78
Sean Condon2aa86092018-07-16 09:04:05 +010079 it('should have a div.dialog-button inside a div#app-dialog', () => {
80 const appDe: DebugElement = fixture.debugElement;
81 const divDe = appDe.query(By.css('div#app-dialog div.dialog-button'));
82 const div: HTMLElement = divDe.nativeElement;
83 // It selects the first one
84 expect(div.textContent).toEqual('OK');
85 });
86});