Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import dbschema from '../../../../database.json'
const { DB_PASS: rootPass, DB_URL: url } = process.env

describe('given the load affiliations by org id function', () => {
let query, drop, truncate, collections, user, org, userTwo, i18n
let query, drop, truncate, collections, db, user, org, userTwo, i18n

const consoleOutput = []
const mockedError = (output) => consoleOutput.push(output)
Expand All @@ -28,7 +28,7 @@ describe('given the load affiliations by org id function', () => {

describe('given a successful load', () => {
beforeAll(async () => {
;({ query, drop, truncate, collections } = await ensure({
;({ query, drop, truncate, collections, db } = await ensure({
variables: {
dbname: dbNameFromFile(__filename),
username: 'root',
Expand Down Expand Up @@ -403,18 +403,6 @@ describe('given the load affiliations by org id function', () => {
})
orgOne = await collections.organizations.save({
verified: false,
summaries: {
web: {
pass: 50,
fail: 1000,
total: 1050,
},
mail: {
pass: 50,
fail: 1000,
total: 1050,
},
},
orgDetails: {
en: {
slug: 'slug-org-a',
Expand All @@ -438,6 +426,12 @@ describe('given the load affiliations by org id function', () => {
},
},
})
const orgOneSummary = await collections.organizationSummaries.save({
organization: orgOne._id,
web: { pass: 50, fail: 1000, total: 1050 },
mail: { pass: 50, fail: 1000, total: 1050 },
})
await db.collection('organizations').update(orgOne._key, { latestSummaryId: orgOneSummary._id })
affOne = await collections.affiliations.save({
_key: '1',
_from: orgOne._id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import dbschema from '../../../../database.json'
const { DB_PASS: rootPass, DB_URL: url } = process.env

describe('given the load affiliations by user id function', () => {
let query, drop, truncate, collections, user, orgOne, orgTwo, i18n
let query, drop, truncate, collections, db, user, orgOne, orgTwo, i18n

const consoleOutput = []
const mockedError = (output) => consoleOutput.push(output)
Expand All @@ -31,7 +31,7 @@ describe('given the load affiliations by user id function', () => {
describe('given there are user affiliations to be returned', () => {
let affOne, affTwo
beforeAll(async () => {
;({ query, drop, truncate, collections } = await ensure({
;({ query, drop, truncate, collections, db } = await ensure({
variables: {
dbname: dbNameFromFile(__filename),
username: 'root',
Expand Down Expand Up @@ -513,18 +513,6 @@ describe('given the load affiliations by user id function', () => {
})
orgOne = await collections.organizations.save({
verified: false,
summaries: {
web: {
pass: 50,
fail: 1000,
total: 1050,
},
mail: {
pass: 50,
fail: 1000,
total: 1050,
},
},
orgDetails: {
en: {
slug: 'slug-org-a',
Expand All @@ -548,20 +536,15 @@ describe('given the load affiliations by user id function', () => {
},
},
})
const orgOneSummary = await collections.organizationSummaries.save({
organization: orgOne._id,
web: { pass: 50, fail: 1000, total: 1050 },
mail: { pass: 50, fail: 1000, total: 1050 },
})
await db.collection('organizations').update(orgOne._key, { latestSummaryId: orgOneSummary._id })

orgTwo = await collections.organizations.save({
verified: false,
summaries: {
web: {
pass: 51,
fail: 1001,
total: 1052,
},
mail: {
pass: 51,
fail: 1001,
total: 1052,
},
},
orgDetails: {
en: {
slug: 'slug-org-b',
Expand All @@ -585,20 +568,15 @@ describe('given the load affiliations by user id function', () => {
},
},
})
const orgTwoSummary = await collections.organizationSummaries.save({
organization: orgTwo._id,
web: { pass: 51, fail: 1001, total: 1052 },
mail: { pass: 51, fail: 1001, total: 1052 },
})
await db.collection('organizations').update(orgTwo._key, { latestSummaryId: orgTwoSummary._id })

orgThree = await collections.organizations.save({
verified: false,
summaries: {
web: {
pass: 52,
fail: 1002,
total: 1054,
},
mail: {
pass: 52,
fail: 1002,
total: 1054,
},
},
orgDetails: {
en: {
slug: 'slug-org-c',
Expand All @@ -622,6 +600,12 @@ describe('given the load affiliations by user id function', () => {
},
},
})
const orgThreeSummary = await collections.organizationSummaries.save({
organization: orgThree._id,
web: { pass: 52, fail: 1002, total: 1054 },
mail: { pass: 52, fail: 1002, total: 1054 },
})
await db.collection('organizations').update(orgThree._key, { latestSummaryId: orgThreeSummary._id })
affOne = await collections.affiliations.save({
_key: '1',
_from: orgOne._id,
Expand Down
Loading
Loading