Skip to content

Commit 029e8c4

Browse files
committed
test fix
1 parent f664740 commit 029e8c4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

tests/gatsby-2/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"plugin:remove": "yarn remove gatsby-plugin-segment-js",
1414
"plugin:install": "yarn add ../../gatsby-plugin-segment-js.tgz",
1515
"test": "yarn test:prepare && yarn test:run",
16-
"test:prepare": "yarn plugin && yarn clean && yarn build",
16+
"test:prepare": "yarn plugin && yarn install && yarn clean && yarn build",
1717
"test:run": "mocha --config ./test/mocha-config.js"
1818
},
1919
"dependencies": {

tests/shared/tests.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const appJsMapFilePath = path.resolve(pathToPublic, appJsMapFileName)
2222
// change a little bit in insignificant ways...so let's remove the whitespace chars before doing
2323
// comparisons
2424
function removeWhitespace (str) {
25-
return str.replace(/\s+/g, '')
25+
return str.replace(/\s+/g, '').replace(/\n/g, '')
2626
}
2727

2828
describe('Code is there', function () {
@@ -51,6 +51,10 @@ describe('Code is there', function () {
5151
it('has segment code in app-*.js.map', function () {
5252
const appCode = String.raw`if (!trackPage) {\n return;\n }\n\n function trackSegmentPage() {\n var delay = Math.max(0, trackPageDelay);\n\n window.setTimeout(function () {\n window.analytics && window.analytics.page(document.title);\n }, delay);\n }\n\n if (prevLocation && window.segmentSnippetLoaded === false) {\n window.segmentSnippetLoader(function () {\n trackSegmentPage();\n });\n } else {\n trackSegmentPage();\n }\n};`
5353
const jsMapText = fs.readFileSync(appJsMapFilePath).toString()
54+
console.log(removeWhitespace(jsMapText))
55+
console.log(removeWhitespace(appCode))
5456
expect(removeWhitespace(jsMapText)).to.include(removeWhitespace(appCode))
5557
})
5658
})
59+
60+

0 commit comments

Comments
 (0)