Skip to content

Commit 23b8ee8

Browse files
committed
test: Make tests resilient even for tagged semvers
1 parent ecf99f8 commit 23b8ee8

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

__tests__/__snapshots__/bin.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exports[`--config 1`] = `
55
<html>
66
<head>
77
<meta charset='utf-8' />
8-
<title> | Documentation</title>
8+
<title>documentation | Documentation</title>
99
<meta name='viewport' content='width=device-width,initial-scale=1'>
1010
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
1111
<link href='assets/style.css' type='text/css' rel='stylesheet' />
@@ -18,7 +18,7 @@ exports[`--config 1`] = `
1818
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
1919
<div class='py1 px2'>
2020
<h3 class='mb0 no-anchor'>documentation</h3>
21-
<div class='mb1'></div>
21+
<div class='mb1'><code></code></div>
2222
<input
2323
placeholder='Filter'
2424
id='filter-input'

__tests__/__snapshots__/test.js.snap

+2-2
Original file line numberDiff line numberDiff line change
@@ -1387,7 +1387,7 @@ exports[`html nested.input.js 1`] = `
13871387
<html>
13881388
<head>
13891389
<meta charset='utf-8' />
1390-
<title> | Documentation</title>
1390+
<title>-alpha.0 | Documentation</title>
13911391
<meta name='viewport' content='width=device-width,initial-scale=1'>
13921392
<link href='assets/bass.css' type='text/css' rel='stylesheet' />
13931393
<link href='assets/style.css' type='text/css' rel='stylesheet' />
@@ -1400,7 +1400,7 @@ exports[`html nested.input.js 1`] = `
14001400
<div id='split-left' class='overflow-auto fs0 height-viewport-100'>
14011401
<div class='py1 px2'>
14021402
<h3 class='mb0 no-anchor'>documentation</h3>
1403-
<div class='mb1'></div>
1403+
<div class='mb1'><code>9.0.0-alpha.0</code></div>
14041404
<input
14051405
placeholder='Filter'
14061406
id='filter-input'

__tests__/bin.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ describe('invalid arguments', function() {
159159
});
160160
});
161161

162+
const semver = /\bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\da-z-]+(?:\.[\da-z-]+)*)?(?:\+[\da-z-]+(?:\.[\da-z-]+)*)?\b/gi;
162163
test('--config', async function() {
163164
const dst = path.join(os.tmpdir(), (Date.now() + Math.random()).toString());
164165
fs.mkdirSync(dst);
@@ -172,9 +173,8 @@ test('--config', async function() {
172173
false
173174
);
174175
let output = fs.readFileSync(outputIndex, 'utf8');
175-
output = output
176-
.replace(/documentation \d+\.\d+\.\d+/g, '')
177-
.replace(/<code>\d+\.\d+\.\d+<\/code>/g, '');
176+
const version = require('../package.json').version;
177+
output = output.replace(new RegExp(version.replace(/\./g, '\\.'), 'g'), '');
178178
expect(output).toMatchSnapshot();
179179
});
180180

0 commit comments

Comments
 (0)