Skip to content

Commit

Permalink
preheat resvg rendering in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yisibl committed Mar 14, 2022
1 parent 6cd7ce0 commit d23dcad
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test/calculate-svg-dimensions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ const calculateSvgDimensions = require('../lib/svg-sprite/utils/calculate-svg-di

const { paths } = require('./helpers/constants.js');

describe('calculateSvgDimensions', () => {
// eslint-disable-next-line import/no-unassigned-import
require('./helpers/resvg-preheat.js');

describe.only('calculateSvgDimensions', () => {
it('should return the expected dimensions from 46x46 fixture', () => {
const svgFilePath = path.join(paths.fixtures, 'svg/special/without-dims/46x46.svg');
const svg = readFileSync(svgFilePath, 'utf-8');
Expand Down
8 changes: 8 additions & 0 deletions test/helpers/resvg-preheat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const { Resvg } = require('@resvg/resvg-js');

new Resvg('<svg xmlns="http://www.w3.org/2000/svg"></svg>', {
logLevel: 'error',
font: {
loadSystemFonts: false
}
});
3 changes: 3 additions & 0 deletions test/shape.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const { isObject } = require('../lib/svg-sprite/utils/index.js');

const { paths } = require('./helpers/constants.js');

// eslint-disable-next-line import/no-unassigned-import
require('./helpers/resvg-preheat.js');

const expectations = [{
svg: '46x46.svg',
result: {
Expand Down
3 changes: 3 additions & 0 deletions test/spriter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ const SVGSpriter = require('../lib/svg-sprite.js');
const TEST_SVG = 'fixture/svg/single/weather-clear.svg';
const TEST_EMPTY_SVG = '<svg></svg>';

// eslint-disable-next-line import/no-unassigned-import
require('./helpers/resvg-preheat.js');

describe('testing SVGSpriter', () => {
let spriter;

Expand Down
3 changes: 3 additions & 0 deletions test/svg-shape.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ const getShape = require('../lib/svg-sprite/shape.js');
const SVGSpriter = require('../lib/svg-sprite.js');
const { paths } = require('./helpers/constants.js');

// eslint-disable-next-line import/no-unassigned-import
require('./helpers/resvg-preheat.js');

describe('testing SVGShape initialization', () => {
let spriter;

Expand Down

0 comments on commit d23dcad

Please sign in to comment.