From 396d56e053a82045f1c14760acf726b7b6512c07 Mon Sep 17 00:00:00 2001 From: Kreeg Date: Wed, 22 Jun 2022 17:54:57 +0300 Subject: [PATCH] Added snapshots testing for regression tests --- .../alignment/__snapshots__/center.test.js.snap | 7 +++++++ .../alignment/__snapshots__/mixed.test.js.snap | 5 +++++ test/svg-sprite/alignment/center.test.js | 3 +++ test/svg-sprite/alignment/mixed.test.js | 2 ++ .../modes/__snapshots__/css.test.js.snap | 17 +++++++++++++++++ .../modes/__snapshots__/defs.test.js.snap | 5 +++++ .../modes/__snapshots__/stack.test.js.snap | 7 +++++++ .../modes/__snapshots__/symbol.test.js.snap | 5 +++++ .../modes/__snapshots__/view.mixed.test.js.snap | 3 +++ .../__snapshots__/view.packed.test.js.snap | 5 +++++ .../minimal-configuration/modes/css.test.js | 4 ++++ .../minimal-configuration/modes/defs.test.js | 2 ++ .../minimal-configuration/modes/stack.test.js | 4 ++++ .../minimal-configuration/modes/symbol.test.js | 2 ++ .../modes/view.mixed.test.js | 1 + .../modes/view.packed.test.js | 2 ++ 16 files changed, 74 insertions(+) create mode 100644 test/svg-sprite/alignment/__snapshots__/center.test.js.snap create mode 100644 test/svg-sprite/alignment/__snapshots__/mixed.test.js.snap create mode 100644 test/svg-sprite/minimal-configuration/modes/__snapshots__/css.test.js.snap create mode 100644 test/svg-sprite/minimal-configuration/modes/__snapshots__/defs.test.js.snap create mode 100644 test/svg-sprite/minimal-configuration/modes/__snapshots__/stack.test.js.snap create mode 100644 test/svg-sprite/minimal-configuration/modes/__snapshots__/symbol.test.js.snap create mode 100644 test/svg-sprite/minimal-configuration/modes/__snapshots__/view.mixed.test.js.snap create mode 100644 test/svg-sprite/minimal-configuration/modes/__snapshots__/view.packed.test.js.snap diff --git a/test/svg-sprite/alignment/__snapshots__/center.test.js.snap b/test/svg-sprite/alignment/__snapshots__/center.test.js.snap new file mode 100644 index 000000000..4be0ba41e --- /dev/null +++ b/test/svg-sprite/alignment/__snapshots__/center.test.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`svg-sprite: with centered alignment and 4 SVG files with «css» mode, horizontal layout and Sass render type creates visually correct sprite 1`] = `""`; + +exports[`svg-sprite: with centered alignment and 4 SVG files with «css» mode, packed layout and LESS render type creates visually correct sprite 1`] = `""`; + +exports[`svg-sprite: with centered alignment and 4 SVG files with «css» mode, vertical layout and CSS render type creates visually correct sprite 1`] = `""`; diff --git a/test/svg-sprite/alignment/__snapshots__/mixed.test.js.snap b/test/svg-sprite/alignment/__snapshots__/mixed.test.js.snap new file mode 100644 index 000000000..5c8f0309b --- /dev/null +++ b/test/svg-sprite/alignment/__snapshots__/mixed.test.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`svg-sprite: with mixed alignment and 4 SVG files with «view» mode, horizontal layout and Sass render type creates visually correct sprite 1`] = `""`; + +exports[`svg-sprite: with mixed alignment and 4 SVG files with «view» mode, vertical layout and CSS render type creates visually correct sprite 1`] = `""`; diff --git a/test/svg-sprite/alignment/center.test.js b/test/svg-sprite/alignment/center.test.js index c8fb7bb66..8d3537b11 100644 --- a/test/svg-sprite/alignment/center.test.js +++ b/test/svg-sprite/alignment/center.test.js @@ -62,6 +62,7 @@ describe(`svg-sprite: with centered alignment and ${align.length} SVG files`, () const input = path.join(tmpPath, 'css/svg', svgPath); const expected = path.join(paths.expectations, 'png/css.vertical.centered.png'); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); @@ -119,6 +120,7 @@ describe(`svg-sprite: with centered alignment and ${align.length} SVG files`, () const input = path.join(tmpPath, 'css/svg', svgPath); const expected = path.join(paths.expectations, 'png/css.horizontal.centered.png'); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); @@ -179,6 +181,7 @@ describe(`svg-sprite: with centered alignment and ${align.length} SVG files`, () const input = path.join(tmpPath, 'css/svg', svgPath); const expected = path.join(paths.expectations, 'png/css.packed.centered.png'); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); diff --git a/test/svg-sprite/alignment/mixed.test.js b/test/svg-sprite/alignment/mixed.test.js index 58585021c..978a2e7ea 100644 --- a/test/svg-sprite/alignment/mixed.test.js +++ b/test/svg-sprite/alignment/mixed.test.js @@ -61,6 +61,7 @@ describe(`svg-sprite: with mixed alignment and ${align.length} SVG files`, () => const input = path.join(tmpPath, 'view/svg', svgPath); const expected = path.join(paths.expectations, 'png/css.vertical.mixed.png'); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); @@ -121,6 +122,7 @@ describe(`svg-sprite: with mixed alignment and ${align.length} SVG files`, () => const input = path.join(tmpPath, 'view/svg', svgPath); const expected = path.join(paths.expectations, 'png/css.horizontal.mixed.png'); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); diff --git a/test/svg-sprite/minimal-configuration/modes/__snapshots__/css.test.js.snap b/test/svg-sprite/minimal-configuration/modes/__snapshots__/css.test.js.snap new file mode 100644 index 000000000..647235ab9 --- /dev/null +++ b/test/svg-sprite/minimal-configuration/modes/__snapshots__/css.test.js.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`testing minimal config default: with minimum configuration creates visually correct sprite with diagonal layout 1`] = `""`; + +exports[`testing minimal config default: with minimum configuration creates visually correct sprite with horizontal layout 1`] = `""`; + +exports[`testing minimal config default: with minimum configuration creates visually correct sprite with packed layout 1`] = `""`; + +exports[`testing minimal config default: with minimum configuration creates visually correct sprite with vertical layout 1`] = `""`; + +exports[`testing minimal config w/o dims: with minimum configuration creates visually correct sprite with diagonal layout 1`] = `""`; + +exports[`testing minimal config w/o dims: with minimum configuration creates visually correct sprite with horizontal layout 1`] = `""`; + +exports[`testing minimal config w/o dims: with minimum configuration creates visually correct sprite with packed layout 1`] = `""`; + +exports[`testing minimal config w/o dims: with minimum configuration creates visually correct sprite with vertical layout 1`] = `""`; diff --git a/test/svg-sprite/minimal-configuration/modes/__snapshots__/defs.test.js.snap b/test/svg-sprite/minimal-configuration/modes/__snapshots__/defs.test.js.snap new file mode 100644 index 000000000..9b9ef906f --- /dev/null +++ b/test/svg-sprite/minimal-configuration/modes/__snapshots__/defs.test.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`svg-sprite: default: «defs» mode creates a visually correct stylesheet resource in CSS format 1`] = `""`; + +exports[`svg-sprite: w/o dims: «defs» mode creates a visually correct stylesheet resource in CSS format 1`] = `""`; diff --git a/test/svg-sprite/minimal-configuration/modes/__snapshots__/stack.test.js.snap b/test/svg-sprite/minimal-configuration/modes/__snapshots__/stack.test.js.snap new file mode 100644 index 000000000..e8c0e9077 --- /dev/null +++ b/test/svg-sprite/minimal-configuration/modes/__snapshots__/stack.test.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`svg-sprite: default: «stack» mode creates a visually correct stylesheet resource in CSS format 1`] = `""`; + +exports[`svg-sprite: w/o dims: «stack» mode creates a visually correct stylesheet resource in CSS format 1`] = `""`; + +exports[`without viewbox creates a visually correct stylesheet resource in CSS format 1`] = `""`; diff --git a/test/svg-sprite/minimal-configuration/modes/__snapshots__/symbol.test.js.snap b/test/svg-sprite/minimal-configuration/modes/__snapshots__/symbol.test.js.snap new file mode 100644 index 000000000..5d0be8eed --- /dev/null +++ b/test/svg-sprite/minimal-configuration/modes/__snapshots__/symbol.test.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`svg-sprite: default: «symbol» mode creates a visually correct stylesheet resource in CSS format 1`] = `""`; + +exports[`svg-sprite: w/o dims: «symbol» mode creates a visually correct stylesheet resource in CSS format 1`] = `""`; diff --git a/test/svg-sprite/minimal-configuration/modes/__snapshots__/view.mixed.test.js.snap b/test/svg-sprite/minimal-configuration/modes/__snapshots__/view.mixed.test.js.snap new file mode 100644 index 000000000..0f7b886f4 --- /dev/null +++ b/test/svg-sprite/minimal-configuration/modes/__snapshots__/view.mixed.test.js.snap @@ -0,0 +1,3 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`svg-sprite: with «view» mode, packed layout and LESS render type creates visually correct sprite 1`] = `""`; diff --git a/test/svg-sprite/minimal-configuration/modes/__snapshots__/view.packed.test.js.snap b/test/svg-sprite/minimal-configuration/modes/__snapshots__/view.packed.test.js.snap new file mode 100644 index 000000000..6bdda230b --- /dev/null +++ b/test/svg-sprite/minimal-configuration/modes/__snapshots__/view.packed.test.js.snap @@ -0,0 +1,5 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`svg-sprite: default: «symbol» mode svg-sprite: weather in «view» mode creates visually correct sprite with packed layout 1`] = `""`; + +exports[`svg-sprite: w/o dims: «symbol» mode svg-sprite: without-dims in «view» mode creates visually correct sprite with packed layout 1`] = `""`; diff --git a/test/svg-sprite/minimal-configuration/modes/css.test.js b/test/svg-sprite/minimal-configuration/modes/css.test.js index 4c0e6c49a..0bb0b47e8 100644 --- a/test/svg-sprite/minimal-configuration/modes/css.test.js +++ b/test/svg-sprite/minimal-configuration/modes/css.test.js @@ -92,6 +92,7 @@ describe('testing minimal config', () => { const input = path.join(tmpPath, 'css/svg', svg.vertical); const expected = path.join(paths.expectations, `png/css.vertical${testConfig.namespace}.png`); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); @@ -102,6 +103,7 @@ describe('testing minimal config', () => { const input = path.join(tmpPath, 'css/svg', svg.horizontal); const expected = path.join(paths.expectations, `png/css.horizontal${testConfig.namespace}.png`); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); @@ -112,6 +114,7 @@ describe('testing minimal config', () => { const input = path.join(tmpPath, 'css/svg', svg.diagonal); const expected = path.join(paths.expectations, `png/css.diagonal${testConfig.namespace}.png`); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); @@ -122,6 +125,7 @@ describe('testing minimal config', () => { const input = path.join(tmpPath, 'css/svg', svg.packed); const expected = path.join(paths.expectations, `png/css.packed${testConfig.namespace}.png`); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); }); diff --git a/test/svg-sprite/minimal-configuration/modes/defs.test.js b/test/svg-sprite/minimal-configuration/modes/defs.test.js index d56a0f42c..2ea204330 100644 --- a/test/svg-sprite/minimal-configuration/modes/defs.test.js +++ b/test/svg-sprite/minimal-configuration/modes/defs.test.js @@ -50,6 +50,8 @@ describe.each` data.svg = svgData.toString(); data.css = '../sprite.css'; + expect(data.svg).toMatchSnapshot(); + const previewTemplate = await fs.readFile(path.join(__dirname, '../../../tmpl/defs.html'), 'utf8'); const out = mustache.render(previewTemplate, data); const preview = await writeFile(path.join(tmpPath, `defs/html/defs${testConfig.namespace}.html`), out); diff --git a/test/svg-sprite/minimal-configuration/modes/stack.test.js b/test/svg-sprite/minimal-configuration/modes/stack.test.js index 47c13c5e2..c9fcbb80c 100644 --- a/test/svg-sprite/minimal-configuration/modes/stack.test.js +++ b/test/svg-sprite/minimal-configuration/modes/stack.test.js @@ -50,6 +50,8 @@ describe.each` data.svg = svgData.toString(); data.css = '../sprite.css'; + expect(data.svg).toMatchSnapshot(); + const previewTemplate = await fs.readFile(path.join(__dirname, '../../../tmpl/stack.html'), 'utf8'); const out = mustache.render(previewTemplate, data); const preview = await writeFile(path.join(tmpPath, `stack/html/stack${testConfig.namespace}.html`), out); @@ -93,6 +95,8 @@ describe('without viewbox', () => { data.svg = svgData.toString(); data.css = '../sprite.css'; + expect(data.svg).toMatchSnapshot(); + const previewTemplate = await fs.readFile(path.join(__dirname, '../../../tmpl/stack.html'), 'utf8'); const out = mustache.render(previewTemplate, data); const preview = await writeFile(path.join(tmpPath, 'stack/html/stack-without-viewbox.html'), out); diff --git a/test/svg-sprite/minimal-configuration/modes/symbol.test.js b/test/svg-sprite/minimal-configuration/modes/symbol.test.js index 1b3793e07..93053bd65 100644 --- a/test/svg-sprite/minimal-configuration/modes/symbol.test.js +++ b/test/svg-sprite/minimal-configuration/modes/symbol.test.js @@ -50,6 +50,8 @@ describe.each` data.svg = svgData.toString(); data.css = '../sprite.css'; + expect(data.svg).toMatchSnapshot(); + const previewTemplate = await fs.readFile(path.join(__dirname, '../../../tmpl/symbol.html'), 'utf8'); const out = mustache.render(previewTemplate, data); const preview = await writeFile(path.join(tmpPath, 'symbol/html/symbol.html'), out); diff --git a/test/svg-sprite/minimal-configuration/modes/view.mixed.test.js b/test/svg-sprite/minimal-configuration/modes/view.mixed.test.js index d99f9ffe7..9cd4da4bd 100644 --- a/test/svg-sprite/minimal-configuration/modes/view.mixed.test.js +++ b/test/svg-sprite/minimal-configuration/modes/view.mixed.test.js @@ -60,6 +60,7 @@ describe('svg-sprite: with «view» mode, packed layout and LESS render type', ( const input = path.join(tmpPath, 'view/svg', packedSvg); const expected = path.join(paths.expectations, 'png/css.packed.mixed.png'); + expect(fs.readFileSync(input).toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); }); diff --git a/test/svg-sprite/minimal-configuration/modes/view.packed.test.js b/test/svg-sprite/minimal-configuration/modes/view.packed.test.js index 454cbf9af..ef98103ab 100644 --- a/test/svg-sprite/minimal-configuration/modes/view.packed.test.js +++ b/test/svg-sprite/minimal-configuration/modes/view.packed.test.js @@ -52,7 +52,9 @@ describe.each` const input = path.join(tmpPath, 'view/svg', svg); const expected = path.join(paths.expectations, `png/css.packed${testConfig.namespace}.png`); + const svgFile = await fs.readFile(input); + expect(svgFile.toString()).toMatchSnapshot(); await expect(input).toBeVisuallyEqualTo(expected); });