Skip to content

Commit 4fb9f5e

Browse files
GQL-109: Fix test
1 parent 3d51c14 commit 4fb9f5e

1 file changed

Lines changed: 33 additions & 46 deletions

File tree

src/datasources/__tests__/graphDbAssociatedCitations.test.js

Lines changed: 33 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -147,41 +147,41 @@ describe('graphDbAssociatedCitations', () => {
147147

148148
expect(response).toEqual(associatedCitationsResponseMocks)
149149
})
150-
})
151-
152-
describe('when the response from graphdb is empty', () => {
153-
test('returns an empty citations array with count 0', async () => {
154-
const getUserGroups = vi.spyOn(getUserPermittedGroups, 'getUserPermittedGroups')
155-
getUserGroups.mockImplementationOnce(() => '"guest","registered"')
156-
157-
nock(/example-graphdb/)
158-
.post('/', (body) => {
159-
const { gremlin } = body
160-
161-
return gremlin
162-
&& gremlin.includes("hasLabel('citation')")
163-
&& gremlin.includes("has('collection', 'id', 'C1200000035-PROV2')")
164-
&& gremlin.includes('.project(\'citationData\', \'associationLevel\', \'relationshipType\')')
165-
&& gremlin.includes('.range(0, 1)')
166-
})
167-
.reply(200, associatedCitationsGraphdbEmptyResponseMock)
168150

169-
const response = await graphDbAssociatedCitations(
170-
{ conceptId: 'C1200000035-PROV2' },
171-
{ limit: 1 },
172-
{
173-
headers: {
174-
'Client-Id': 'eed-test-graphql',
175-
'CMR-Request-Id': 'abcd-1234-efgh-5678'
151+
describe('when the response from graphdb is empty', () => {
152+
test('returns an empty citations array with count 0', async () => {
153+
const getUserGroups = vi.spyOn(getUserPermittedGroups, 'getUserPermittedGroups')
154+
getUserGroups.mockImplementationOnce(() => '"guest","registered"')
155+
156+
nock(/example-graphdb/)
157+
.post('/', (body) => {
158+
const { gremlin } = body
159+
160+
return gremlin
161+
&& gremlin.includes("hasLabel('citation')")
162+
&& gremlin.includes("has('collection', 'id', 'C1200000035-PROV2')")
163+
&& gremlin.includes('.project(\'citationData\', \'associationLevel\', \'relationshipType\')')
164+
&& gremlin.includes('.range(0, 1)')
165+
})
166+
.reply(200, associatedCitationsGraphdbEmptyResponseMock)
167+
168+
const response = await graphDbAssociatedCitations(
169+
{ conceptId: 'C1200000035-PROV2' },
170+
{ limit: 1 },
171+
{
172+
headers: {
173+
'Client-Id': 'eed-test-graphql',
174+
'CMR-Request-Id': 'abcd-1234-efgh-5678'
175+
},
176+
edlUsername: 'testUser'
176177
},
177-
edlUsername: 'testUser'
178-
},
179-
parsedInfo
180-
)
178+
parsedInfo
179+
)
181180

182-
expect(response).toEqual({
183-
count: 0,
184-
items: []
181+
expect(response).toEqual({
182+
count: 0,
183+
items: []
184+
})
185185
})
186186
})
187187
})
@@ -256,24 +256,11 @@ describe('graphDbAssociatedCitations', () => {
256256
}
257257
})
258258

259-
// TODO fix while its running with other tests
260-
test.skip('returns an empty set of citations', async () => {
259+
test('returns an empty set of citations and does not make a request to graphdb', async () => {
261260
process.env.runGraphdb = 'false'
262261
const getUserGroups = vi.spyOn(getUserPermittedGroups, 'getUserPermittedGroups')
263262
getUserGroups.mockImplementationOnce(() => '"guest","registered"')
264263

265-
nock(/example-graphdb/)
266-
.post('/', (body) => {
267-
const { gremlin } = body
268-
269-
return gremlin
270-
&& gremlin.includes("hasLabel('citation')")
271-
&& gremlin.includes("has('collection', 'id', 'C1200000035-PROV2')")
272-
&& gremlin.includes('.project(\'citationData\', \'associationLevel\', \'relationshipType\')')
273-
&& gremlin.includes('.range(0, 1)')
274-
})
275-
.reply(200, associatedCitationsGraphdbResponseMocks)
276-
277264
const response = await graphDbAssociatedCitations(
278265
{ conceptId: 'C1200000035-PROV2' },
279266
{ limit: 1 },

0 commit comments

Comments
 (0)