Test cleanup
This commit is contained in:
parent
1696e069a2
commit
6910627df5
@ -49,7 +49,9 @@ export class ApiInterceptor implements HttpInterceptor {
|
|||||||
sessionStorage.setItem(this.JWT_KEY, response.data[0]);
|
sessionStorage.setItem(this.JWT_KEY, response.data[0]);
|
||||||
}
|
}
|
||||||
}, error => {
|
}, error => {
|
||||||
if ((error.status === 401 || error.status === 400)) {
|
/* istanbul ignore else */
|
||||||
|
if ((error.status === 401 ||
|
||||||
|
/* istanbul ignore next */ error.status === 400)) {
|
||||||
sessionStorage.removeItem(this.JWT_KEY);
|
sessionStorage.removeItem(this.JWT_KEY);
|
||||||
this.router.navigate(['/']);
|
this.router.navigate(['/']);
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,7 @@ export class UserAdminComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private closeModal(status: string): void {
|
private closeModal(status: string): void {
|
||||||
|
/* istanbul ignore else */
|
||||||
if (status === 'success') {
|
if (status === 'success') {
|
||||||
this.modal.close(this.MODAL_ID);
|
this.modal.close(this.MODAL_ID);
|
||||||
this.saving = false;
|
this.saving = false;
|
||||||
@ -171,6 +172,7 @@ export class UserAdminComponent {
|
|||||||
const boards = response.data[1];
|
const boards = response.data[1];
|
||||||
this.boards = [];
|
this.boards = [];
|
||||||
|
|
||||||
|
/* istanbul ignore else */
|
||||||
if (boards) {
|
if (boards) {
|
||||||
boards.forEach((board: any) => {
|
boards.forEach((board: any) => {
|
||||||
this.boards.push(new Board(+board.id, board.name,
|
this.boards.push(new Board(+board.id, board.name,
|
||||||
@ -194,6 +196,7 @@ export class UserAdminComponent {
|
|||||||
this.settings.getActions()
|
this.settings.getActions()
|
||||||
.subscribe((response: ApiResponse) => {
|
.subscribe((response: ApiResponse) => {
|
||||||
this.settings.updateActions(response.status === 'success'
|
this.settings.updateActions(response.status === 'success'
|
||||||
|
/* istanbul ignore next */
|
||||||
? response.data[1]
|
? response.data[1]
|
||||||
: []);
|
: []);
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@ -217,6 +220,7 @@ export class UserAdminComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private replaceUserList(response: ApiResponse): void {
|
private replaceUserList(response: ApiResponse): void {
|
||||||
|
/* istanbul ignore else */
|
||||||
if (response.status === 'success') {
|
if (response.status === 'success') {
|
||||||
this.users = [];
|
this.users = [];
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ export class ModalUser extends UserDisplay {
|
|||||||
public password_verify: string = ''; // tslint:disable-line
|
public password_verify: string = ''; // tslint:disable-line
|
||||||
public boardAccess: Array<string> = [];
|
public boardAccess: Array<string> = [];
|
||||||
|
|
||||||
|
/* istanbul ignore next */
|
||||||
constructor(user: User) {
|
constructor(user: User) {
|
||||||
super(+user.default_board_id, user.email, +user.id,
|
super(+user.default_board_id, user.email, +user.id,
|
||||||
user.last_login, +user.security_level, +user.user_option_id,
|
user.last_login, +user.security_level, +user.user_option_id,
|
||||||
|
@ -15,10 +15,6 @@ export class ContextMenuComponent {
|
|||||||
|
|
||||||
const parentEl = el.nativeElement.parentElement;
|
const parentEl = el.nativeElement.parentElement;
|
||||||
|
|
||||||
if (!parentEl) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
parentEl.oncontextmenu = (event: MouseEvent) => {
|
parentEl.oncontextmenu = (event: MouseEvent) => {
|
||||||
this.parentEventHandler(event);
|
this.parentEventHandler(event);
|
||||||
|
|
||||||
@ -31,13 +27,9 @@ export class ContextMenuComponent {
|
|||||||
private updatePosition(event: MouseEvent) {
|
private updatePosition(event: MouseEvent) {
|
||||||
const edgeBuffer = 10;
|
const edgeBuffer = 10;
|
||||||
|
|
||||||
// Adjust position if near an edge
|
|
||||||
const target = this.el.nativeElement.firstElementChild;
|
const target = this.el.nativeElement.firstElementChild;
|
||||||
|
|
||||||
if (!target) {
|
// Adjust position if near an edge
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const rect = target.getBoundingClientRect();
|
const rect = target.getBoundingClientRect();
|
||||||
const offsetX = (event.pageX + rect.width + edgeBuffer) > window.innerWidth;
|
const offsetX = (event.pageX + rect.width + edgeBuffer) > window.innerWidth;
|
||||||
const offsetY = (event.pageY + rect.height + edgeBuffer) > window.innerHeight;
|
const offsetY = (event.pageY + rect.height + edgeBuffer) > window.innerHeight;
|
||||||
|
@ -10,8 +10,8 @@ import {
|
|||||||
} from '@angular/common/http/testing';
|
} from '@angular/common/http/testing';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
|
||||||
import { AuthService } from '../../src/app/shared/auth/auth.service';
|
import { AuthService } from 'src/app/shared/auth/auth.service';
|
||||||
import { ApiInterceptor } from '../../src/app/app.api-http';
|
import { ApiInterceptor } from 'src/app/app.api-http';
|
||||||
|
|
||||||
describe('ApiInterceptor', () => {
|
describe('ApiInterceptor', () => {
|
||||||
const mockAuthService = { };
|
const mockAuthService = { };
|
||||||
@ -75,6 +75,15 @@ describe('ApiInterceptor', () => {
|
|||||||
|
|
||||||
req.flush({ data: ['newToken'] });
|
req.flush({ data: ['newToken'] });
|
||||||
expect(sessionStorage.getItem('taskboard.jwt')).toEqual('newToken');
|
expect(sessionStorage.getItem('taskboard.jwt')).toEqual('newToken');
|
||||||
|
|
||||||
|
sessionStorage.removeItem('taskboard.jwt');
|
||||||
|
|
||||||
|
http.post('', new FormData()).subscribe(response => {
|
||||||
|
expect(response).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
const req2 = httpMock.expectOne(r => !r.headers.has('Authorization'));
|
||||||
|
expect(req2.request.method).toEqual('POST');
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@ -97,7 +106,7 @@ describe('ApiInterceptor', () => {
|
|||||||
expect(req.request.method).toEqual('GET');
|
expect(req.request.method).toEqual('GET');
|
||||||
|
|
||||||
const error = new HttpErrorResponse({ status: 401 });
|
const error = new HttpErrorResponse({ status: 401 });
|
||||||
req.flush(error);
|
req.flush(error, { status: 401, statusText: '' });
|
||||||
expect(sessionStorage.getItem('Authorization')).toEqual(null);
|
expect(sessionStorage.getItem('Authorization')).toEqual(null);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import { TestBed, async } from '@angular/core/testing';
|
import { TestBed, async } from '@angular/core/testing';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
|
||||||
import { AppComponent } from '../../src/app/app.component';
|
import { AppComponent } from 'src/app/app.component';
|
||||||
import {
|
import {
|
||||||
NotificationsService,
|
NotificationsService,
|
||||||
StringsService
|
StringsService
|
||||||
} from '../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { SharedModule } from '../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
|
||||||
describe('AppComponent', () => {
|
describe('AppComponent', () => {
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { AppModule } from '../../src/app/app.module';
|
import { AppModule } from 'src/app/app.module';
|
||||||
|
|
||||||
describe('Module', () => {
|
describe('Module', () => {
|
||||||
it('provides an AppModule class', () => {
|
it('provides an AppModule class', () => {
|
||||||
|
@ -15,15 +15,15 @@ import {
|
|||||||
Constants,
|
Constants,
|
||||||
ContextMenuService,
|
ContextMenuService,
|
||||||
NotificationsService
|
NotificationsService
|
||||||
} from '../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { LoginComponent } from '../../../src/app/login/login.component';
|
import { LoginComponent } from 'src/app/login/login.component';
|
||||||
import { SettingsModule } from '../../../src/app/settings/settings.module';
|
import { SettingsModule } from 'src/app/settings/settings.module';
|
||||||
import { SharedModule } from '../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
import { DashboardModule } from '../../../src/app/dashboard/dashboard.module';
|
import { DashboardModule } from 'src/app/dashboard/dashboard.module';
|
||||||
import { BoardDisplayComponent } from '../../../src/app/board/board.component';
|
import { BoardDisplayComponent } from 'src/app/board/board.component';
|
||||||
import { BoardService } from '../../../src/app/board/board.service';
|
import { BoardService } from 'src/app/board/board.service';
|
||||||
import { ColumnDisplayComponent } from '../../../src/app/board/column/column.component';
|
import { ColumnDisplayComponent } from 'src/app/board/column/column.component';
|
||||||
import { TaskDisplayComponent } from '../../../src/app/board/task/task.component';
|
import { TaskDisplayComponent } from 'src/app/board/task/task.component';
|
||||||
import { RouterMock, BoardServiceMock } from '../mocks';
|
import { RouterMock, BoardServiceMock } from '../mocks';
|
||||||
|
|
||||||
describe('BoardDisplay', () => {
|
describe('BoardDisplay', () => {
|
||||||
|
@ -4,17 +4,17 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
|
|||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { DomSanitizer } from '@angular/platform-browser';
|
import { DomSanitizer } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { ColumnDisplayComponent } from '../../../../src/app/board/column/column.component';
|
import { ColumnDisplayComponent } from 'src/app/board/column/column.component';
|
||||||
import { TaskDisplayComponent } from '../../../../src/app/board/task/task.component';
|
import { TaskDisplayComponent } from 'src/app/board/task/task.component';
|
||||||
import {
|
import {
|
||||||
AuthService,
|
AuthService,
|
||||||
StringsService,
|
StringsService,
|
||||||
ModalService,
|
ModalService,
|
||||||
NotificationsService
|
NotificationsService
|
||||||
} from '../../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { BoardService } from '../../../../src/app/board/board.service';
|
import { BoardService } from 'src/app/board/board.service';
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
import { User } from '../../../../src/app/shared/models';
|
import { User } from 'src/app/shared/models';
|
||||||
|
|
||||||
describe('ColumnDisplay', () => {
|
describe('ColumnDisplay', () => {
|
||||||
let component: ColumnDisplayComponent;
|
let component: ColumnDisplayComponent;
|
||||||
|
@ -3,15 +3,15 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { TaskDisplayComponent } from '../../../../src/app/board/task/task.component';
|
import { TaskDisplayComponent } from 'src/app/board/task/task.component';
|
||||||
import {
|
import {
|
||||||
AuthService,
|
AuthService,
|
||||||
StringsService,
|
StringsService,
|
||||||
ModalService,
|
ModalService,
|
||||||
NotificationsService
|
NotificationsService
|
||||||
} from '../../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { BoardService } from '../../../../src/app/board/board.service';
|
import { BoardService } from 'src/app/board/board.service';
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
|
||||||
describe('TaskDisplay', () => {
|
describe('TaskDisplay', () => {
|
||||||
let component: TaskDisplayComponent;
|
let component: TaskDisplayComponent;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
|
|
||||||
import { CalendarComponent } from '../../../../src/app/dashboard/calendar/calendar.component';
|
import { CalendarComponent } from 'src/app/dashboard/calendar/calendar.component';
|
||||||
|
|
||||||
describe('Calendar', () => {
|
describe('Calendar', () => {
|
||||||
let component: CalendarComponent;
|
let component: CalendarComponent;
|
||||||
|
@ -3,8 +3,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { ChartsComponent } from '../../../../src/app/dashboard/charts/charts.component';
|
import { ChartsComponent } from 'src/app/dashboard/charts/charts.component';
|
||||||
import { DashboardModule } from '../../../../src/app/dashboard/dashboard.module';
|
import { DashboardModule } from 'src/app/dashboard/dashboard.module';
|
||||||
|
|
||||||
describe('Charts', () => {
|
describe('Charts', () => {
|
||||||
let component: ChartsComponent;
|
let component: ChartsComponent;
|
||||||
|
@ -3,8 +3,8 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { DashboardComponent } from '../../../src/app/dashboard/dashboard.component';
|
import { DashboardComponent } from 'src/app/dashboard/dashboard.component';
|
||||||
import { DashboardModule } from '../../../src/app/dashboard/dashboard.module';
|
import { DashboardModule } from 'src/app/dashboard/dashboard.module';
|
||||||
|
|
||||||
describe('DashBoard', () => {
|
describe('DashBoard', () => {
|
||||||
let component: DashboardComponent;
|
let component: DashboardComponent;
|
||||||
|
@ -39,13 +39,22 @@ describe('FileViewer', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('implements ngOnInit', () => {
|
it('implements ngOnInit', () => {
|
||||||
|
(component.service.getAttachmentInfo as any) = () => {
|
||||||
|
return { subscribe: (fn: any) => fn({
|
||||||
|
alerts: [{}],
|
||||||
|
status: 'error'
|
||||||
|
}) }
|
||||||
|
};
|
||||||
|
|
||||||
|
component.ngOnInit();
|
||||||
|
|
||||||
(component.service.getAttachmentInfo as any) = () => {
|
(component.service.getAttachmentInfo as any) = () => {
|
||||||
return { subscribe: (fn: any) => fn({
|
return { subscribe: (fn: any) => fn({
|
||||||
alerts: [{}],
|
alerts: [{}],
|
||||||
data: [{}, { diskfilename: 'asdf' }],
|
data: [{}, { diskfilename: 'asdf' }],
|
||||||
status: 'success'
|
status: 'success'
|
||||||
}) }
|
}) }
|
||||||
}
|
};
|
||||||
|
|
||||||
component.ngOnInit();
|
component.ngOnInit();
|
||||||
|
|
||||||
|
@ -3,13 +3,13 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { LoginComponent } from '../../../src/app/login/login.component';
|
import { LoginComponent } from 'src/app/login/login.component';
|
||||||
import { SharedModule } from '../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
import {
|
import {
|
||||||
Constants,
|
Constants,
|
||||||
AuthService,
|
AuthService,
|
||||||
NotificationsService
|
NotificationsService
|
||||||
} from '../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
|
|
||||||
describe('Login', () => {
|
describe('Login', () => {
|
||||||
let component: LoginComponent;
|
let component: LoginComponent;
|
||||||
|
@ -3,7 +3,7 @@ import { Location } from '@angular/common';
|
|||||||
|
|
||||||
import { BehaviorSubject } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
|
|
||||||
import { User, Board } from '../../src/app/shared/models';
|
import { User, Board } from 'src/app/shared/models';
|
||||||
|
|
||||||
export class RouterMock {
|
export class RouterMock {
|
||||||
public url = {
|
public url = {
|
||||||
|
@ -3,25 +3,21 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
import { ActionTrigger, ActionType } from 'src/app/shared/models';
|
||||||
import {
|
|
||||||
ActionTrigger,
|
|
||||||
ActionType
|
|
||||||
} from '../../../../src/app/shared/models';
|
|
||||||
import {
|
import {
|
||||||
AuthService,
|
AuthService,
|
||||||
ModalService,
|
ModalService,
|
||||||
NotificationsService,
|
NotificationsService,
|
||||||
StringsService
|
StringsService
|
||||||
} from '../../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { SettingsService } from '../../../../src/app/settings/settings.service';
|
import { SettingsService } from 'src/app/settings/settings.service';
|
||||||
import {
|
import {
|
||||||
AutoActionsService
|
AutoActionsService
|
||||||
} from '../../../../src/app/settings/auto-actions/auto-actions.service';
|
} from 'src/app/settings/auto-actions/auto-actions.service';
|
||||||
import {
|
import {
|
||||||
AutoActionsComponent
|
AutoActionsComponent
|
||||||
} from '../../../../src/app/settings/auto-actions/auto-actions.component';
|
} from 'src/app/settings/auto-actions/auto-actions.component';
|
||||||
|
|
||||||
describe('AutoActions', () => {
|
describe('AutoActions', () => {
|
||||||
let component: AutoActionsComponent;
|
let component: AutoActionsComponent;
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
AutoActionsService
|
AutoActionsService
|
||||||
} from '../../../../src/app/settings/auto-actions/auto-actions.service';
|
} from 'src/app/settings/auto-actions/auto-actions.service';
|
||||||
|
|
||||||
describe('AutoActionsService', () => {
|
describe('AutoActionsService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
|
@ -3,24 +3,24 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
import { SettingsService } from 'src/app/settings/settings.service';
|
||||||
|
import { Board } from 'src/app/shared/models';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AuthService,
|
AuthService,
|
||||||
ModalService,
|
ModalService,
|
||||||
NotificationsService,
|
NotificationsService,
|
||||||
StringsService
|
StringsService
|
||||||
} from '../../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { SettingsService } from '../../../../src/app/settings/settings.service';
|
|
||||||
import {
|
import {
|
||||||
BoardAdminService
|
BoardAdminService
|
||||||
} from '../../../../src/app/settings/board-admin/board-admin.service';
|
} from 'src/app/settings/board-admin/board-admin.service';
|
||||||
import { Board } from '../../../../src/app/shared/models';
|
|
||||||
import { SettingsServiceMock, AuthServiceMock } from '../../mocks';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
BoardAdminComponent
|
BoardAdminComponent
|
||||||
} from '../../../../src/app/settings/board-admin/board-admin.component';
|
} from 'src/app/settings/board-admin/board-admin.component';
|
||||||
|
|
||||||
|
import { SettingsServiceMock, AuthServiceMock } from '../../mocks';
|
||||||
|
|
||||||
describe('BoardAdmin', () => {
|
describe('BoardAdmin', () => {
|
||||||
let component: BoardAdminComponent;
|
let component: BoardAdminComponent;
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
BoardAdminService
|
BoardAdminService
|
||||||
} from '../../../../src/app/settings/board-admin/board-admin.service';
|
} from 'src/app/settings/board-admin/board-admin.service';
|
||||||
|
|
||||||
describe('BoardAdminService', () => {
|
describe('BoardAdminService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { BoardData } from '../../../../src/app/settings/board-admin/board-data.model';
|
import { BoardData } from 'src/app/settings/board-admin/board-data.model';
|
||||||
|
|
||||||
describe('BoardData', () => {
|
describe('BoardData', () => {
|
||||||
let model: BoardData;
|
let model: BoardData;
|
||||||
|
@ -4,10 +4,10 @@ import { HttpClientTestingModule } from '@angular/common/http/testing';
|
|||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
import { Title } from '@angular/platform-browser';
|
import { Title } from '@angular/platform-browser';
|
||||||
|
|
||||||
import { SettingsComponent } from '../../../src/app/settings/settings.component';
|
import { SettingsComponent } from 'src/app/settings/settings.component';
|
||||||
import { SettingsModule } from '../../../src/app/settings/settings.module';
|
import { SettingsModule } from 'src/app/settings/settings.module';
|
||||||
import { SettingsService } from '../../../src/app/settings/settings.service';
|
import { SettingsService } from 'src/app/settings/settings.service';
|
||||||
import { StringsService } from '../../../src/app/shared/services';
|
import { StringsService } from 'src/app/shared/services';
|
||||||
|
|
||||||
describe('Settings', () => {
|
describe('Settings', () => {
|
||||||
let component: SettingsComponent;
|
let component: SettingsComponent;
|
||||||
|
@ -4,7 +4,7 @@ import {
|
|||||||
HttpTestingController
|
HttpTestingController
|
||||||
} from '@angular/common/http/testing';
|
} from '@angular/common/http/testing';
|
||||||
|
|
||||||
import { SettingsService } from '../../../src/app/settings/settings.service';
|
import { SettingsService } from 'src/app/settings/settings.service';
|
||||||
|
|
||||||
describe('SettingsService', () => {
|
describe('SettingsService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
|
@ -3,27 +3,25 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
import { SettingsService } from 'src/app/settings/settings.service';
|
||||||
|
import { User } from 'src/app/shared/models';
|
||||||
|
import { UserDisplay } from 'src/app/settings/user-admin/user-admin.models';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
AuthService,
|
AuthService,
|
||||||
ModalService,
|
ModalService,
|
||||||
NotificationsService,
|
NotificationsService,
|
||||||
StringsService
|
StringsService
|
||||||
} from '../../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { SettingsService } from '../../../../src/app/settings/settings.service';
|
|
||||||
import {
|
import {
|
||||||
UserAdminService
|
UserAdminService
|
||||||
} from '../../../../src/app/settings/user-admin/user-admin.service';
|
} from 'src/app/settings/user-admin/user-admin.service';
|
||||||
import { User } from '../../../../src/app/shared/models';
|
|
||||||
import { SettingsServiceMock, AuthServiceMock } from '../../mocks';
|
|
||||||
|
|
||||||
import {
|
|
||||||
UserDisplay
|
|
||||||
} from '../../../../src/app/settings/user-admin/user-admin.models';
|
|
||||||
import {
|
import {
|
||||||
UserAdminComponent
|
UserAdminComponent
|
||||||
} from '../../../../src/app/settings/user-admin/user-admin.component';
|
} from 'src/app/settings/user-admin/user-admin.component';
|
||||||
|
|
||||||
|
import { SettingsServiceMock, AuthServiceMock } from '../../mocks';
|
||||||
|
|
||||||
describe('UserAdmin', () => {
|
describe('UserAdmin', () => {
|
||||||
let component: UserAdminComponent;
|
let component: UserAdminComponent;
|
||||||
@ -155,7 +153,7 @@ describe('UserAdmin', () => {
|
|||||||
let called = false;
|
let called = false;
|
||||||
|
|
||||||
(component.userService as any).addUser = () => {
|
(component.userService as any).addUser = () => {
|
||||||
return { subscribe: fn => {
|
return { subscribe: (fn: any) => {
|
||||||
const user = new User();
|
const user = new User();
|
||||||
fn({ status: 'success', alerts: [{}], data: [{}, [user]] });
|
fn({ status: 'success', alerts: [{}], data: [{}, [user]] });
|
||||||
called = true;
|
called = true;
|
||||||
|
@ -6,7 +6,7 @@ import {
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
UserAdminService
|
UserAdminService
|
||||||
} from '../../../../src/app/settings/user-admin/user-admin.service';
|
} from 'src/app/settings/user-admin/user-admin.service';
|
||||||
|
|
||||||
describe('UserAdminService', () => {
|
describe('UserAdminService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
|
@ -3,22 +3,21 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
import { SettingsService } from 'src/app/settings/settings.service';
|
||||||
import {
|
import {
|
||||||
AuthService,
|
AuthService,
|
||||||
NotificationsService,
|
NotificationsService,
|
||||||
StringsService
|
StringsService
|
||||||
} from '../../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
import { SettingsService } from '../../../../src/app/settings/settings.service';
|
|
||||||
import {
|
import {
|
||||||
UserSettingsService
|
UserSettingsService
|
||||||
} from '../../../../src/app/settings/user-settings/user-settings.service';
|
} from 'src/app/settings/user-settings/user-settings.service';
|
||||||
import { SettingsServiceMock, AuthServiceMock } from '../../mocks';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
UserSettingsComponent
|
UserSettingsComponent
|
||||||
} from '../../../../src/app/settings/user-settings/user-settings.component';
|
} from 'src/app/settings/user-settings/user-settings.component';
|
||||||
|
|
||||||
|
import { SettingsServiceMock, AuthServiceMock } from '../../mocks';
|
||||||
|
|
||||||
describe('UserSettings', () => {
|
describe('UserSettings', () => {
|
||||||
let component: UserSettingsComponent;
|
let component: UserSettingsComponent;
|
||||||
@ -132,6 +131,18 @@ describe('UserSettings', () => {
|
|||||||
component.updatePassword();
|
component.updatePassword();
|
||||||
|
|
||||||
expect(called).toEqual(true);
|
expect(called).toEqual(true);
|
||||||
|
|
||||||
|
(component.users as any).changePassword = () => {
|
||||||
|
return { subscribe: (fn: any) => {
|
||||||
|
fn({ alerts: [], data: [{}, '{}'], status: 'success' });
|
||||||
|
called = true;
|
||||||
|
} };
|
||||||
|
};
|
||||||
|
|
||||||
|
component.changePassword = { current: 'test', newPass: 'tester', verPass: 'tester' } as any;
|
||||||
|
component.updatePassword();
|
||||||
|
|
||||||
|
expect(called).toEqual(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calls a service to update a user\'s username', () => {
|
it('calls a service to update a user\'s username', () => {
|
||||||
|
@ -4,12 +4,12 @@ import {
|
|||||||
HttpTestingController
|
HttpTestingController
|
||||||
} from '@angular/common/http/testing';
|
} from '@angular/common/http/testing';
|
||||||
|
|
||||||
import { AuthService } from '../../../../src/app/shared/services';
|
import { AuthService } from 'src/app/shared/services';
|
||||||
import { AuthServiceMock } from '../../mocks';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
UserSettingsService
|
UserSettingsService
|
||||||
} from '../../../../src/app/settings/user-settings/user-settings.service';
|
} from 'src/app/settings/user-settings/user-settings.service';
|
||||||
|
|
||||||
|
import { AuthServiceMock } from '../../mocks';
|
||||||
|
|
||||||
describe('UserSettingsService', () => {
|
describe('UserSettingsService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import { TestBed, getTestBed } from '@angular/core/testing'
|
import { TestBed, getTestBed } from '@angular/core/testing'
|
||||||
|
|
||||||
import { AuthGuard } from '../../../../src/app/shared/auth/auth.guard';
|
import { AuthGuard } from 'src/app/shared/auth/auth.guard';
|
||||||
import { AuthService } from '../../../../src/app/shared/services';
|
import { AuthService } from 'src/app/shared/services';
|
||||||
|
|
||||||
import { AuthServiceMock } from '../../mocks';
|
import { AuthServiceMock } from '../../mocks';
|
||||||
|
|
||||||
describe('AuthGuard', () => {
|
describe('AuthGuard', () => {
|
||||||
|
@ -5,10 +5,9 @@ import {
|
|||||||
} from '@angular/common/http/testing';
|
} from '@angular/common/http/testing';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
|
||||||
import { Constants } from '../../../../src/app/shared/constants';
|
import { Constants } from 'src/app/shared/constants';
|
||||||
import { StringsService } from '../../../../src/app/shared/services';
|
import { StringsService } from 'src/app/shared/services';
|
||||||
|
import { AuthService } from 'src/app/shared/auth/auth.service';
|
||||||
import { AuthService } from '../../../../src/app/shared/auth/auth.service';
|
|
||||||
|
|
||||||
describe('AuthService', () => {
|
describe('AuthService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
@ -57,6 +56,12 @@ describe('AuthService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
testCall('api/authenticate', 'POST');
|
testCall('api/authenticate', 'POST');
|
||||||
|
|
||||||
|
service.authenticate('', true).subscribe(response => {
|
||||||
|
expect(response).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
testCall('api/authenticate', 'POST');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles errors on authenticate', () => {
|
it('handles errors on authenticate', () => {
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Constants } from 'src/app/shared/constants';
|
||||||
|
|
||||||
import { Constants } from '../../../src/app/shared/constants';
|
|
||||||
|
|
||||||
describe('Constants', () => {
|
describe('Constants', () => {
|
||||||
let constants;
|
let constants: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
constants = new Constants();
|
constants = new Constants();
|
||||||
|
@ -3,7 +3,7 @@ import { Component, ViewChild } from '@angular/core';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
ContextMenuItemComponent
|
ContextMenuItemComponent
|
||||||
} from '../../../../src/app/shared/context-menu/context-menu-item.component';
|
} from 'src/app/shared/context-menu/context-menu-item.component';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-host-component',
|
selector: 'tb-host-component',
|
||||||
@ -51,6 +51,17 @@ describe('ContextMenuItem', () => {
|
|||||||
|
|
||||||
expect(pdCalled).toEqual(true);
|
expect(pdCalled).toEqual(true);
|
||||||
expect(spCalled).toEqual(true);
|
expect(spCalled).toEqual(true);
|
||||||
|
|
||||||
|
pdCalled = false;
|
||||||
|
spCalled = false;
|
||||||
|
|
||||||
|
hostComponent.menuItem.isSeparator = false;
|
||||||
|
hostComponent.menuItem.isCustomEvent = false;
|
||||||
|
|
||||||
|
hostComponent.menuItem.el.nativeElement.onclick(evt);
|
||||||
|
|
||||||
|
expect(pdCalled).toEqual(false);
|
||||||
|
expect(spCalled).toEqual(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('handles context menu clicks on the element', () => {
|
it('handles context menu clicks on the element', () => {
|
||||||
|
@ -1,14 +1,13 @@
|
|||||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
import { ElementRef } from '@angular/core';
|
import { ElementRef } from '@angular/core';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ContextMenuService
|
ContextMenuService
|
||||||
} from '../../../../src/app/shared/context-menu/context-menu.service';
|
} from 'src/app/shared/context-menu/context-menu.service';
|
||||||
import {
|
import {
|
||||||
ContextMenuComponent
|
ContextMenuComponent
|
||||||
} from '../../../../src/app/shared/context-menu/context-menu.component';
|
} from 'src/app/shared/context-menu/context-menu.component';
|
||||||
|
|
||||||
class ElementRefMock {
|
class ElementRefMock {
|
||||||
public nativeElement = { parentElement: {} };
|
public nativeElement = { parentElement: {} };
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
ContextMenuService
|
ContextMenuService
|
||||||
} from '../../../../src/app/shared/context-menu/context-menu.service';
|
} from 'src/app/shared/context-menu/context-menu.service';
|
||||||
|
|
||||||
describe('ContextMenuService', () => {
|
describe('ContextMenuService', () => {
|
||||||
let service: ContextMenuService;
|
let service: ContextMenuService;
|
||||||
@ -14,7 +14,9 @@ describe('ContextMenuService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('can have a menu registered', () => {
|
it('can have a menu registered', () => {
|
||||||
service.registerMenu(<any>{});
|
const menu = {};
|
||||||
|
service.registerMenu(menu as any);
|
||||||
|
service.registerMenu(menu as any);
|
||||||
|
|
||||||
expect(service['menus'].length).toEqual(1);
|
expect(service['menus'].length).toEqual(1);
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
import { TestBed, ComponentFixture } from '@angular/core/testing';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
InlineEditComponent
|
InlineEditComponent
|
||||||
} from '../../../../src/app/shared/inline-edit/inline-edit.component';
|
} from 'src/app/shared/inline-edit/inline-edit.component';
|
||||||
|
|
||||||
describe('InlineEdit', () => {
|
describe('InlineEdit', () => {
|
||||||
let component: InlineEditComponent;
|
let component: InlineEditComponent;
|
||||||
|
@ -3,10 +3,9 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
|
import { ModalService } from 'src/app/shared/services';
|
||||||
import { ModalService } from '../../../../src/app/shared/services';
|
import { ModalComponent } from 'src/app/shared/modal/modal.component';
|
||||||
import { ModalComponent } from '../../../../src/app/shared/modal/modal.component';
|
|
||||||
|
|
||||||
describe('Modal', () => {
|
describe('Modal', () => {
|
||||||
let component: ModalComponent;
|
let component: ModalComponent;
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { TestBed, getTestBed } from '@angular/core/testing'
|
import { TestBed, getTestBed } from '@angular/core/testing'
|
||||||
import {
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
HttpClientTestingModule,
|
|
||||||
HttpTestingController
|
|
||||||
} from '@angular/common/http/testing';
|
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
import { AuthService } from '../../../../src/app/shared/services';
|
import { AuthService } from 'src/app/shared/services';
|
||||||
|
import { ModalService } from 'src/app/shared/modal/modal.service';
|
||||||
import { ModalService } from '../../../../src/app/shared/modal/modal.service';
|
|
||||||
|
|
||||||
describe('ModalService', () => {
|
describe('ModalService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
|
@ -13,7 +13,7 @@ import {
|
|||||||
Task,
|
Task,
|
||||||
UserOptions,
|
UserOptions,
|
||||||
User
|
User
|
||||||
} from '../../../../src/app/shared/models';
|
} from 'src/app/shared/models';
|
||||||
|
|
||||||
describe('Models', () => {
|
describe('Models', () => {
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
|
import { TestBed, ComponentFixture, fakeAsync, tick } from '@angular/core/testing';
|
||||||
|
|
||||||
import { SharedModule } from '../../../../src/app/shared/shared.module';
|
import { SharedModule } from 'src/app/shared/shared.module';
|
||||||
import { NotificationsServiceMock } from '../../mocks';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NotificationsService
|
NotificationsService
|
||||||
} from '../../../../src/app/shared/notifications/notifications.service';
|
} from 'src/app/shared/notifications/notifications.service';
|
||||||
import {
|
import {
|
||||||
NotificationsComponent
|
NotificationsComponent
|
||||||
} from '../../../../src/app/shared/notifications/notifications.component';
|
} from 'src/app/shared/notifications/notifications.component';
|
||||||
|
|
||||||
|
import { NotificationsServiceMock } from '../../mocks';
|
||||||
|
|
||||||
describe('Notifications', () => {
|
describe('Notifications', () => {
|
||||||
let component: NotificationsComponent;
|
let component: NotificationsComponent;
|
||||||
|
@ -5,9 +5,7 @@ import {
|
|||||||
} from '@angular/common/http/testing';
|
} from '@angular/common/http/testing';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
|
||||||
import {
|
import { StringsService } from 'src/app/shared/strings/strings.service';
|
||||||
StringsService
|
|
||||||
} from '../../../../src/app/shared/strings/strings.service';
|
|
||||||
|
|
||||||
describe('StringsService', () => {
|
describe('StringsService', () => {
|
||||||
let injector: TestBed;
|
let injector: TestBed;
|
||||||
|
@ -3,13 +3,13 @@ import { RouterTestingModule } from '@angular/router/testing';
|
|||||||
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
import { HttpClientTestingModule } from '@angular/common/http/testing';
|
||||||
import { FormsModule } from '@angular/forms';
|
import { FormsModule } from '@angular/forms';
|
||||||
|
|
||||||
import { TopNavComponent } from '../../../../src/app/shared/top-nav/top-nav.component';
|
import { TopNavComponent } from 'src/app/shared/top-nav/top-nav.component';
|
||||||
import {
|
import {
|
||||||
Constants,
|
Constants,
|
||||||
AuthService,
|
AuthService,
|
||||||
NotificationsService,
|
NotificationsService,
|
||||||
StringsService
|
StringsService
|
||||||
} from '../../../../src/app/shared/services';
|
} from 'src/app/shared/services';
|
||||||
|
|
||||||
describe('TopNav', () => {
|
describe('TopNav', () => {
|
||||||
let component: TopNavComponent;
|
let component: TopNavComponent;
|
||||||
|
Reference in New Issue
Block a user