Skip to content

Commit

Permalink
Add cellect API to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eatyourgreens committed Feb 8, 2021
1 parent f92e3ee commit 7b27884
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ const TRANSLATIONS = [
}
]

const availableSubjects = {
1: 4,
2: 10,
3: 10
}
function subjectSet(id) {
return {
id,
Expand All @@ -46,6 +51,23 @@ function subjectSet(id) {
}

describe('Helpers > fetchWorkflowsHelper', function () {
before(function () {
const cellect = nock('https://cellect.zooniverse.org')
.persist()
.get('/workflows/1/status')
.reply(200, {
groups: availableSubjects
})
.get('/workflows/2/status')
.reply(200, {
groups: availableSubjects
})
})

after(function () {
nock.cleanAll()
})

it('should provide the expected result with a single workflow', async function () {
const scope = nock('https://panoptes-staging.zooniverse.org/api')
.get('/translations')
Expand Down Expand Up @@ -76,9 +98,9 @@ describe('Helpers > fetchWorkflowsHelper', function () {
id: '1',
displayName: 'Foo',
subjectSets: [
subjectSet('1'),
subjectSet('2'),
subjectSet('3')
Object.assign(subjectSet('1'), { availableSubjects: availableSubjects[1]}),
Object.assign(subjectSet('2'), { availableSubjects: availableSubjects[2]}),
Object.assign(subjectSet('3'), { availableSubjects: availableSubjects[3]})
]
}
])
Expand Down Expand Up @@ -113,9 +135,9 @@ describe('Helpers > fetchWorkflowsHelper', function () {
id: '1',
displayName: 'Foo',
subjectSets: [
subjectSet('1'),
subjectSet('2'),
subjectSet('3')
Object.assign(subjectSet('1'), { availableSubjects: availableSubjects[1]}),
Object.assign(subjectSet('2'), { availableSubjects: availableSubjects[2]}),
Object.assign(subjectSet('3'), { availableSubjects: availableSubjects[3]})
]
},
{
Expand All @@ -125,9 +147,9 @@ describe('Helpers > fetchWorkflowsHelper', function () {
id: '2',
displayName: 'Bar',
subjectSets: [
subjectSet('1'),
subjectSet('2'),
subjectSet('3')
Object.assign(subjectSet('1'), { availableSubjects: availableSubjects[1]}),
Object.assign(subjectSet('2'), { availableSubjects: availableSubjects[2]}),
Object.assign(subjectSet('3'), { availableSubjects: availableSubjects[3]})
]
}
])
Expand Down Expand Up @@ -163,9 +185,9 @@ describe('Helpers > fetchWorkflowsHelper', function () {
id: '1',
displayName: 'Foo',
subjectSets: [
subjectSet('1'),
subjectSet('2'),
subjectSet('3')
Object.assign(subjectSet('1'), { availableSubjects: availableSubjects[1]}),
Object.assign(subjectSet('2'), { availableSubjects: availableSubjects[2]}),
Object.assign(subjectSet('3'), { availableSubjects: availableSubjects[3]})
]
},
{
Expand All @@ -175,9 +197,9 @@ describe('Helpers > fetchWorkflowsHelper', function () {
id: '2',
displayName: 'Bar',
subjectSets: [
subjectSet('1'),
subjectSet('2'),
subjectSet('3')
Object.assign(subjectSet('1'), { availableSubjects: availableSubjects[1]}),
Object.assign(subjectSet('2'), { availableSubjects: availableSubjects[2]}),
Object.assign(subjectSet('3'), { availableSubjects: availableSubjects[3]})
]
}
])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ describe('Components > ProjectHomePage > getDefaultPageProps', function () {
}
}

const availableSubjects = {
1: 4,
2: 10,
3: 10
}

function subjectSet(id) {
return {
id,
Expand All @@ -40,6 +46,12 @@ describe('Components > ProjectHomePage > getDefaultPageProps', function () {
describe('with the staging API', function () {
before(function () {
const slug = 'test-owner/test-project'
const cellect = nock('https://cellect.zooniverse.org')
.persist()
.get('/workflows/1/status')
.reply(200, {
groups: availableSubjects
})
const scope = nock('https://panoptes-staging.zooniverse.org/api')
.get('/projects')
.query(query => query.slug === slug)
Expand Down Expand Up @@ -69,6 +81,10 @@ describe('Components > ProjectHomePage > getDefaultPageProps', function () {
})
})

after(function () {
nock.cleanAll()
})

it('should return the project\'s active workflows', async function () {
const params = {
owner: 'test-owner',
Expand All @@ -95,9 +111,9 @@ describe('Components > ProjectHomePage > getDefaultPageProps', function () {
id: '1',
displayName: 'Foo',
subjectSets: [
subjectSet('1'),
subjectSet('2'),
subjectSet('3')
Object.assign(subjectSet('1'), { availableSubjects: availableSubjects[1]}),
Object.assign(subjectSet('2'), { availableSubjects: availableSubjects[2]}),
Object.assign(subjectSet('3'), { availableSubjects: availableSubjects[3]})
]
}
])
Expand All @@ -107,6 +123,12 @@ describe('Components > ProjectHomePage > getDefaultPageProps', function () {
describe('with the production API', function () {
before(function () {
const slug = 'test-owner/test-project'
const cellect = nock('https://cellect.zooniverse.org')
.persist()
.get('/workflows/1/status')
.reply(200, {
groups: availableSubjects
})
const scope = nock('https://www.zooniverse.org/api')
.get('/projects')
.query(query => query.slug === slug)
Expand Down Expand Up @@ -136,6 +158,10 @@ describe('Components > ProjectHomePage > getDefaultPageProps', function () {
})
})

after(function () {
nock.cleanAll()
})

it('should return the project\'s active workflows', async function () {
const params = {
owner: 'test-owner',
Expand All @@ -162,9 +188,9 @@ describe('Components > ProjectHomePage > getDefaultPageProps', function () {
id: '1',
displayName: 'Foo',
subjectSets: [
subjectSet('1'),
subjectSet('2'),
subjectSet('3')
Object.assign(subjectSet('1'), { availableSubjects: availableSubjects[1]}),
Object.assign(subjectSet('2'), { availableSubjects: availableSubjects[2]}),
Object.assign(subjectSet('3'), { availableSubjects: availableSubjects[3]})
]
}
])
Expand Down

0 comments on commit 7b27884

Please sign in to comment.