Skip to content

Commit

Permalink
Add test for curator API #2559
Browse files Browse the repository at this point in the history
  • Loading branch information
iamleeg committed Mar 14, 2022
1 parent 8fee379 commit d096007
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions verification/curator-service/api/test/geocode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as baseUser from './users/base.json';
import { MongoMemoryServer } from 'mongodb-memory-server';
import app from '../src/index';
import axios from 'axios';
import mongoose from 'mongoose';
import supertest from 'supertest';

jest.mock('../src/clients/email-client', () => {
Expand Down Expand Up @@ -69,6 +70,31 @@ describe('Geocode', () => {
'http://location/geocode/convertUTM?n=12&e=7&z=3',
);
});
it('combines proxied and local results for resolving country names', async () => {
const mongoClient = mongoose.connection.getClient();
// add a not-real-case document
await mongoClient.db().collection('cases').insertOne({
location: {
country: 'EE',
},
});
mockedAxios.get.mockResolvedValueOnce({
status: 200,
statusText: 'OK',
data: 'Ainotse',
});
const res = await curatorRequest
.get('/api/geocode/countryNames')
.expect(200)
.expect('Content-Type', /json/);
expect(res.body.length == 2);
expect(res.body[0] === 'Estonia');
expect(res.body[1] === 'Ainotse');
expect(mockedAxios.get).toHaveBeenCalledTimes(1);
expect(mockedAxios.get).toHaveBeenCalledWith(
'http://location/geocode/countryName?c=EE',
);
});
it('proxies clear calls', async () => {
mockedAxios.post.mockResolvedValueOnce({
status: 200,
Expand Down

0 comments on commit d096007

Please sign in to comment.