FIX: Recovering a post does not insert it back into the stream correctly.

This commit is contained in:
Guo Xiang Tan
2018-06-29 11:41:44 +08:00
parent 252e5574cc
commit d1c3eb6bfa
3 changed files with 41 additions and 4 deletions

View File

@ -681,6 +681,40 @@ QUnit.test("loadedAllPosts when the id changes", assert => {
);
});
QUnit.test("triggerRecoveredPost", async assert => {
const postStream = buildStream(4567);
const store = postStream.store;
[1, 2, 3, 5].forEach(id => {
postStream.appendPost(
store.createRecord("post", { id: id, post_number: id })
);
});
const response = object => {
return [200, { "Content-Type": "application/json" }, object];
};
// prettier-ignore
server.get("/posts/4", () => { // eslint-disable-line no-undef
return response({ id: 4, post_number: 4 });
});
assert.equal(
postStream.get("postsWithPlaceholders.length"),
4,
"it should return the right length"
);
await postStream.triggerRecoveredPost(4);
assert.equal(
postStream.get("postsWithPlaceholders.length"),
5,
"it should return the right length"
);
});
QUnit.test("comitting and triggerNewPostInStream race condition", assert => {
const postStream = buildStream(4964);
const store = postStream.store;