From 0b3b6d470c10e4fc1b2671fc04386af13433568a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ma=C3=ABl=20AUDEON?= <mael.audeon@teamdlab.com> Date: Fri, 7 Aug 2020 15:16:11 +0200 Subject: [PATCH] [TRTL-206] Fix frontend unit tests --- ui/ui-frontend-common/src/app/modules/index.ts | 1 + .../group/group-list/group-list.component.spec.ts | 12 +++++++++--- .../identity/src/app/group/group.component.spec.ts | 9 +++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ui/ui-frontend-common/src/app/modules/index.ts b/ui/ui-frontend-common/src/app/modules/index.ts index d6684996..8662db55 100644 --- a/ui/ui-frontend-common/src/app/modules/index.ts +++ b/ui/ui-frontend-common/src/app/modules/index.ts @@ -88,6 +88,7 @@ export * from './components/role-toggle/index'; export * from './components/search-bar/index'; export * from './components/stepper/index'; export * from './components/table-filter/index'; +export * from './components/order-by-button/index'; export * from './directives/collapse/index'; export * from './directives/drag-and-drop/index'; diff --git a/ui/ui-frontend/projects/identity/src/app/group/group-list/group-list.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/group/group-list/group-list.component.spec.ts index 1f9b3436..8d7103a9 100644 --- a/ui/ui-frontend/projects/identity/src/app/group/group-list/group-list.component.spec.ts +++ b/ui/ui-frontend/projects/identity/src/app/group/group-list/group-list.component.spec.ts @@ -43,9 +43,10 @@ import { MatProgressSpinnerModule } from '@angular/material/progress-spinner'; import { By } from '@angular/platform-browser'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { Router } from '@angular/router'; -import { of, Subject } from 'rxjs'; +import {of, Subject} from 'rxjs'; -import { Group } from 'ui-frontend-common'; +import {Group, TableFilterModule} from 'ui-frontend-common'; +import {OrderByButtonModule} from 'ui-frontend-common'; import { InfiniteScrollStubDirective, VitamUICommonTestModule } from 'ui-frontend-common/testing'; import { GroupService } from '../group.service'; import { GroupListComponent } from './group-list.component'; @@ -82,6 +83,7 @@ class Page { let page: Page; let groups: Group[]; +const levels: string[] = ['level1', 'level2']; describe('GroupListComponent', () => { @@ -116,7 +118,8 @@ describe('GroupListComponent', () => { search: () => of(groups), canLoadMore: true, loadMore: () => of(groups), - updated: new Subject() + updated: new Subject(), + getNonEmptyLevels: () => of(levels) }; const matDialogSpy = jasmine.createSpyObj('MatDialog', ['open']); const routerSpy = jasmine.createSpyObj('Router', ['navigate']); @@ -127,6 +130,8 @@ describe('GroupListComponent', () => { MatProgressSpinnerModule, NoopAnimationsModule, VitamUICommonTestModule, + TableFilterModule, + OrderByButtonModule ], declarations: [ GroupListComponent, @@ -145,6 +150,7 @@ describe('GroupListComponent', () => { const groupService = TestBed.get(GroupService); spyOn(groupService, 'search').and.callThrough(); spyOn(groupService, 'loadMore').and.callThrough(); + spyOn(groupService, 'getNonEmptyLevels').and.callFake(groupListServiceSpy.getNonEmptyLevels); })); diff --git a/ui/ui-frontend/projects/identity/src/app/group/group.component.spec.ts b/ui/ui-frontend/projects/identity/src/app/group/group.component.spec.ts index 628c73bc..ed1512d8 100644 --- a/ui/ui-frontend/projects/identity/src/app/group/group.component.spec.ts +++ b/ui/ui-frontend/projects/identity/src/app/group/group.component.spec.ts @@ -36,11 +36,11 @@ */ /* tslint:disable:no-magic-numbers no-use-before-declare max-classes-per-file */ -import { Component, Input } from '@angular/core'; +import {Component, Input} from '@angular/core'; import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { ActivatedRoute } from '@angular/router'; import { EMPTY, of } from 'rxjs'; -import { ENVIRONMENT, Group, InjectorModule, LoggerModule } from 'ui-frontend-common'; +import {ENVIRONMENT, Group, InjectorModule, LoggerModule, SearchBarModule} from 'ui-frontend-common'; import { environment } from './../../environments/environment'; import { MatDialog } from '@angular/material/dialog'; @@ -65,6 +65,10 @@ let page: Page; @Component({ selector: 'app-group-list', template: '' }) class GroupListStubComponent { + + // tslint:disable-next-line:no-input-rename + @Input('search') searchText: string; + search() { } } @@ -87,6 +91,7 @@ describe('GroupComponent', () => { NoopAnimationsModule, VitamUICommonTestModule, InjectorModule, + SearchBarModule, LoggerModule.forRoot() ], declarations: [ -- GitLab