Skip to content

Commit

Permalink
Added snapshots testing for regression tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreeg committed Sep 5, 2022
1 parent 9527e18 commit 396d56e
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 0 deletions.
7 changes: 7 additions & 0 deletions test/svg-sprite/alignment/__snapshots__/center.test.js.snap

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/svg-sprite/alignment/__snapshots__/mixed.test.js.snap

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions test/svg-sprite/alignment/center.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down
2 changes: 2 additions & 0 deletions test/svg-sprite/alignment/mixed.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions test/svg-sprite/minimal-configuration/modes/css.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});

Expand All @@ -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);
});
});
Expand Down
2 changes: 2 additions & 0 deletions test/svg-sprite/minimal-configuration/modes/defs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions test/svg-sprite/minimal-configuration/modes/stack.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions test/svg-sprite/minimal-configuration/modes/symbol.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down

0 comments on commit 396d56e

Please sign in to comment.