Created
December 24, 2016 17:09
-
-
Save bleonard/4318ec9a957af2451b2c6b1004a7bd70 to your computer and use it in GitHub Desktop.
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
// name the test something relevant | |
it("should create a new post", function* (driver, done) { | |
// stub the fetch request to get the initial lists of posts with commonly used json | |
server.get("/api/posts/tester", fixtures.home()); | |
// stub creation and set expectations of endpoint to create new post | |
server.post("/api/posts", | |
{id: 100, content: 'new post here', username: 'tester'}, // return this content | |
{content: 'new post here'} // expect this content | |
); | |
// automatically log the test user in | |
yield bootstrap().login().launch(driver); | |
// tap the upper right to create a new post | |
yield driver.elementById('+').click(); | |
// make sure the screen when there | |
yield driver.elementById('New Post'); | |
// type in some stuff | |
yield driver.execute("target.frontMostApp().keyboard().typeString('new post here')"); | |
// tap the submit button | |
yield driver.elementById('Submit').click(); | |
// check that we are back on the dashboard | |
yield driver.elementById('Dashboard'); | |
// make sure the new post is there | |
yield driver.elementById('new post here'); | |
// all done! | |
done(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment