From 5a4057d39cc6b952c696a88363ecb267a285d933 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Fri, 3 Jan 2020 10:13:43 +0000 Subject: [PATCH 1/2] fixed tests --- .../alerting/server/routes/create.test.ts | 29 +------------------ .../alerting/server/routes/get.test.ts | 6 ++-- 2 files changed, 5 insertions(+), 30 deletions(-) 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 51b9668b6131a3..a614c70dc0271f 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/create.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/create.test.ts @@ -58,34 +58,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(` - Object { - "actions": Array [ - Object { - "actionTypeId": "test", - "group": "default", - "id": "2", - "params": Object { - "foo": true, - }, - }, - ], - "alertTypeId": "1", - "consumer": "bar", - "id": "123", - "name": "abc", - "params": Object { - "bar": true, - }, - "schedule": Object { - "interval": "10s", - }, - "tags": Array [ - "foo", - ], - "updatedAt": null, - } - `); + expect(omit(response, 'createdAt', 'updatedAt')).toMatchInlineSnapshot(); expect(alertsClient.create).toHaveBeenCalledTimes(1); expect(alertsClient.create.mock.calls[0]).toMatchInlineSnapshot(` Array [ 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 2ac7d257139f38..5b1bdc7f697086 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/get.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/get.test.ts @@ -42,8 +42,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 [ From 954a71a84c880a3cef2493dfd02e0677cc574f55 Mon Sep 17 00:00:00 2001 From: Gidi Meir Morris Date: Fri, 3 Jan 2020 10:14:36 +0000 Subject: [PATCH 2/2] fixed tests --- .../alerting/server/routes/create.test.ts | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 a614c70dc0271f..03b33b0bd40b0d 100644 --- a/x-pack/legacy/plugins/alerting/server/routes/create.test.ts +++ b/x-pack/legacy/plugins/alerting/server/routes/create.test.ts @@ -58,7 +58,33 @@ 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', 'updatedAt')).toMatchInlineSnapshot(); + expect(omit(response, 'createdAt', 'updatedAt')).toMatchInlineSnapshot(` + Object { + "actions": Array [ + Object { + "actionTypeId": "test", + "group": "default", + "id": "2", + "params": Object { + "foo": true, + }, + }, + ], + "alertTypeId": "1", + "consumer": "bar", + "id": "123", + "name": "abc", + "params": Object { + "bar": true, + }, + "schedule": Object { + "interval": "10s", + }, + "tags": Array [ + "foo", + ], + } + `); expect(alertsClient.create).toHaveBeenCalledTimes(1); expect(alertsClient.create.mock.calls[0]).toMatchInlineSnapshot(` Array [