-
- Dario Herrera
+
+
+ {{name}}
-
diff --git a/src/app/modules/shared/components/user/user.component.spec.ts b/src/app/modules/shared/components/user/user.component.spec.ts
index bf5e41717..9b44146e0 100644
--- a/src/app/modules/shared/components/user/user.component.spec.ts
+++ b/src/app/modules/shared/components/user/user.component.spec.ts
@@ -1,14 +1,28 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
-
+import { of } from 'rxjs';
import { UserComponent } from './user.component';
+import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
describe('UserComponent', () => {
let component: UserComponent;
let fixture: ComponentFixture
;
+ let azureAdB2CService: AzureAdB2CService;
+
+ const azureAdB2CServiceStub = {
+ isLogin() {
+ return true;
+ },
+ signIn() {
+ return of();
+ }
+ };
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ UserComponent ]
+ declarations: [ UserComponent ],
+ providers: [
+ { providers: AzureAdB2CService, useValue: azureAdB2CServiceStub}
+ ]
})
.compileComponents();
}));
@@ -17,9 +31,19 @@ describe('UserComponent', () => {
fixture = TestBed.createComponent(UserComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ azureAdB2CService = TestBed.inject(AzureAdB2CService);
});
- it('should be created', () => {
+ it('should be created user component ', () => {
expect(component).toBeTruthy();
});
+
+ it('should check onInit', () => {
+ spyOn(azureAdB2CService, 'isLogin').and.returnValue(true);
+ spyOn(azureAdB2CService, 'getName').and.returnValue('Name');
+ component.ngOnInit();
+ expect(azureAdB2CService.isLogin).toHaveBeenCalled;
+ expect(azureAdB2CService.getName).toHaveBeenCalled;
+ });
+
});
diff --git a/src/app/modules/shared/components/user/user.component.ts b/src/app/modules/shared/components/user/user.component.ts
index 5df0c83d0..dfab1c71d 100644
--- a/src/app/modules/shared/components/user/user.component.ts
+++ b/src/app/modules/shared/components/user/user.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit } from '@angular/core';
+import { AzureAdB2CService } from '../../../login/services/azure.ad.b2c.service';
@Component({
selector: 'app-user',
@@ -7,9 +8,17 @@ import { Component, OnInit } from '@angular/core';
})
export class UserComponent implements OnInit {
- constructor() { }
+ name: string = ''
+ constructor(private azureAdB2CService: AzureAdB2CService) { }
ngOnInit(): void {
+ if(this.azureAdB2CService.isLogin()) {
+ this.name = this.azureAdB2CService.getName()
+ }
+ }
+
+ logout() {
+ this.azureAdB2CService.logout()
}
}
diff --git a/src/app/modules/shared/pipes/group-by-date/group-by-date.pipe.spec.ts b/src/app/modules/shared/pipes/group-by-date/group-by-date.pipe.spec.ts
index b8b4906ff..ddf869c20 100644
--- a/src/app/modules/shared/pipes/group-by-date/group-by-date.pipe.spec.ts
+++ b/src/app/modules/shared/pipes/group-by-date/group-by-date.pipe.spec.ts
@@ -1,8 +1,75 @@
import { GroupByDatePipe } from './group-by-date.pipe';
+import { Pipe } from '@angular/core';
describe('GroupByDatePipe', () => {
it('create an instance', () => {
const pipe = new GroupByDatePipe();
expect(pipe).toBeTruthy();
});
+
+ it('create an instance', () => {
+ const pipe = new GroupByDatePipe();
+ const date = '2020-02-05T15:36:15.887Z';
+ const result = pipe.getDate(date);
+ expect(pipe.getDate).toHaveBeenCalled
+ expect(result).toEqual(new Date('2/5/2020').toLocaleDateString())
+ });
+
+ it('should add new date', () => {
+ const entryList = [
+ {
+ id: 'entry_1',
+ project: 'Mido - 05 de Febrero',
+ startDate: '2020-02-05T15:36:15.887Z',
+ endDate: '2020-02-05T18:36:15.887Z',
+ activity: 'development',
+ technology: 'Angular, TypeScript',
+ comments: 'No comments',
+ ticket: 'EY-25'
+ },
+ {
+ id: 'entry_2',
+ project: 'Mido 15 de Marzo',
+ startDate: '2020-03-15T20:36:15.887Z',
+ endDate: '2020-03-15T23:36:15.887Z',
+ activity: 'development',
+ technology: 'Angular, TypeScript',
+ comments: 'No comments',
+ ticket: 'EY-38'
+ },
+ {
+ id: 'entry_3',
+ project: 'GoSpace 15 y 16 de Marzo',
+ startDate: '2020-03-15T23:36:15.887Z',
+ endDate: '2020-03-16T05:36:15.887Z',
+ activity: 'development',
+ technology: 'Angular, TypeScript',
+ comments: 'No comments',
+ ticket: 'EY-225'
+ },
+ {
+ id: 'entry_4',
+ project: 'Mido 16 de Marzo',
+ startDate: '2020-03-16T15:36:15.887Z',
+ endDate: '2020-03-16T18:36:15.887Z',
+ activity: 'development',
+ technology: 'Angular, TypeScript',
+ comments: 'No comments',
+ ticket: 'EY-89'
+ },
+ {
+ id: 'entry_5',
+ project: 'Ernst&Young 01 de Abril',
+ startDate: '2020-04-01T09:36:15.887Z',
+ endDate: '2020-04-01T15:36:15.887Z',
+ activity: 'development',
+ technology: 'Angular, TypeScript',
+ comments: 'No comments',
+ ticket: 'EY-59'
+ }
+ ];
+ const pipe = new GroupByDatePipe();
+ pipe.transform(entryList)
+ expect(pipe.transform).toHaveBeenCalled
+ });
});
diff --git a/src/app/modules/time-entries/pages/time-entries.component.spec.ts b/src/app/modules/time-entries/pages/time-entries.component.spec.ts
index b80ba7d36..4d5516a4d 100644
--- a/src/app/modules/time-entries/pages/time-entries.component.spec.ts
+++ b/src/app/modules/time-entries/pages/time-entries.component.spec.ts
@@ -61,7 +61,7 @@ describe('TimeEntriesComponent', () => {
it('should call dataByMonth in ngOnInit()', async(() => {
component.ngOnInit();
- expect(component.dataByMonth.length).toEqual(3);
+ expect(component.dataByMonth.length).toEqual(1);
}));
it('should open Delete Modal', () => {
@@ -91,9 +91,9 @@ describe('TimeEntriesComponent', () => {
});
it('should delete a Entry', () => {
- const entryId = 'entry_2';
+ const entryId = 'entry_5';
component.removeEntry(entryId);
- expect(component.dataByMonth.length).toBe(2);
+ expect(component.dataByMonth.length).toBe(0);
});
it('should get the entry List by Month', () => {
diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts
index 3612073bc..84b2f5826 100644
--- a/src/environments/environment.prod.ts
+++ b/src/environments/environment.prod.ts
@@ -1,3 +1,9 @@
+import * as keys from './.keys.json';
+
export const environment = {
production: true
};
+
+export const AUTHORITY = keys.authority;
+export const CLIENT_ID = keys.client_id;
+export const SCOPES = keys.scopes;
\ No newline at end of file
diff --git a/src/environments/environment.ts b/src/environments/environment.ts
index 7b4f817ad..21d08f023 100644
--- a/src/environments/environment.ts
+++ b/src/environments/environment.ts
@@ -1,11 +1,16 @@
// This file can be replaced during build by using the `fileReplacements` array.
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
// The list of file replacements can be found in `angular.json`.
+import * as keys from './.keys.json';
export const environment = {
production: false
};
+export const AUTHORITY = keys.authority;
+export const CLIENT_ID = keys.client_id;
+export const SCOPES = keys.scopes;
+
/*
* For easier debugging in development mode, you can import the following file
* to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
diff --git a/src/environments/keys.example.json b/src/environments/keys.example.json
new file mode 100644
index 000000000..c65a76e7f
--- /dev/null
+++ b/src/environments/keys.example.json
@@ -0,0 +1,6 @@
+{
+ "authority": "XXXXX",
+ "client_id": "XXXXX",
+ "scopes": ["XXXXX"]
+ }
+
\ No newline at end of file
diff --git a/tsconfig.json b/tsconfig.json
index 30956ae7e..582f5574d 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -21,6 +21,7 @@
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
- "strictInjectionParameters": true
+ "strictInjectionParameters": true,
+ "resolveJsonModule": true
}
}