Skip to content

Commit

Permalink
GQL-85: Putting test under collection
Browse files Browse the repository at this point in the history
  • Loading branch information
mandyparson committed Nov 15, 2024
1 parent cd69773 commit a71d8b6
Showing 1 changed file with 94 additions and 96 deletions.
190 changes: 94 additions & 96 deletions src/resolvers/__tests__/collection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -708,110 +708,108 @@ describe('Collection', () => {
collection: null
})
})
})
})

describe('collection', () => {
describe('when retrieving revisions that contain tombstones', () => {
test('includes them in the results', async () => {
nock(/example-cmr/)
.defaultReplyHeaders({
'CMR-Hits': 1,
'CMR-Took': 7,
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.get(/collections\.json/)
.reply(200, {
feed: {
entry: [{
id: 'C100001-EDSC'
}],
facets: {}
}
})

nock(/example-cmr/)
.defaultReplyHeaders({
'CMR-Hits': 3,
'CMR-Took': 7,
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.get('/search/collections.umm_json?all_revisions=true&concept_id=C100001-EDSC')
.reply(200, {
items: [{
meta: {
'concept-id': 'C100001-EDSC',
'revision-id': '3',
deleted: false
},
umm: {
Abstract: 'Cras mattis consectetur purus sit amet fermentum.'
}
}, {
meta: {
'concept-id': 'C100001-EDSC',
'revision-id': '2',
deleted: true
}
}, {
meta: {
'concept-id': 'C100001-EDSC',
'revision-id': '1',
deleted: false
},
umm: {
Abstract: 'Cras mattis consectetur purus sit amet fermentum.'
}
}]
})
describe('when retrieving revisions that contain tombstones', () => {
test('includes them in the results', async () => {
nock(/example-cmr/)
.defaultReplyHeaders({
'CMR-Hits': 1,
'CMR-Took': 7,
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.get(/collections\.json/)
.reply(200, {
feed: {
entry: [{
id: 'C100001-EDSC'
}],
facets: {}
}
})

nock(/example-cmr/)
.defaultReplyHeaders({
'CMR-Hits': 3,
'CMR-Took': 7,
'CMR-Request-Id': 'abcd-1234-efgh-5678'
})
.get('/search/collections.umm_json?all_revisions=true&concept_id=C100001-EDSC')
.reply(200, {
items: [{
meta: {
'concept-id': 'C100001-EDSC',
'revision-id': '3',
deleted: false
},
umm: {
Abstract: 'Cras mattis consectetur purus sit amet fermentum.'
}
}, {
meta: {
'concept-id': 'C100001-EDSC',
'revision-id': '2',
deleted: true
}
}, {
meta: {
'concept-id': 'C100001-EDSC',
'revision-id': '1',
deleted: false
},
umm: {
Abstract: 'Cras mattis consectetur purus sit amet fermentum.'
}
}]
})

const response = await server.executeOperation({
variables: {},
query: `{
collections {
count
facets
items {
conceptId
revisions {
count
items {
revisionId
const response = await server.executeOperation({
variables: {},
query: `{
collections {
count
facets
items {
conceptId
revisions {
count
items {
revisionId
}
}
}
}
}
}`
}, {
contextValue
})
}`
}, {
contextValue
})

const { data, errors } = response.body.singleResult
const { data, errors } = response.body.singleResult

expect(errors).toBeUndefined()
expect(errors).toBeUndefined()

expect(data).toEqual({
collections: {
count: 1,
facets: {},
items: [{
conceptId: 'C100001-EDSC',
revisions: {
count: 3,
items: [
{
revisionId: '3'
},
{
revisionId: '2'
},
{
revisionId: '1'
}
]
}
}]
}
expect(data).toEqual({
collections: {
count: 1,
facets: {},
items: [{
conceptId: 'C100001-EDSC',
revisions: {
count: 3,
items: [
{
revisionId: '3'
},
{
revisionId: '2'
},
{
revisionId: '1'
}
]
}
}]
}
})
})
})
})
Expand Down

0 comments on commit a71d8b6

Please sign in to comment.