Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurell876 committed Jun 26, 2020
1 parent 95625ba commit 0d974a9
Showing 1 changed file with 45 additions and 38 deletions.
83 changes: 45 additions & 38 deletions tests/user_organization.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ beforeAll(async () => {
token = await getToken();
});

let createdOrgId = "test";

describe("User-Organization Resolvers", () => {
//ORGANIZATION IS CREATED

let createdOrgId;
test("createOrganization", async () => {
const response = await axios.post(
URL,
Expand All @@ -37,6 +38,7 @@ describe("User-Organization Resolvers", () => {
);
const { data } = response;
createdOrgId = data.data.createOrganization._id;
console.log(createdOrgId);
expect(data.data.createOrganization).toEqual(
expect.objectContaining({
_id: expect.any(String),
Expand All @@ -46,6 +48,7 @@ describe("User-Organization Resolvers", () => {
});

//NEW USER IS CREATED

let newUserToken;
let newUserId;
test("signUp", async () => {
Expand Down Expand Up @@ -78,7 +81,6 @@ describe("User-Organization Resolvers", () => {
});

//NEW USER JOINS ORGANIZATION

test("Join Public Organization", async () => {
const response = await axios.post(
URL,
Expand All @@ -99,7 +101,6 @@ describe("User-Organization Resolvers", () => {
},
}
);

const { data } = response;
expect(data.data.joinPublicOrganization).toEqual(
expect.objectContaining({
Expand All @@ -114,41 +115,47 @@ describe("User-Organization Resolvers", () => {
//NEW USER CREATES AN EVENT
let createdEventId;
test("User Creates Event", async () => {
const response = await axios.post(
URL,
{
query: `
mutation{
createEvent(data:{
title:"to be deleted"
description: "to be deleted"
recurring: false
attendees: "to be deleted"
isPublic: false
isRegisterable:false
organizationId: "${createdOrgId}"
}){
_id
}
}
}`,
},
{
headers: {
Authorization: `Bearer ${newUserToken}`,
try {
const response = await axios.post(
URL,
{
query: `
mutation{
createEvent(data:{
title:"to be deleted"
description: "to be deleted"
recurring: false
attendees: "to be deleted"
isPublic: false
isRegisterable:false
organizationId: "${createdOrgId}"
}){
_id
}
}`,
},
}
);
{
headers: {
Authorization: `Bearer ${newUserToken}`,
},
}
);

const { data } = response;
createdEventId = data.data.createEvent._id;
expect(data.data.createEvent).toEqual(
expect.objectContaining({
_id: expect(createdEventId),
})
);
});
const { data } = response;
createdEventId = data.data.createEvent._id;

expect(data.data.createEvent).toEqual(
expect.objectContaining({
_id: createdEventId,
})
);
} catch(e) {
console.log("an error has occurred")
console.log(e);
throw e
}

});

//USER IS MADE ADMIN
test("User is made admin", async () => {
Expand Down Expand Up @@ -197,7 +204,7 @@ describe("User-Organization Resolvers", () => {
_id
}
}
}`,
`,
},
{
headers: {
Expand All @@ -207,9 +214,9 @@ describe("User-Organization Resolvers", () => {
);

const { data } = response;
expect(data.data.createEvent).toEqual(
expect(data.data.adminRemoveEvent).toEqual(
expect.objectContaining({
_id: expect(createdEventId),
_id: createdEventId,
})
);
});
Expand Down

0 comments on commit 0d974a9

Please sign in to comment.