Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] token refactor in docs-page-shell #8174

Merged
merged 3 commits into from
Apr 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/components/application-wrapper.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react';

if (typeof window !== 'undefined') {
window.MapboxPageShellProduction = true;
import(/* webpackChunkName: "assembly-js" */ '@mapbox/mbx-assembly/dist/assembly.js');
}

Expand Down
1 change: 0 additions & 1 deletion docs/pages/example/jump-to.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
]
};

mapboxgl.accessToken = 'pk.eyJ1IjoibWFsLXdvb2QiLCJhIjoiY2oyZ2t2em50MDAyMzJ3cnltMDFhb2NzdiJ9.X-D4Wvo5E5QxeP7K_I3O8w';
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/streets-v11',
Expand Down
25 changes: 23 additions & 2 deletions test/unit/docs/examples.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ const readPost = filename => {
}
};

const listExamples = dir => {

const listExamplesJs = dir => {
const files = fs.readdirSync(`${dir}`);
return files.reduce((arr, file) => {
if (path.extname(file) === '.js') {
Expand All @@ -37,7 +38,18 @@ const listExamples = dir => {
}, []);
};

listExamples('./docs/pages/example/').forEach((example) => {
const listExamplesHtml = dir => {
const files = fs.readdirSync(`${dir}`);
return files.reduce((arr, file) => {
if (path.extname(file) === '.html') {
arr.push(`${dir}${file}`);
}
return arr;
}, []);
};

// Test .js files
listExamplesJs('./docs/pages/example/').forEach((example) => {
const file = readPost(example);
const metadata = file.metadata;

Expand Down Expand Up @@ -65,3 +77,12 @@ listExamples('./docs/pages/example/').forEach((example) => {
});
}
});

// Test .html files
listExamplesHtml('./docs/pages/example/').forEach((example) => {
const file = readPost(example);
test(`Example: ${example}`, (t) => {
t.ok(!file.file.includes('pk.ey'), 'do not hardcode access tokens, an access token will be appended automatically');
t.end();
});
});
2 changes: 1 addition & 1 deletion vendor/docs-page-shell/page-shell-script.js

Large diffs are not rendered by default.