Skip to content
This repository has been archived by the owner on Aug 6, 2019. It is now read-only.

Commit

Permalink
Better testing for api using jest.
Browse files Browse the repository at this point in the history
  • Loading branch information
gigatoride committed Sep 13, 2018
1 parent d3c2386 commit 83cd731
Showing 1 changed file with 85 additions and 0 deletions.
85 changes: 85 additions & 0 deletions test/api.test.js
@@ -0,0 +1,85 @@
const utopian = require("../src/api");

jest.setTimeout(30000);

//Retrieve projects statistics
test("returns true for username favcau as a moderator", async () => {
expect(await utopian.isModerator('favcau')).toBe(
true
);
});

test("returns an array for projects statistics by status and category", async () => {
expect(Array.isArray(await utopian.stats.getProjects("social", true))).toBe(
true
);
});

//Retrieve contributors statistics
test("returns an array of objects for contributors statistics by status and category", async () => {
expect(
Array.isArray(
await utopian.stats.getContributors("social", "reviewed", false)
)
).toBe(true);
});

// Retrieve moderators
test("returns an array for all moderators", async () => {
expect(Array.isArray(await utopian.getModerators())).toBe(true);
});

// Retrieve posts by category and status
test("returns an array of objects for posts by category.", async () => {
expect(Array.isArray(await utopian.getPosts("task-copywriting"))).toBe(true);
});

// Retrieve posts by category and status
test("returns an array of objects for posts by category, status", async () => {
expect(
Array.isArray(await utopian.getPosts("task-copywriting", "reviewed"))
).toBe(true);
});

// Retrieve posts by category,status,staff_picked
test("returns an array of objects for posts by category, status, staff picks", async () => {
expect(
Array.isArray(
await utopian.getPosts("development", "pending", null, null, true)
)
).toBe(true);
});

// Retrieve posts by category,status,staff_picked
test("returns an array of objects for posts by category, status, author, non-staff picks", async () => {
expect(
Array.isArray(
await utopian.getPosts(
"development",
"reviewed",
"gigatoride",
null,
false
)
)
).toBe(true);
});

// Retrieve all pending posts
test("returns an array of objects for all posts by status", async () => {
expect(Array.isArray(await utopian.getPosts("pending"))).toBe(true);
});

// Retrieve all projects statistics
test("returns an array of objects by date and section statistics", async () => {
expect(Array.isArray(await utopian.stats.getModeratorsByDate("today"))).toBe(
true
);
});

// Retrieve all statistics
test("returns an array of objects by date for all section statistics", async () => {
expect(Array.isArray(await utopian.stats.getProjectsByDate("today"))).toBe(
true
);
});

0 comments on commit 83cd731

Please sign in to comment.