Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: #571 technology report - test create component
  • Loading branch information
scastillo-jp authored and Angeluz-07 committed Dec 11, 2020
commit 07c130eb4f177a6f2816cb9d6de0b9633c9f7d96
4 changes: 2 additions & 2 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
import { CommonModule, DatePipe } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { NgModule, Component } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { DataTablesModule } from 'angular-datatables';
Expand Down Expand Up @@ -127,7 +127,7 @@ const maskConfig: Partial<IConfig> = {
UsersComponent,
UsersListComponent,
TechnologyReportComponent,
TechnologyReportTableComponent
TechnologyReportTableComponent,
],
imports: [
NgxMaskModule.forRoot(maskConfig),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,83 +1,77 @@
// import { async, ComponentFixture, TestBed } from '@angular/core/testing';
// import { MockStore, provideMockStore } from '@ngrx/store/testing';
// import { Entry } from 'src/app/modules/shared/models';
// import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe';
// import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors';
// import { EntryState } from '../../../time-clock/store/entry.reducer';
// import { TimeEntriesTableComponent } from './time-entries-table.component';
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { MockStore, provideMockStore } from '@ngrx/store/testing';
import { Entry } from 'src/app/modules/shared/models';
import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe';
import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors';
import { EntryState } from '../../../time-clock/store/entry.reducer';
import { TechnologyReportTableComponent } from './technology-report-table.component';

// describe('Reports Page', () => {
// describe('TimeEntriesTableComponent', () => {
// let component: TimeEntriesTableComponent;
// let fixture: ComponentFixture<TimeEntriesTableComponent>;
// let store: MockStore<EntryState>;
// let getReportDataSourceSelectorMock;
// const timeEntry: Entry = {
// id: '123',
// start_date: new Date(),
// end_date: new Date(),
// activity_id: '123',
// technologies: ['react', 'redux'],
// description: 'any comment',
// uri: 'custom uri',
// project_id: '123',
// project_name: 'Time-Tracker'
// };
describe('Reports Page', () => {
describe('TimeEntriesTableComponent', () => {
let component: TechnologyReportTableComponent;
let fixture: ComponentFixture<TechnologyReportTableComponent>;
let store: MockStore<EntryState>;
let getReportDataSourceSelectorMock;
const timeEntry: Entry = {
start_date: new Date(),
end_date: new Date(),
technologies: ['react', 'redux'],
};

// const state: EntryState = {
// active: timeEntry,
// isLoading: false,
// message: '',
// createError: false,
// updateError: false,
// timeEntriesSummary: null,
// timeEntriesDataSource: {
// data: [timeEntry],
// isLoading: false
// },
// reportDataSource: {
// data: [timeEntry],
// isLoading: false
// }
// };
const state: EntryState = {
active: timeEntry,
isLoading: false,
message: '',
createError: false,
updateError: false,
timeEntriesSummary: null,
timeEntriesDataSource: {
data: [timeEntry],
isLoading: false
},
reportDataSource: {
data: [timeEntry],
isLoading: false
}
};

// beforeEach(async(() => {
// TestBed.configureTestingModule({
// imports: [],
// declarations: [TimeEntriesTableComponent, SubstractDatePipe],
// providers: [provideMockStore({ initialState: state })],
// }).compileComponents();
// store = TestBed.inject(MockStore);
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [],
declarations: [TechnologyReportTableComponent, SubstractDatePipe],
providers: [provideMockStore({ initialState: state })],
}).compileComponents();
store = TestBed.inject(MockStore);

// }));
}));

// beforeEach(async(() => {
// fixture = TestBed.createComponent(TimeEntriesTableComponent);
// component = fixture.componentInstance;
// store.setState(state);
// getReportDataSourceSelectorMock = store.overrideSelector(getReportDataSource, state.reportDataSource);
// fixture.detectChanges();
// }));
beforeEach(async(() => {
fixture = TestBed.createComponent(TechnologyReportTableComponent);
component = fixture.componentInstance;
store.setState(state);
getReportDataSourceSelectorMock = store.overrideSelector(getReportDataSource, state.reportDataSource);
fixture.detectChanges();
}));

// it('component should be created', async () => {
// expect(component).toBeTruthy();
// });
fit('component should be created', async () => {
expect(component).toBeTruthy();
});

// it('on success load time entries, the report should be populated', () => {
// component.reportDataSource$.subscribe(ds => {
// expect(ds.data).toEqual(state.reportDataSource.data);
// });
// });
// it('on success load time entries, the report should be populated', () => {
// component.reportDataSource$.subscribe(ds => {
// expect(ds.data).toEqual(state.reportDataSource.data);
// });
// });

// it('after the component is initialized it should initialize the table', () => {
// spyOn(component.dtTrigger, 'next');
// component.ngAfterViewInit();
// it('after the component is initialized it should initialize the table', () => {
// spyOn(component.dtTrigger, 'next');
// component.ngAfterViewInit();

// expect(component.dtTrigger.next).toHaveBeenCalled();
// });
// expect(component.dtTrigger.next).toHaveBeenCalled();
// });

// afterEach(() => {
// fixture.destroy();
// });
// });
// });
afterEach(() => {
fixture.destroy();
});
});
});