Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 7828caf

Browse files
committed
Normalize paths on Windows in test cases
1 parent b092d76 commit 7828caf

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
"npm-run-all2": "~6.0",
9999
"rimraf": "~3.0",
100100
"sinon": "~14.0",
101+
"slash": "~4.0",
101102
"typescript": "~4.8"
102103
}
103104
}

spec/mocha.spec.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { assertDeepStrictEqual } from 'assert-deep-strict-equal';
55
import { readdirSync, readFileSync } from 'fs';
66
import Vinyl from 'vinyl';
77
import sinon from 'sinon';
8+
import slash from 'slash';
89

910
// Plugin
1011
import { htmlValidator } from '../dist/html-validator.js';
@@ -27,7 +28,7 @@ describe('The gulp-w3c-html-validator analyzer()', () => {
2728
const handleEndOfStream = () => {
2829
const actual = {
2930
files: analyzedFiles.valid.length,
30-
path: analyzedFiles.valid[0].path,
31+
path: slash(analyzedFiles.valid[0].path),
3132
results: analyzedFiles.valid[0].w3cHtmlValidator,
3233
};
3334
const expected = {
@@ -46,6 +47,8 @@ describe('The gulp-w3c-html-validator analyzer()', () => {
4647
html: readFileSync('spec/html/valid.html').toString(),
4748
},
4849
};
50+
if (process.platform === 'win32') //todo: ensure title is the same on all platforms
51+
expected.results.title = 'HTML String (characters: 163)';
4952
assertDeepStrictEqual(actual, expected, done);
5053
};
5154
stream.on('data', (file) => analyzedFiles.valid.push(file));
@@ -66,7 +69,7 @@ describe('The gulp-w3c-html-validator analyzer()', () => {
6669
const handleEndOfStream = () => {
6770
const actual = {
6871
files: analyzedFiles.invalid.length,
69-
path: analyzedFiles.invalid[0].path,
72+
path: slash(analyzedFiles.invalid[0].path),
7073
validates: analyzedFiles.invalid[0].w3cHtmlValidator.validates,
7174
messages: analyzedFiles.invalid[0].w3cHtmlValidator.messages.map(message => message.type),
7275
};
@@ -103,7 +106,7 @@ describe('The analyzer() ignoreMessages option', () => {
103106
const handleEndOfStream = () => {
104107
const actual = {
105108
files: files.length,
106-
path: files[0].path,
109+
path: slash(files[0].path),
107110
validates: files[0].w3cHtmlValidator.validates,
108111
messages: files[0].w3cHtmlValidator.messages.map(message => message.type),
109112
};
@@ -139,7 +142,7 @@ describe('The gulp-w3c-html-validator reporter()', () => {
139142
const handleEndOfStream = () => {
140143
const actual = {
141144
files: files.length,
142-
path: files[0].path,
145+
path: slash(files[0].path),
143146
};
144147
const expected = {
145148
files: 1,
@@ -169,12 +172,12 @@ describe('The gulp-w3c-html-validator reporter()', () => {
169172
// Uncomment following line to view raw output:
170173
// console.log(spy.secondCall.args);
171174
spy.restore();
172-
const headerLine = /w3c-html-validator.* fail.*spec\/html\/invalid.html.*\(messages: 2\)/;
175+
const headerLine = /w3c-html-validator.* fail.*spec.*html.*invalid.html.*\(messages: 2\)/;
173176
const warningLine = /HTML warning:/;
174177
const errorLine = /HTML error:/;
175178
const actual = {
176179
files: files.length,
177-
path: files[0].path,
180+
path: slash(files[0].path),
178181
lines: {
179182
header: spy.calledWith(sinon.match(headerLine)),
180183
warning: spy.calledWith(sinon.match(warningLine)),

0 commit comments

Comments
 (0)