mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-03-25 10:02:27 -04:00
* Test * Add pretty formatting * Fix Tests * Fix Tests * Fix Tests * Fix * Add pretty formatting fix * Fix * Test * Fix tests * Clean typeckech * Add prettier check * Fix api tsconfig * Fix api tsconfig * Fix tsconfig * Fix * Fix * Prettier
39 lines
1.0 KiB
TypeScript
39 lines
1.0 KiB
TypeScript
jest.mock('common/geodb')
|
|
|
|
import {AuthedUser} from 'api/helpers/endpoint'
|
|
import {searchLocation} from 'api/search-location'
|
|
import * as geodbModules from 'common/geodb'
|
|
|
|
describe('searchLocation', () => {
|
|
beforeEach(() => {
|
|
jest.resetAllMocks()
|
|
})
|
|
afterEach(() => {
|
|
jest.restoreAllMocks()
|
|
})
|
|
|
|
describe('when given valid input', () => {
|
|
it('should return search location', async () => {
|
|
const mockBody = {
|
|
term: 'mockTerm',
|
|
limit: 15,
|
|
}
|
|
const mockAuth = {uid: '321'} as AuthedUser
|
|
const mockReq = {} as any
|
|
const mockReturn = 'Pass'
|
|
|
|
;(geodbModules.geodbFetch as jest.Mock).mockResolvedValue(mockReturn)
|
|
|
|
const result = await searchLocation(mockBody, mockAuth, mockReq)
|
|
|
|
expect(result).toBe(mockReturn)
|
|
expect(geodbModules.geodbFetch).toBeCalledTimes(1)
|
|
expect(geodbModules.geodbFetch).toBeCalledWith(
|
|
expect.stringContaining(
|
|
`/cities?namePrefix=${mockBody.term}&limit=${mockBody.limit}&offset=0&sort=-population`,
|
|
),
|
|
)
|
|
})
|
|
})
|
|
})
|