forked from valueadd-poland/pimp-my-pr
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolve valueadd-poland#160
- Loading branch information
Maciej Łukasik
committed
Oct 14, 2020
1 parent
822ae45
commit b52ca1a
Showing
111 changed files
with
2,718 additions
and
237 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
libs/pmp-web/repository/domain/src/lib/interfaces/timeline-chart-range.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface TimelineChartRange { | ||
toDate: Date | null; | ||
fromDate: Date | null; | ||
} |
8 changes: 8 additions & 0 deletions
8
libs/pmp-web/repository/domain/src/lib/interfaces/timeline-properties.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { TimelineStep } from '@pimp-my-pr/shared/domain'; | ||
|
||
export interface TimelineProperties { | ||
step: TimelineStep; | ||
dateFrom: Date; | ||
trackedFrom: Date; | ||
totalPrs: number; | ||
} |
14 changes: 14 additions & 0 deletions
14
libs/pmp-web/repository/domain/src/lib/interfaces/timeline-record.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
export interface TimelineRecord { | ||
dataFrom: Date; | ||
sumCount: number; | ||
avgCount: number; | ||
avgWaitingTime: number; | ||
/** | ||
* This field is required to calculate total prs count in the selected time period on the timeline | ||
*/ | ||
closedBefore: number; | ||
/** | ||
* This field is required to calculate total prs count in the selected time period on the timeline | ||
*/ | ||
openedAfter: number; | ||
} |
7 changes: 7 additions & 0 deletions
7
libs/pmp-web/repository/domain/src/lib/interfaces/timeline-settings.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { TimelineStep } from '@pimp-my-pr/shared/domain'; | ||
|
||
export interface TimelineSettings { | ||
step: TimelineStep; | ||
timelineFrom: Date; | ||
timelineTo: Date; | ||
} |
7 changes: 7 additions & 0 deletions
7
libs/pmp-web/repository/domain/src/lib/interfaces/timeline-total-stats.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface TimelineTotalStats { | ||
totalPrs: number; | ||
avgPrsCount: number; | ||
avgWaitingTime: number; | ||
opened: number; | ||
closed: number; | ||
} |
6 changes: 6 additions & 0 deletions
6
libs/pmp-web/repository/domain/src/lib/interfaces/timeline.interface.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { TimelineProperties } from './timeline-properties.interface'; | ||
import { TimelineRecord } from './timeline-record.interface'; | ||
|
||
export interface Timeline extends TimelineProperties { | ||
data: TimelineRecord[]; | ||
} |
5 changes: 5 additions & 0 deletions
5
libs/pmp-web/repository/domain/src/lib/payloads/get-pr-timeline.payload.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { TimelineSettings } from '../..'; | ||
|
||
export interface GetPrTimelinePayload extends TimelineSettings { | ||
repositoryId: string; | ||
} |
7 changes: 7 additions & 0 deletions
7
libs/pmp-web/repository/repository-pr-timeline/data-access/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# pmp-web-repository-repository-timeline-data-access | ||
|
||
This library was generated with [Nx](https://nx.dev). | ||
|
||
## Running unit tests | ||
|
||
Run `nx test pmp-web-repository-repository-timeline-data-access` to execute the unit tests. |
11 changes: 11 additions & 0 deletions
11
libs/pmp-web/repository/repository-pr-timeline/data-access/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
name: 'pmp-web-repository-repository-pr-timeline-data-access', | ||
preset: '../../../../../jest.config.js', | ||
coverageDirectory: | ||
'../../../../../coverage/libs/pmp-web/repository/repository-pr-timeline/data-access', | ||
snapshotSerializers: [ | ||
'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js', | ||
'jest-preset-angular/build/AngularSnapshotSerializer.js', | ||
'jest-preset-angular/build/HTMLCommentSerializer.js' | ||
] | ||
}; |
4 changes: 4 additions & 0 deletions
4
libs/pmp-web/repository/repository-pr-timeline/data-access/src/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * from './lib/+state/timeline.facade'; | ||
export * from './lib/+state/timeline.reducer'; | ||
export * from './lib/+state/timeline.selectors'; | ||
export * from './lib/pmp-web-repository-repository-pr-timeline-data-access.module'; |
32 changes: 32 additions & 0 deletions
32
.../pmp-web/repository/repository-pr-timeline/data-access/src/lib/+state/timeline.actions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Action } from '@ngrx/store'; | ||
import { HttpErrorResponse } from '@angular/common/http'; | ||
import { Timeline } from '@pimp-my-pr/pmp-web/repository/domain'; | ||
import { GetPrTimelinePayload } from '@pimp-my-pr/pmp-web/repository/domain'; | ||
|
||
export namespace fromTimelineActions { | ||
export enum Types { | ||
GetTimeline = '[Repository pr timeline] Get Timeline', | ||
GetTimelineFail = '[Repository pr timeline] Get Timeline Fail', | ||
GetTimelineSuccess = '[Repository pr timeline] Get Timeline Success' | ||
} | ||
|
||
export class GetTimeline implements Action { | ||
readonly type = Types.GetTimeline; | ||
|
||
constructor(public payload: GetPrTimelinePayload) {} | ||
} | ||
|
||
export class GetTimelineFail implements Action { | ||
readonly type = Types.GetTimelineFail; | ||
|
||
constructor(public payload: HttpErrorResponse) {} | ||
} | ||
|
||
export class GetTimelineSuccess implements Action { | ||
readonly type = Types.GetTimelineSuccess; | ||
|
||
constructor(public payload: Timeline) {} | ||
} | ||
|
||
export type CollectiveType = GetTimeline | GetTimelineSuccess | GetTimelineFail; | ||
} |
69 changes: 69 additions & 0 deletions
69
...web/repository/repository-pr-timeline/data-access/src/lib/+state/timeline.effects.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
import { Observable } from 'rxjs'; | ||
import { provideMockActions } from '@ngrx/effects/testing'; | ||
import { provideMockStore } from '@ngrx/store/testing'; | ||
import { NxModule, DataPersistence } from '@nrwl/angular'; | ||
import { cold, hot } from 'jest-marbles'; | ||
import { TimelineEffects } from './timeline.effects'; | ||
import { fromTimelineActions } from './timeline.actions'; | ||
import { TimelineDataService } from '../services/timeline-data.service'; | ||
import { createSpyObj } from 'jest-createspyobj'; | ||
|
||
describe('TimelineEffects', () => { | ||
let timelineDataService: jest.Mocked<TimelineDataService>; | ||
let actions: Observable<any>; | ||
let effects: TimelineEffects; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [NxModule.forRoot()], | ||
providers: [ | ||
TimelineEffects, | ||
DataPersistence, | ||
provideMockActions(() => actions), | ||
provideMockStore({ initialState: {} }), | ||
{ | ||
provide: TimelineDataService, | ||
useValue: createSpyObj(TimelineDataService) | ||
} | ||
] | ||
}); | ||
|
||
effects = TestBed.get(TimelineEffects); | ||
timelineDataService = TestBed.get(TimelineDataService); | ||
}); | ||
|
||
describe('getTimelineRecord$', () => { | ||
test('returns GetTimelineSuccess action on success', () => { | ||
const payload = {} as any; | ||
const action = new fromTimelineActions.GetTimeline({} as any); | ||
const completion = new fromTimelineActions.GetTimelineSuccess(payload); | ||
|
||
actions = hot('-a', { a: action }); | ||
const response = cold('--b|', { b: payload }); | ||
const expected = cold('---c', { c: completion }); | ||
timelineDataService.getTimeline.mockReturnValue(response); | ||
|
||
expect(effects.getTimeline$).toSatisfyOnFlush(() => { | ||
expect(timelineDataService.getTimeline).toHaveBeenCalled(); | ||
}); | ||
expect(effects.getTimeline$).toBeObservable(expected); | ||
}); | ||
|
||
test('returns GetTimelineFail action on fail', () => { | ||
const payload = {} as any; | ||
const action = new fromTimelineActions.GetTimeline({} as any); | ||
const completion = new fromTimelineActions.GetTimelineFail(payload); | ||
|
||
actions = hot('-a', { a: action }); | ||
const response = cold('-#', {}, payload); | ||
const expected = cold('--c', { c: completion }); | ||
timelineDataService.getTimeline.mockReturnValue(response); | ||
|
||
expect(effects.getTimeline$).toSatisfyOnFlush(() => { | ||
expect(timelineDataService.getTimeline).toHaveBeenCalled(); | ||
}); | ||
expect(effects.getTimeline$).toBeObservable(expected); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.