Skip to content

Commit 835e754

Browse files
committed
post tests
1 parent d6847b2 commit 835e754

File tree

2 files changed

+72
-0
lines changed

2 files changed

+72
-0
lines changed

test/helpers/fixtures.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,16 @@ var Fixtures = {
1919
};
2020
},
2121

22+
friend: function() {
23+
return {
24+
username: 'friend',
25+
posts: [
26+
{ id: 3, content: "post3", username: "friend" },
27+
{ id: 4, content: "post4", username: "friend" }
28+
]
29+
};
30+
},
31+
2232
error: function(message, status, key, code) {
2333
return {
2434
status: (status ? status : 422),

test/integration/posts.test.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import it, {itOnly} from '../helpers/appium';
2+
import server from '../helpers/server';
3+
import fixtures from '../helpers/fixtures';
4+
import bootstrap from '../helpers/bootstrap';
5+
6+
describe.only("Posts", () => {
7+
it("should show my posts", function* (driver, done) {
8+
server.get("/api/posts/tester", fixtures.home());
9+
10+
yield bootstrap().login().nav("dashboard").launch(driver);
11+
12+
yield driver.elementById('Dashboard');
13+
yield driver.elementById('post1');
14+
15+
done();
16+
});
17+
18+
it("should show an empty list", function* (driver, done) {
19+
server.get("/api/posts/tester", { username: "tester", posts: [] });
20+
21+
yield bootstrap().login().nav("dashboard").launch(driver);
22+
23+
yield driver.elementById('Dashboard');
24+
yield driver.elementById('No items');
25+
26+
done();
27+
});
28+
29+
it("should my friends's posts", function* (driver, done) {
30+
server.get("/api/posts/friend", fixtures.friend());
31+
32+
yield bootstrap().login().nav("dashboard/follows/friend").launch(driver);
33+
34+
yield driver.elementById('friend');
35+
yield driver.elementById('post3');
36+
37+
done();
38+
});
39+
40+
it("should create a new post", function* (driver, done) {
41+
var list = fixtures.home();
42+
server.get("/api/posts/tester", list);
43+
server.post("/api/posts", {id: 100, content: 'new post here', username: 'tester' });
44+
45+
yield bootstrap().login().launch(driver);
46+
47+
yield driver.elementById('+').click(); // new post!
48+
49+
yield driver.elementById('New Post');
50+
51+
yield driver.execute("target.frontMostApp().keyboard().typeString('new post here')");
52+
53+
yield driver.elementById('Submit').click();
54+
55+
yield driver.elementById('Dashboard');
56+
57+
yield driver.elementById('new post here'); // it's there!
58+
59+
done();
60+
});
61+
62+
});

0 commit comments

Comments
 (0)