Skip to content

Commit 5f15dcb

Browse files
committed
test: handle unix and windows path
1 parent 33b26f9 commit 5f15dcb

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

test/spaces/visitSpace.test.js

+19-12
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
/* eslint-disable no-restricted-syntax */
44
/* eslint-disable func-names */
55
import { expect } from 'chai';
6-
import path from 'path'
7-
import fs from 'fs'
6+
import path from 'path';
7+
import fs from 'fs';
88
import {
99
removeSpace,
1010
removeTags,
1111
mochaAsync,
1212
userSignIn,
1313
menuGoToVisitSpace,
1414
expectElementToExist,
15+
removePathSeparators,
1516
} from '../utils';
1617
import { closeApplication, createApplication } from '../application';
1718
import {
@@ -46,7 +47,7 @@ import {
4647
DEFAULT_GLOBAL_TIMEOUT,
4748
LOAD_PHASE_PAUSE,
4849
OPEN_TOOLS_PAUSE,
49-
APPS_FOLDER
50+
APPS_FOLDER,
5051
} from '../constants';
5152
import { USER_GRAASP } from '../fixtures/users';
5253
import { USER_MODES, DEFAULT_USER_MODE } from '../../src/config/constants';
@@ -294,23 +295,29 @@ const hasPhaseLayout = async (
294295
case SAVED: {
295296
const iframe = await client.$(`${itemSelector} iframe`);
296297
const src = await iframe.getAttribute('src');
297-
const {name, main} = mapping[url]
298+
const { name, main } = mapping[url];
298299

299300
const varFolder = await client.getUserDataPath();
300301

301-
if(src.includes(asset)) {
302-
const absolutePath = path.join(varFolder, decodeURI(asset))
302+
if (src.includes(asset)) {
303+
const absolutePath = path.join(varFolder, decodeURI(asset));
303304
expect(fs.existsSync(absolutePath)).to.be.true;
304305
}
305306
// check for prepackaged links
306-
else if(name) {
307+
else if (name) {
307308
// todo: use shared constant with public, src
308309
// src should contain prepackaged path
309-
const prepackagedAppsFolder = path.join(varFolder,APPS_FOLDER, name, main)
310-
expect(src).to.include(prepackagedAppsFolder);
311-
}
312-
else {
313-
throw new Error(`${src} does not match ${asset}`)
310+
const prepackagedAppsFolder = path.join(
311+
varFolder,
312+
APPS_FOLDER,
313+
name,
314+
main
315+
);
316+
expect(removePathSeparators(src)).to.include(
317+
removePathSeparators(prepackagedAppsFolder)
318+
);
319+
} else {
320+
throw new Error(`${src} does not match ${asset}`);
314321
}
315322

316323
if (appInstance) {

test/utils.js

+4
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,10 @@ export const removeTags = (html) => {
140140
return html.replace(/<\/?[^>]+(>|$)/g, '');
141141
};
142142

143+
export const removePathSeparators = (path) => {
144+
return path.replace(/[/\\]/g, '');
145+
};
146+
143147
export const createRandomString = () => {
144148
return Math.random().toString(36).substring(7);
145149
};

0 commit comments

Comments
 (0)