diff options
| author | crupest <crupest@outlook.com> | 2019-03-11 00:14:48 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2019-03-11 00:14:48 +0800 | 
| commit | 66e345c2ef3cdff410bf6f31d54f09ab4e6fe213 (patch) | |
| tree | 8fdf86e18f2dcfa2ee5bfc6973985b8b8706b433 /Timeline/ClientApp/src/app/todo/todo-service | |
| parent | 31199282e1ccf72bb464117ae68668aed91e2530 (diff) | |
| download | timeline-66e345c2ef3cdff410bf6f31d54f09ab4e6fe213.tar.gz timeline-66e345c2ef3cdff410bf6f31d54f09ab4e6fe213.tar.bz2 timeline-66e345c2ef3cdff410bf6f31d54f09ab4e6fe213.zip  | |
Extract out http entities.
Diffstat (limited to 'Timeline/ClientApp/src/app/todo/todo-service')
3 files changed, 17 insertions, 16 deletions
diff --git a/Timeline/ClientApp/src/app/todo/todo-service/http-entities.ts b/Timeline/ClientApp/src/app/todo/todo-service/http-entities.ts new file mode 100644 index 00000000..3971617c --- /dev/null +++ b/Timeline/ClientApp/src/app/todo/todo-service/http-entities.ts @@ -0,0 +1,11 @@ +export const githubBaseUrl = 'https://api.github.com/repos/crupest/Timeline'; + +export interface IssueResponseItem { +  number: number; +  title: string; +  state: string; +  html_url: string; +  pull_request?: any; +} + +export type IssueResponse = IssueResponseItem[]; diff --git a/Timeline/ClientApp/src/app/todo/todo-service/todo.service.spec.ts b/Timeline/ClientApp/src/app/todo/todo-service/todo.service.spec.ts index b0b35f7b..679dc8b7 100644 --- a/Timeline/ClientApp/src/app/todo/todo-service/todo.service.spec.ts +++ b/Timeline/ClientApp/src/app/todo/todo-service/todo.service.spec.ts @@ -3,7 +3,8 @@ import { HttpClientTestingModule, HttpTestingController } from '@angular/common/  import { toArray } from 'rxjs/operators';  import { TodoItem } from '../todo-item'; -import { TodoService, IssueResponse } from './todo.service'; +import { TodoService } from './todo.service'; +import { IssueResponse, githubBaseUrl } from './http-entities';  describe('TodoService', () => { @@ -19,8 +20,6 @@ describe('TodoService', () => {    it('should work well', () => {      const service: TodoService = TestBed.get(TodoService); -    const baseUrl = service.baseUrl; -      const mockIssueList: IssueResponse = [{        number: 1,        title: 'Issue title 1', @@ -47,7 +46,8 @@ describe('TodoService', () => {      const httpController: HttpTestingController = TestBed.get(HttpTestingController); -    httpController.expectOne(request => request.url === baseUrl + '/issues' && request.params.get('state') === 'all').flush(mockIssueList); +    httpController.expectOne(request => request.url === githubBaseUrl + '/issues' && +      request.params.get('state') === 'all').flush(mockIssueList);      httpController.verify();    }); diff --git a/Timeline/ClientApp/src/app/todo/todo-service/todo.service.ts b/Timeline/ClientApp/src/app/todo/todo-service/todo.service.ts index ed1f2cbe..df63636d 100644 --- a/Timeline/ClientApp/src/app/todo/todo-service/todo.service.ts +++ b/Timeline/ClientApp/src/app/todo/todo-service/todo.service.ts @@ -3,29 +3,19 @@ import { HttpClient } from '@angular/common/http';  import { Observable, from } from 'rxjs';  import { switchMap, map, filter } from 'rxjs/operators'; +import { IssueResponse, githubBaseUrl } from './http-entities';  import { TodoItem } from '../todo-item'; -export interface IssueResponseItem { -  number: number; -  title: string; -  state: string; -  html_url: string; -  pull_request?: any; -} - -export type IssueResponse = IssueResponseItem[];  @Injectable({    providedIn: 'root'  })  export class TodoService { -  readonly baseUrl = 'https://api.github.com/repos/crupest/Timeline'; -    constructor(private client: HttpClient) { }    getWorkItemList(): Observable<TodoItem> { -    return this.client.get<IssueResponse>(`${this.baseUrl}/issues`, { +    return this.client.get<IssueResponse>(`${githubBaseUrl}/issues`, {        params: {          state: 'all'        }  | 
