Skip to content

Commit

Permalink
tests for references view
Browse files Browse the repository at this point in the history
  • Loading branch information
iilumme committed Apr 26, 2016
1 parent cff7875 commit f73a32a
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/test/java/ohtuhatut/controller/ReferenceControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ public void getRequestToASpesificReferenceWorks() throws Exception {
.andReturn();
}

@Test
public void getRequestToAllReferencesWorks() throws Exception {

MvcResult result = mockMvc.perform(get(API_URI))
.andExpect(status().isOk())
.andExpect(model().attributeExists("references"))
.andExpect(view().name("references"))
.andReturn();
}


// -------------- book references

Expand Down
25 changes: 25 additions & 0 deletions src/test/java/ohtuhatut/selenium/ReferenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,26 @@ public void nonexistingReferenceCantBeEdited() {

assertTrue(pageSource().contains("Reference does not exist"));
}

@Test
public void referencesPageShowsAllTheExistingReferences() {
createAReference(1);
createAReference(2);
getToReferencesPage();

assertTrue(pageSource().contains("References"));
assertTrue(pageSource().contains("testTitle"));

}

@Test
public void referencesPageShowsNoReferencesWhenThereAreNoReferences() {
getToReferencesPage();

assertTrue(pageSource().contains("References"));
assertTrue(pageSource().contains("No references in the database at the moment"));

}

private void createAReference(int i) {
getToManualReferenceCreationPage();
Expand All @@ -194,6 +214,11 @@ private void createAReference(int i) {
submit(find("form").first());
}

private void getToReferencesPage() {
goTo(getUrl());
click(find("#references"));
}

private void getToReferenceCreationsChoosingPage() {
goTo(getUrl());
click(find("#reference-choose"));
Expand Down

0 comments on commit f73a32a

Please sign in to comment.