Skip to content

Commit

Permalink
#800 add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
schoicsiro committed Oct 31, 2023
1 parent c3c6319 commit 01475b0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ profileEditor.controller("AttachmentUploadController", function (profileService,

if (self.categories == null) {
profileService.getCategories().then(function (data) {
self.categories = data;
self.categories = data.resp;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class OpusController extends OpusBaseController {

def getCategories() {
def result = profileService.getCategories()
handle result
render result as JSON
}

@Secured(role = ROLE_PROFILE_ADMIN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ class ApiControllerSpec extends Specification implements ControllerUnitTest<ApiC

where:
type | opusId | profileId | imageId | responseCode
'PRIVATE' |'opus1' | '123' | '1.png' | 200
'PRIVATE' | 'opus1' | '123' | '1.png' | 200
}

void "getOpusList should be provided"() {
setup:
Expand All @@ -192,4 +193,4 @@ class ApiControllerSpec extends Specification implements ControllerUnitTest<ApiC
response.status == 200

}
}
}
14 changes: 14 additions & 0 deletions src/test/groovy/au/org/ala/profile/hub/OpusControllerSpec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -202,4 +202,18 @@ class OpusControllerSpec extends Specification implements ControllerUnitTest<Opu
then:
assert response.json == [opus1, opus2, opus3, opus4]
}
def "new categories should return a model with the expected number of elements"() {
setup:
mockProfileService.getCategories() >> [[key: 'key1', title: 'title1'],[key: 'key2', title: 'title2'],[key: 'key3', title: 'title3']]

when:
controller.getCategories()

then:
assert response.json.size() == 3
assert response.json.toString().contains("key1")
assert response.json.toString().contains("key2")
assert response.json.toString().contains("key3")
}
}

0 comments on commit 01475b0

Please sign in to comment.