diff --git a/x-pack/legacy/plugins/alerting/server/routes/create.test.ts b/x-pack/legacy/plugins/alerting/server/routes/create.test.ts index d37d07ad2d1b..2a0ae78fd78b 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/create.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/create.test.ts @@ -20,6 +20,7 @@ const mockedAlert = { params: { bar: true, }, + throttle: '30s', actions: [ { group: 'default', @@ -31,17 +32,6 @@ const mockedAlert = { ], }; -const mockedAlertComputerFields = { - enabled: true, - muteAll: false, - createdBy: '', - updatedBy: '', - apiKey: '', - apiKeyOwner: '', - throttle: '30s', - mutedInstanceIds: [], -}; - beforeEach(() => jest.resetAllMocks()); test('creates an alert with proper parameters', async () => { @@ -55,7 +45,13 @@ test('creates an alert with proper parameters', async () => { const updatedAt = new Date(); alertsClient.create.mockResolvedValueOnce({ ...mockedAlert, - ...mockedAlertComputerFields, + enabled: true, + muteAll: false, + createdBy: '', + updatedBy: '', + apiKey: '', + apiKeyOwner: '', + mutedInstanceIds: [], createdAt, updatedAt, id: '123', @@ -70,7 +66,7 @@ test('creates an alert with proper parameters', async () => { expect(statusCode).toBe(200); const response = JSON.parse(payload); expect(new Date(response.createdAt)).toEqual(createdAt); - expect(omit(response, 'createdAt')).toMatchInlineSnapshot(` + expect(omit(response, 'createdAt', 'updatedAt')).toMatchInlineSnapshot(` Object { "actions": Array [ Object { @@ -102,7 +98,6 @@ test('creates an alert with proper parameters', async () => { "foo", ], "throttle": "30s", - "updatedAt": null, "updatedBy": "", } `); @@ -133,7 +128,7 @@ test('creates an alert with proper parameters', async () => { "tags": Array [ "foo", ], - "throttle": null, + "throttle": "30s", }, }, ] diff --git a/x-pack/legacy/plugins/alerting/server/routes/get.test.ts b/x-pack/legacy/plugins/alerting/server/routes/get.test.ts index 0609e56ce069..320e9042d87c 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/get.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/get.test.ts @@ -53,8 +53,10 @@ test('calls get with proper parameters', async () => { alertsClient.get.mockResolvedValueOnce(mockedAlert); const { payload, statusCode } = await server.inject(request); expect(statusCode).toBe(200); - const { createdAt, ...response } = JSON.parse(payload); - expect({ createdAt: new Date(createdAt), ...response }).toEqual(mockedAlert); + const { createdAt, updatedAt, ...response } = JSON.parse(payload); + expect({ createdAt: new Date(createdAt), updatedAt: new Date(updatedAt), ...response }).toEqual( + mockedAlert + ); expect(alertsClient.get).toHaveBeenCalledTimes(1); expect(alertsClient.get.mock.calls[0]).toMatchInlineSnapshot(` Array [