message: catalog-backend: add some missing location unit tests
diff: @@ -265,6 +265,33 @@ describe('createRouter readonly disabled', () => {
  });
  });
  + describe('GET /locations/:id', () => {
  + it('happy path: gets location by id', async () => {
  + const location: Location = {
  + id: 'foo',
  + type: 'url',
  + target: 'example.com',
  + };
  + locationService.getLocation.mockResolvedValueOnce(location);
  +
  + const response = await request(app)
  + .get('/locations/foo')
  + .set('authorization', 'Bearer someauthtoken');
  +
  + expect(locationService.getLocation).toHaveBeenCalledTimes(1);
  + expect(locationService.getLocation).toHaveBeenCalledWith('foo', {
  + authorizationToken: 'someauthtoken',
  + });
  +
  + expect(response.status).toEqual(200);
  + expect(response.body).toEqual({
  + id: 'foo',
  + target: 'example.com',
  + type: 'url',
  + });
  + });
  + });
  +
  describe('POST /locations', () => {
  it('rejects malformed locations', async () => {
  const spec = {
  @@ -337,6 +364,23 @@ describe('createRouter readonly disabled', () => {
  );
  });
  });
  +
  + describe('DELETE /locations', () => {
  + it('deletes the location', async () => {
  + locationService.deleteLocation.mockResolvedValueOnce(undefined);
  +
  + const response = await request(app)
  + .delete('/locations/foo')
  + .set('authorization', 'Bearer someauthtoken');
  +
  + expect(locationService.deleteLocation).toHaveBeenCalledTimes(1);
  + expect(locationService.deleteLocation).toHaveBeenCalledWith('foo', {
  + authorizationToken: 'someauthtoken',
  + });
  +
  + expect(response.status).toEqual(204);
  + });
  + });
  });
  describe('createRouter readonly enabled', () => {
  @@ -430,6 +474,33 @@ describe('createRouter readonly enabled', () => {
  });
  });
  + describe('GET /locations/:id', () => {
  + it('happy path: gets location by id', async () => {
  + const location: Location = {
  + id: 'foo',
  + type: 'url',
  + target: 'example.com',
  + };
  + locationService.getLocation.mockResolvedValueOnce(location);
  +
  + const response = await request(app)
  + .get('/locations/foo')
  + .set('authorization', 'Bearer someauthtoken');
  +
  + expect(locationService.getLocation).toHaveBeenCalledTimes(1);
  + expect(locationService.getLocation).toHaveBeenCalledWith('foo', {
  + authorizationToken: 'someauthtoken',
  + });
  +
  + expect(response.status).toEqual(200);
  + expect(response.body).toEqual({
  + id: 'foo',
  + target: 'example.com',
  + type: 'url',
  + });
  + });
  + });
  +
  describe('POST /locations', () => {
  it('is not allowed', async () => {
  const spec: LocationSpec = {
  @@ -475,6 +546,17 @@ describe('createRouter readonly enabled', () => {
  );
  });
  });
  +
  + describe('DELETE /locations', () => {
  + it('is not allowed', async () => {
  + const response = await request(app)
  + .delete('/locations/foo')
  + .set('authorization', 'Bearer someauthtoken');
  +
  + expect(locationService.deleteLocation).not.toHaveBeenCalled();
  + expect(response.status).toEqual(403);
  + });
  + });
  });
  describe('NextRouter permissioning', () => {
  