Skip to content
Prev Previous commit
Next Next commit
fix: TTL-919 debug 9 test modules
  • Loading branch information
mmaquina committed Jul 12, 2023
commit 74f8d6c53e37424ec43d1d0b717e78d6fbe407ea
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
import { waitForAsync, TestBed, ComponentFixture } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
import { ActivitiesManagementComponent } from './activities-management.component';
import { ActivityListComponent } from '../components/activity-list/activity-list.component';
import { CreateActivityComponent } from '../components/create-activity/create-activity.component';
import { StoreModule } from '@ngrx/store';
import { ReactiveFormsModule } from '@angular/forms';
import { provideMockStore } from '@ngrx/store/testing';

const state = {};

describe('ActivitiesManagementComponent', () => {
let component: ActivitiesManagementComponent;
let fixture: ComponentFixture<ActivitiesManagementComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
imports: [],
declarations: [ActivitiesManagementComponent]
imports: [ StoreModule.forRoot({}), ReactiveFormsModule ],
providers: [ provideMockStore({ initialState: state }) ],
declarations: [
ActivitiesManagementComponent,
CreateActivityComponent,
ActivityListComponent,
]
}).compileComponents();
}));

Expand All @@ -27,7 +39,7 @@ describe('ActivitiesManagementComponent', () => {
expect(component.showOptionInDevelopment).toBe(true);
});

