From fcd7a035ec55bc5beae7bd22ca96e6f0591ac0da Mon Sep 17 00:00:00 2001 From: restrry Date: Fri, 7 Feb 2020 15:06:42 +0100 Subject: [PATCH] use comparison instead of inline snapshots --- .../logging/layouts/pattern_layout.test.ts | 42 +++++++------------ 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/src/core/server/logging/layouts/pattern_layout.test.ts b/src/core/server/logging/layouts/pattern_layout.test.ts index ebff5967c8e8a..88188d7820cd3 100644 --- a/src/core/server/logging/layouts/pattern_layout.test.ts +++ b/src/core/server/logging/layouts/pattern_layout.test.ts @@ -133,9 +133,7 @@ test('`format()` correctly formats record with meta data.', () => { to: 'v8', }, }) - ).toMatchInlineSnapshot( - `"[2012-02-01T00:00:00.000Z][DEBUG][context-meta][{\\"from\\":\\"v7\\",\\"to\\":\\"v8\\"}] message-meta"` - ); + ).toBe('[2012-02-01T00:00:00.000Z][DEBUG][context-meta][{"from":"v7","to":"v8"}] message-meta'); expect( layout.format({ @@ -146,7 +144,7 @@ test('`format()` correctly formats record with meta data.', () => { pid: 5355, meta: {}, }) - ).toMatchInlineSnapshot(`"[2012-02-01T00:00:00.000Z][DEBUG][context-meta][{}] message-meta"`); + ).toBe('[2012-02-01T00:00:00.000Z][DEBUG][context-meta][{}] message-meta'); expect( layout.format({ @@ -156,7 +154,7 @@ test('`format()` correctly formats record with meta data.', () => { timestamp: new Date(Date.UTC(2012, 1, 1)), pid: 5355, }) - ).toMatchInlineSnapshot(`"[2012-02-01T00:00:00.000Z][DEBUG][context-meta] message-meta"`); + ).toBe('[2012-02-01T00:00:00.000Z][DEBUG][context-meta] message-meta'); }); test('`format()` correctly formats record with highlighting.', () => { @@ -188,9 +186,7 @@ test('`format()` allows specifying pattern with meta.', () => { to: 'v8', }, }; - expect(layout.format(record)).toMatchInlineSnapshot( - `"context-[{\\"from\\":\\"v7\\",\\"to\\":\\"v8\\"}]-message"` - ); + expect(layout.format(record)).toBe('context-[{"from":"v7","to":"v8"}]-message'); }); describe('format', () => { @@ -213,9 +209,7 @@ describe('format', () => { it('ISO8601', () => { const layout = new PatternLayout('[{timestamp{ISO8601}}][{context}]'); - expect(layout.format(record)).toMatchInlineSnapshot( - `"[2012-02-01T00:00:00.000Z][context]"` - ); + expect(layout.format(record)).toBe('[2012-02-01T00:00:00.000Z][context]'); }); it('ISO8601_TZ', () => { @@ -223,27 +217,25 @@ describe('format', () => { '[{timestamp{ISO8601_TZ}{America/Los_Angeles}}][{context}]' ); - expect(layout.format(record)).toMatchInlineSnapshot( - `"[2012-01-31T16:00:00,000-0800][context]"` - ); + expect(layout.format(record)).toBe('[2012-01-31T16:00:00,000-0800][context]'); }); it('ABSOLUTE', () => { const layout = new PatternLayout('[{timestamp{ABSOLUTE}}][{context}]'); - expect(layout.format(record)).toMatchInlineSnapshot(`"[01:00:00,000][context]"`); + expect(layout.format(record)).toBe('[01:00:00,000][context]'); }); it('UNIX', () => { const layout = new PatternLayout('[{timestamp{UNIX}}][{context}]'); - expect(layout.format(record)).toMatchInlineSnapshot(`"[1328054400][context]"`); + expect(layout.format(record)).toBe('[1328054400][context]'); }); it('UNIX_MILLIS', () => { const layout = new PatternLayout('[{timestamp{UNIX_MILLIS}}][{context}]'); - expect(layout.format(record)).toMatchInlineSnapshot(`"[1328054400000][context]"`); + expect(layout.format(record)).toBe('[1328054400000][context]'); }); }); @@ -251,9 +243,7 @@ describe('format', () => { it('ISO8601', () => { const layout = new PatternLayout('[{timestamp{ISO8601}{America/Los_Angeles}}][{context}]'); - expect(layout.format(record)).toMatchInlineSnapshot( - `"[2012-02-01T00:00:00.000Z][context]"` - ); + expect(layout.format(record)).toBe('[2012-02-01T00:00:00.000Z][context]'); }); it('ISO8601_TZ', () => { @@ -261,21 +251,19 @@ describe('format', () => { '[{timestamp{ISO8601_TZ}{America/Los_Angeles}}][{context}]' ); - expect(layout.format(record)).toMatchInlineSnapshot( - `"[2012-01-31T16:00:00,000-0800][context]"` - ); + expect(layout.format(record)).toBe('[2012-01-31T16:00:00,000-0800][context]'); }); it('ABSOLUTE', () => { const layout = new PatternLayout('[{timestamp{ABSOLUTE}{America/Los_Angeles}}][{context}]'); - expect(layout.format(record)).toMatchInlineSnapshot(`"[16:00:00,000][context]"`); + expect(layout.format(record)).toBe('[16:00:00,000][context]'); }); it('UNIX', () => { const layout = new PatternLayout('[{timestamp{UNIX}{America/Los_Angeles}}][{context}]'); - expect(layout.format(record)).toMatchInlineSnapshot(`"[1328054400][context]"`); + expect(layout.format(record)).toBe('[1328054400][context]'); }); it('UNIX_MILLIS', () => { @@ -283,7 +271,7 @@ describe('format', () => { '[{timestamp{UNIX_MILLIS}{America/Los_Angeles}}][{context}]' ); - expect(layout.format(record)).toMatchInlineSnapshot(`"[1328054400000][context]"`); + expect(layout.format(record)).toBe('[1328054400000][context]'); }); }); it('formats several conversions patterns correctly', () => { @@ -291,7 +279,7 @@ describe('format', () => { '[{timestamp{ABSOLUTE}{America/Los_Angeles}}][{context}][{timestamp{UNIX}}]' ); - expect(layout.format(record)).toMatchInlineSnapshot(`"[16:00:00,000][context][1328054400]"`); + expect(layout.format(record)).toBe('[16:00:00,000][context][1328054400]'); }); }); });