Commit 29bd57387414b1609da9bb5a11124078c5522d7a

Authored by Michel Felipe
1 parent a61cb0f5

Added new 'per_page' to SearchComponent

src/app/search/search.component.spec.ts
... ... @@ -8,7 +8,7 @@ describe("Components", () => {
8 8 describe("Search Component", () => {
9 9  
10 10 let helper: ComponentTestHelper<SearchComponent>;
11   - let stateParams = { query: 'query' };
  11 + let stateParams = { query: 'query', per_page: 20 };
12 12 let articleService = jasmine.createSpyObj("ArticleService", ["search"]);
13 13 let result = Promise.resolve({ data: [{ id: 1 }], headers: (param: string) => { return 1; } });
14 14 articleService.search = jasmine.createSpy("search").and.returnValue(result);
... ... @@ -30,7 +30,7 @@ describe(&quot;Components&quot;, () =&gt; {
30 30 });
31 31  
32 32 it("load first page with search results", () => {
33   - expect(articleService.search).toHaveBeenCalledWith({ query: 'query', per_page: 10, page: 0 });
  33 + expect(articleService.search).toHaveBeenCalledWith({ query: 'query', per_page: 20, page: 0 });
34 34 });
35 35  
36 36 it("display search results", () => {
... ...
src/app/search/search.component.ts
... ... @@ -19,6 +19,7 @@ export class SearchComponent {
19 19  
20 20 constructor(private articleService: ArticleService, private $stateParams: ng.ui.IStateParamsService, private $state: ng.ui.IStateService) {
21 21 this.query = this.$stateParams['query'];
  22 + this.perPage = this.$stateParams['per_page'] || this.perPage;
22 23 this.loadPage();
23 24 }
24 25  
... ...