it('should check if add new entry button is render', () => {
it('should check if add new entry button is rendered', () => {
const addItemDebugElement = fixture.debugElement.query(By.css('div.col-12.px-0')).childNodes.length;
expect(addItemDebugElement).toBe(3);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { TestBed } from '@angular/core/testing';
import * as selectors from './activity-management.selectors';
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
import { SpinnerOverlayComponent } from '../../shared/components/spinner-overlay/spinner-overlay.component';

describe('ActivityManagement Selectors', () => {

beforeEach(() => {
TestBed.configureTestingModule({
imports: [ MatProgressSpinnerModule ],
declarations: [ ],
declarations: [ SpinnerOverlayComponent ],
}).compileComponents();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import { ManagementCustomerProjectsComponent } from './management-customer-proje
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { CustomerState } from '../../store';
import { of } from 'rxjs';
import { CreateCustomerComponent } from '../customer-info/components/create-customer/create-customer';
import { CreateProjectComponent } from '../projects/components/create-project/create-project.component';
import { CreateProjectTypeComponent } from '../projects-type/components/create-project-type/create-project-type.component';
import { MatNativeDateModule } from '@angular/material/core';
import { ReactiveFormsModule } from '@angular/forms';
import { ProjectListComponent } from '../projects/components/project-list/project-list.component';
import { ProjectTypeListComponent } from '../projects-type/components/project-type-list/project-type-list.component';

describe('ManagmentCustomerProjectsComponent', () => {
let component: ManagementCustomerProjectsComponent;
Expand All @@ -20,9 +27,17 @@ describe('ManagmentCustomerProjectsComponent', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [ManagementCustomerProjectsComponent],
imports: [ MatNativeDateModule, ReactiveFormsModule],
declarations: [
ManagementCustomerProjectsComponent,
CreateCustomerComponent,
CreateProjectComponent,
CreateProjectTypeComponent,
ProjectListComponent,
ProjectTypeListComponent,
],
providers: [
provideMockStore({ initialState: state })
provideMockStore({ initialState: state }),
],
}).compileComponents();
}));
Expand Down
7 changes: 7 additions & 0 deletions src/app/modules/login/services/azure.ad.b2c.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { inject, TestBed } from '@angular/core/testing';
import { Account, UserAgentApplication } from 'msal';
import { AzureAdB2CService } from './azure.ad.b2c.service';
import { CookieService } from 'ngx-cookie-service';
import { ActivitiesManagementComponent } from '../../activities-management/pages/activities-management.component';
import { ActivityListComponent, CreateActivityComponent } from '../../activities-management/components';

describe('AzureAdB2CService', () => {
let service: AzureAdB2CService;
Expand All @@ -11,6 +13,11 @@ describe('AzureAdB2CService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [],
declarations: [
ActivitiesManagementComponent,
CreateActivityComponent,
ActivityListComponent,
]
});
service = TestBed.inject(AzureAdB2CService);
cookieService = TestBed.inject(CookieService);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing';

import { SearchComponent } from './search.component';
import { FormsModule } from '@angular/forms';

describe('SearchComponent', () => {
let component: SearchComponent;
let fixture: ComponentFixture<SearchComponent>;

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [SearchComponent],
imports: [ FormsModule ],
declarations: [ SearchComponent ],
}).compileComponents();
}));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import {waitForAsync, ComponentFixture, TestBed} from '@angular/core/testing';
import {MockStore, provideMockStore} from '@ngrx/store/testing';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatIconModule } from '@angular/material/icon';

import {TechnologyState} from '../../store/technology.reducers';
import {allTechnologies} from '../../store/technology.selectors';
import {TechnologiesComponent} from './technologies.component';
import * as actions from '../../store/technology.actions';


describe('Technologies component', () => {
let component: TechnologiesComponent;
let fixture: ComponentFixture<TechnologiesComponent>;
Expand All @@ -24,7 +28,7 @@ describe('Technologies component', () => {
TestBed.configureTestingModule({
declarations: [TechnologiesComponent],
providers: [provideMockStore({initialState: state})],
imports: [FormsModule, ReactiveFormsModule],
imports: [FormsModule, ReactiveFormsModule, NgSelectModule, MatDatepickerModule, MatIconModule],
}).compileComponents();
store = TestBed.inject(MockStore);
mockTechnologySelector = store.overrideSelector(allTechnologies, state.technologies);
Expand Down
22 changes: 22 additions & 0 deletions src/app/modules/shared/formatters/number.formatter.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
import { TestBed, waitForAsync } from '@angular/core/testing';

import { NumberFormatter } from './number.formatter';
import { CreateCustomerComponent } from '../../customer-management/components/customer-info/components/create-customer/create-customer';
import { CreateProjectComponent } from '../../customer-management/components/projects/components/create-project/create-project.component';
import { CreateProjectTypeComponent } from '../../customer-management/components/projects-type/components/create-project-type/create-project-type.component';
import { ProjectListComponent } from '../../customer-management/components/projects/components/project-list/project-list.component';
import { ProjectTypeListComponent } from '../../customer-management/components/projects-type/components/project-type-list/project-type-list.component';


describe('NumberFormatter', () => {

beforeEach(waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [
NumberFormatter,
CreateCustomerComponent,
CreateProjectComponent,
CreateProjectTypeComponent,
ProjectListComponent,
ProjectTypeListComponent,
],
}).compileComponents();
}));

it('adds a 0 if value < 10', () => {
const numberFormatter = new NumberFormatter(9);

Expand Down
9 changes: 9 additions & 0 deletions src/app/modules/shared/store/technology.actions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
import * as actions from './technology.actions';
import { Technology } from '../models';
import { TestBed } from '@angular/core/testing';
import { FormsModule } from '@angular/forms';

describe('Actions for Technology', () => {
beforeEach(() => {
TestBed.configureTestingModule({
imports: [ FormsModule ],
declarations: [ ],
}).compileComponents();
});

it('FindTechnologySuccess type is TechnologyActionTypes.FIND_TECHNOLOGIES_SUCESS', () => {
const technologyList: Technology = { items: [{ name: 'java' }, { name: 'javascript' }] };
const findTechnologySuccess = new actions.FindTechnologySuccess(technologyList);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
import { CalendarEvent, CalendarView } from 'angular-calendar';
import { CalendarEvent, CalendarModule, CalendarView, DateAdapter } from 'angular-calendar';
import * as moment from 'moment';
import { Observable, of } from 'rxjs';
import { Entry } from 'src/app/modules/shared/models';
import { DataSource } from 'src/app/modules/shared/models/data-source.model';

import { CalendarComponent } from './calendar.component';
import { MatNativeDateModule } from '@angular/material/core';
import { CommonModule } from '@angular/common';
import { adapterFactory } from 'angular-calendar/date-adapters/date-fns';

type MockCardEntryHeight = {
startDate: string;
Expand All @@ -31,7 +34,15 @@ describe('CalendarComponent', () => {
beforeEach(
waitForAsync(() => {
TestBed.configureTestingModule({
declarations: [CalendarComponent],
imports: [
MatNativeDateModule,
CommonModule,
CalendarModule.forRoot({
provide: DateAdapter,
useFactory: adapterFactory,
})
],
declarations: [ CalendarComponent ],
}).compileComponents();
mockCardEntriesHeight = [
{ startDate: '2021-04-11T08:00:00Z', endDate: '2021-04-11T10:20:00Z', expected: 28 },
Expand Down