Skip to content

Instantly share code, notes, and snippets.

@ianpetzer
Last active December 18, 2015 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ianpetzer/5780226 to your computer and use it in GitHub Desktop.
Save ianpetzer/5780226 to your computer and use it in GitHub Desktop.
test("Check editing of a book updates search results", function() {
expect(7);
visit("/").then(function() {
return click("#searchButton"); //Click the search button
}).then(function() {
throws(
function() {
find(".searchResult h2:contains('The Great Modification')") ;
},
"No existing called the Great Modification"
);
return click(".searchResult h2:contains('The Great Gatsby') ~ a"); //Select the search result for The Great Gatsby
}).then(function() {
equal($.trim(find(".tags ul li:first").text()), "Fiction", "Found first tag");
equal($.trim(find(".tags ul li:eq(1)").text()), "Classic", "Found second tag");
return click("#editBook"); //Click the search button
}).then(function() {
equal(find(".titleInputBox").val(), "The Great Gatsby", "Found book title input box");
fillIn(".titleInputBox", ".editBook", "The Great Modification");
equal(find(".titleInputBox").val(), "The Great Modification", "Title of book changed on edit page");
return click(".saveEditsToBook"); //Save the changes
}).then(function() {
return click("#searchButton"); //Click the search button
}).then(function() {
ok(exists(".searchResult h2:contains('The Great Modification')"), "Retrieved modified title from search list");
throws(
function() {
find(".searchResult h2:contains('The Great Gatsby')") ;
},
"The Great Gatbsy title has been changed in the search results!"
);
});
@bit-dragon
Copy link

Should be good to rename .txt to .js to be more easy to read. Btw it is a good example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment