Skip to content

Commit

Permalink
Merge branch 'wip/fetch-test' into wip/discourse-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
Beanow committed Nov 20, 2019
2 parents a6b0d8e + 09b87ba commit 136369f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/plugins/discourse/fetch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("plugins/discourse/fetch", () => {
expectError("latestPosts", (x) => x.latestPosts(), 403);
expectError("latestPosts", (x) => x.latestPosts(), 429);

expectError("topic", (x) => x.topicWithPosts(14), 429);
expectError("topicWithPosts", (x) => x.topicWithPosts(14), 429);
expectError("post", (x) => x.post(14), 429);
expectError(
"categoryDefinitionTopicIds",
Expand All @@ -77,6 +77,8 @@ describe("plugins/discourse/fetch", () => {
(x) => x.categoryDefinitionTopicIds(),
429
);
expectError("likesByUser", (x) => x.likesByUser("dl-proto", 0), 403);
expectError("likesByUser", (x) => x.likesByUser("dl-proto", 0), 429);

function expectNull(name, f, status) {
it(`${name} returns null on ${String(status)}`, async () => {
Expand All @@ -86,8 +88,8 @@ describe("plugins/discourse/fetch", () => {
});
}

expectNull("topic", (x) => x.topicWithPosts(14), 404);
expectNull("topic", (x) => x.topicWithPosts(14), 403);
expectNull("topicWithPosts", (x) => x.topicWithPosts(14), 404);
expectNull("topicWithPosts", (x) => x.topicWithPosts(14), 403);
expectNull("post", (x) => x.post(14), 404);
expectNull("post", (x) => x.post(14), 403);
});
Expand All @@ -99,7 +101,7 @@ describe("plugins/discourse/fetch", () => {
fetchOptions = _options;
return Promise.resolve(new Response("", {status: 404}));
};
await new Fetcher(options, fakeFetch, 0).post(1337);
await new Fetcher(options, fakeFetch, 0).topicWithPosts(1337);
if (fetchOptions == null) {
throw new Error("fetchOptions == null");
}
Expand Down

0 comments on commit 136369f

Please sign in to comment.