-
Notifications
You must be signed in to change notification settings - Fork 14
Feature/add code coverage #46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
702dddd
* Added more tests
hikr17 fc60f8c
Missed 2 files.
hikr17 c79b1ac
Merge remote-tracking branch 'origin/develop' into feature/add-code-c…
hikr17 e154677
* Added more tests.
hikr17 7c77383
Merge remote-tracking branch 'origin/develop' into feature/add-code-c…
hikr17 62fc506
Added test for RichSkillSearchResultsComponent. Also added support f…
hikr17 d4c7681
Renamed ActivatedRouteStub.setParamsMap => setParams.
hikr17 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ import { HttpClientTestingModule, HttpTestingController } from "@angular/common/ | |
| import { async, TestBed } from "@angular/core/testing" | ||
| import { Router } from "@angular/router" | ||
| import { | ||
| createMockBatchResult, | ||
| createMockCollection, | ||
| createMockCollectionUpdate, | ||
| createMockPaginatedCollections, | ||
| createMockPaginatedSkills, | ||
| createMockTaskResult | ||
|
|
@@ -15,9 +15,15 @@ import { AppConfig } from "../../app.config" | |
| import { AuthService } from "../../auth/auth-service" | ||
| import { EnvironmentService } from "../../core/environment.service" | ||
| import { PublishStatus } from "../../PublishStatus" | ||
| import { ApiBatchResult, IBatchResult } from "../../richskill/ApiBatchResult" | ||
| import { ApiSortOrder } from "../../richskill/ApiSkill" | ||
| import { IStringListUpdate } from "../../richskill/ApiSkillUpdate" | ||
| import { PaginatedCollections, PaginatedSkills } from "../../richskill/service/rich-skill-search.service" | ||
| import { | ||
| ApiSearch, | ||
| ApiSkillListUpdate, | ||
| PaginatedCollections, | ||
| PaginatedSkills | ||
| } from "../../richskill/service/rich-skill-search.service" | ||
| import { ApiTaskResult, ITaskResult } from "../../task/ApiTaskResult" | ||
| import { ApiCollection, ApiCollectionUpdate } from "../ApiCollection" | ||
| import { CollectionService } from "./collection.service" | ||
|
|
@@ -333,4 +339,168 @@ describe("CollectionService", () => { | |
| expect(req.request.method).toEqual("POST") | ||
| req.flush(testData) | ||
| }) | ||
|
|
||
| it("searchCollections should return", () => { | ||
| // Arrange | ||
| RouterData.commands = [] | ||
| AuthServiceData.isDown = false | ||
| const testData: PaginatedCollections = createMockPaginatedCollections() | ||
| const expected = testData | ||
| const path = "api/search/collections" | ||
| const query = "testQueryString" | ||
| const apiSearch = new ApiSearch({ query }) | ||
| const size = 5 | ||
| const from = 1 | ||
| const filter = new Set<PublishStatus>([PublishStatus.Published, PublishStatus.Draft]) | ||
| const sort = ApiSortOrder.SkillAsc | ||
|
|
||
| // Act | ||
| const result$ = testService.searchCollections(apiSearch, size, from, filter, sort) | ||
|
|
||
| // Assert | ||
| result$ | ||
| .subscribe((data: PaginatedCollections) => { | ||
| expect(data).toEqual(expected) | ||
| expect(RouterData.commands).toEqual([ ]) // No errors | ||
| expect(AuthServiceData.isDown).toEqual(false) | ||
| }) | ||
|
|
||
| const req = httpTestingController.expectOne(AppConfig.settings.baseApiUrl + "/" + path + | ||
| `?sort=${sort}&status=${PublishStatus.Published}&status=${PublishStatus.Draft}&size=${size}&from=${from}`) | ||
| expect(req.request.method).toEqual("POST") | ||
| req.flush(testData.collections, { | ||
| headers: { "x-total-count": "" + testData.totalCount} | ||
| }) | ||
| }) | ||
|
|
||
| it("updateSkills should return", () => { | ||
| // Arrange | ||
| RouterData.commands = [] | ||
| AuthServiceData.isDown = false | ||
| const testData = createMockTaskResult() | ||
| const expected = new ApiTaskResult(testData) | ||
| const uuid = expected.uuid | ||
| const path = "api/collections/" + uuid + "/updateSkills" | ||
| const query = "testQueryString" | ||
| const update = new ApiSkillListUpdate({ | ||
| add: new ApiSearch({query}), | ||
| remove: new ApiSearch({query}) | ||
| }) | ||
| const filter = new Set<PublishStatus>([PublishStatus.Published, PublishStatus.Draft]) | ||
| const sort = undefined | ||
|
|
||
| // Act | ||
| const result$ = testService.updateSkills(uuid, update, filter) | ||
|
|
||
| // Assert | ||
| result$ | ||
| .subscribe((data: ITaskResult) => { | ||
| expect(data).toEqual(expected) | ||
| expect(RouterData.commands).toEqual([ ]) // No errors | ||
| expect(AuthServiceData.isDown).toEqual(false) | ||
| }) | ||
|
|
||
| const req = httpTestingController.expectOne(AppConfig.settings.baseApiUrl + "/" + path + | ||
| `?sort=${sort}&status=${PublishStatus.Published}&status=${PublishStatus.Draft}`) | ||
| expect(req.request.method).toEqual("POST") | ||
| req.flush(testData) | ||
| }) | ||
|
|
||
| // There are 2 REST requests here. Cannot figure out how to get the task request to return the task. | ||
| xit("updateSkillsWithResult should return", () => { | ||
| // Arrange | ||
| RouterData.commands = [] | ||
| AuthServiceData.isDown = false | ||
| const iTaskResult = createMockTaskResult() | ||
| const testData: IBatchResult = createMockBatchResult() | ||
| const expected = new ApiBatchResult(testData) | ||
| const uuid: string = iTaskResult.uuid ? iTaskResult.uuid : "" | ||
| const path = "api/collections/" + uuid + "/updateSkills" | ||
| const query = "testQueryString" | ||
| const update = new ApiSkillListUpdate({ | ||
| add: new ApiSearch({query}), | ||
| remove: new ApiSearch({query}) | ||
| }) | ||
| const filter = new Set<PublishStatus>([PublishStatus.Published, PublishStatus.Draft]) | ||
| const sort = undefined | ||
|
|
||
| // Act | ||
| const result$ = testService.updateSkillsWithResult(uuid, update, filter) | ||
|
|
||
| // Assert | ||
| result$ | ||
| .subscribe((data: ApiBatchResult) => { | ||
| expect(data).toEqual(expected) | ||
| expect(RouterData.commands).toEqual([ ]) // No errors | ||
| expect(AuthServiceData.isDown).toEqual(false) | ||
| }) | ||
|
|
||
| const req = httpTestingController.expectOne(AppConfig.settings.baseApiUrl + "/" + path + | ||
| `?sort=${sort}&status=${PublishStatus.Published}&status=${PublishStatus.Draft}`) | ||
| expect(req.request.method).toEqual("POST") | ||
| req.flush(testData) | ||
| }) | ||
|
|
||
| // There are 2 REST requests here. Cannot figure out how to get the task request to return the task. | ||
| xit("publishCollectionWithResult should return", () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, same as above. |
||
| // Arrange | ||
| RouterData.commands = [] | ||
| AuthServiceData.isDown = false | ||
| const now = new Date() | ||
| const iTaskResult = createMockTaskResult() | ||
| const testData: IBatchResult = createMockBatchResult() | ||
| const expected = new ApiBatchResult(testData) | ||
| const path = "api/collections/publish" | ||
| const query = "testQueryString" | ||
| const apiSearch = new ApiSearch({ query }) | ||
| const filter = new Set<PublishStatus>([PublishStatus.Draft]) | ||
| const newStatus = PublishStatus.Published | ||
|
|
||
| // Act | ||
| const result$ = testService.publishCollectionsWithResult(apiSearch, newStatus, filter) | ||
|
|
||
| // Assert | ||
| result$ | ||
| .subscribe((data: ApiBatchResult) => { | ||
| expect(data).toEqual(expected) | ||
| expect(RouterData.commands).toEqual([ ]) // No errors | ||
| expect(AuthServiceData.isDown).toEqual(false) | ||
| }) | ||
|
|
||
| const req = httpTestingController.expectOne(AppConfig.settings.baseApiUrl + "/" + path + | ||
| `?newStatus=${newStatus}&filterByStatus=${PublishStatus.Draft}`) | ||
| expect(req.request.method).toEqual("POST") | ||
| req.flush(testData) | ||
| }) | ||
|
|
||
| it("collectionReadyToPublish should return", () => { | ||
| // Arrange | ||
| RouterData.commands = [] | ||
| AuthServiceData.isDown = false | ||
| const uuid = "f6aacc9e-bfc6-4cc9-924d-c7ef83afef07" | ||
| const path = "api/collections/" + uuid + "/skills" | ||
| const testData = createMockPaginatedSkills(0, 0) | ||
| const expected = true | ||
| const size = 1 | ||
| const from = 0 | ||
| const sort = undefined | ||
|
|
||
| // Act | ||
| const result$ = testService.collectionReadyToPublish(uuid) | ||
|
|
||
| // Assert | ||
| result$ | ||
| .subscribe((data: boolean) => { | ||
| expect(data).toEqual(expected) | ||
| expect(RouterData.commands).toEqual([ ]) // No errors | ||
| expect(AuthServiceData.isDown).toEqual(false) | ||
| }) | ||
|
|
||
| const req = httpTestingController.expectOne(AppConfig.settings.baseApiUrl + "/" + path + | ||
| `?sort=${sort}&status=${PublishStatus.Archived}&status=${PublishStatus.Draft}&size=${size}&from=${from}`) | ||
| expect(req.request.method).toEqual("POST") | ||
| req.flush(testData.skills, { | ||
| headers: { "x-total-count": "" + testData.totalCount} | ||
| }) | ||
| }) | ||
| }) | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was this
xitintentional?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, the comment says that I had trouble figuring out the 2-request detail. I chose to submit and move on, rather than continue to keep this code laying around. I'll get back to it at some point. You probably knew, but 'xit' just skips the test.