-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
182 additions
and
123 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ dist/ | |
docs/all | ||
docs/public | ||
node_modules/ | ||
test/integration/render/**/*.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Integration tests | ||
|
||
## Generating the references | ||
|
||
yarn test:render:prepare | ||
|
||
## Running the tests | ||
|
||
yarn test:render |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<link href="<%- mapboxglcss %>" rel="stylesheet" /> | ||
<script src="<%- cartogl %>"></script> | ||
<script src="<%- mapboxgl %>"></script> | ||
<style> | ||
body { margin: 0; padding: 0; } | ||
#map { position: absolute; height: 100%; width: 100%; } | ||
</style> | ||
</head> | ||
<body> | ||
<div id='map'></div> | ||
</body> | ||
<script src="<%- file %>"></script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const exquisite = require('exquisite-sst'); | ||
const util = require('./util'); | ||
|
||
let options = util.loadOptions(); | ||
|
||
const files = util.loadFiles(); | ||
const renderTemplate = util.loadTemplate(); | ||
|
||
files.reduce((promise, file) => { | ||
return promise.then(() => takeReference(file)); | ||
}, Promise.resolve()); | ||
|
||
function takeReference (file) { | ||
console.log(`Taking reference from ${util.getName(file)}`); | ||
util.writeTemplate(file, renderTemplate); | ||
options.url = `file://${util.getHTML(file)}`; | ||
options.output = `${util.getPNG(file)}`; | ||
return exquisite.getReference(options); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,24 @@ | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
const chai = require('chai'); | ||
const exquisite = require('exquisite-sst'); | ||
const chai = require('chai'); | ||
const util = require('./util'); | ||
|
||
chai.use(require('chai-as-promised')); | ||
|
||
let options = { | ||
delay: 4000, | ||
viewportWidth: 800, | ||
viewportHeight: 600, | ||
headless: process.platform === 'linux' | ||
// waitForFn: () => window.mapLoaded | ||
}; | ||
let options = util.loadOptions(); | ||
|
||
const renderDir = path.join(__dirname, 'render'); | ||
const files = util.loadFiles(); | ||
const renderTemplate = util.loadTemplate(); | ||
|
||
describe('Render tests:', () => { | ||
const files = glob.sync(path.join(renderDir, '**', 'test.html')); | ||
files.forEach(test); | ||
}); | ||
|
||
function test (file) { | ||
it(testName(file), () => { | ||
options.url = `file://${file}`; | ||
options.input = `${file.replace('.html', '.png')}`; | ||
options.output = `${file.replace('.html', '_out.png')}`; | ||
it(util.getName(file), () => { | ||
util.writeTemplate(file, renderTemplate); | ||
options.url = `file://${util.getHTML(file)}`; | ||
options.input = `${util.getPNG(file)}`; | ||
options.output = `${util.getOutPNG(file)}`; | ||
return chai.expect(exquisite.test(options)).to.eventually.be.true; | ||
}).timeout(5000); | ||
} | ||
|
||
function testName (file) { | ||
return file.substr(renderDir.length, file.length - renderDir.length - 10); | ||
}).timeout(10000); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* global mapboxgl carto */ | ||
|
||
carto.setDefaultAuth({ | ||
user: 'arroyo-carto', | ||
apiKey: 'YOUR_API_KEY' | ||
}); | ||
|
||
const map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: { version: 8, sources: {}, layers: [] }, | ||
center: [50, 30], | ||
zoom: 2 | ||
}); | ||
|
||
const source = new carto.source.Dataset('route'); | ||
const style = new carto.Style(); | ||
const layer = new carto.Layer('layer', source, style); | ||
|
||
layer.addTo(map); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* global mapboxgl carto */ | ||
|
||
carto.setDefaultAuth({ | ||
user: 'arroyo-carto', | ||
apiKey: 'YOUR_API_KEY' | ||
}); | ||
|
||
const map = new mapboxgl.Map({ | ||
container: 'map', | ||
style: { version: 8, sources: {}, layers: [] }, | ||
center: [50, 30], | ||
zoom: 2 | ||
}); | ||
|
||
const source = new carto.source.Dataset('route'); | ||
const style = new carto.Style(` | ||
width: 10, | ||
color: rgba(0,1,1,1) | ||
`); | ||
const layer = new carto.Layer('layer', source, style); | ||
|
||
layer.addTo(map); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const glob = require('glob'); | ||
const template = require('lodash.template'); | ||
|
||
const fileName = 'test.js'; | ||
const renderDir = path.join(__dirname, 'render'); | ||
|
||
function getHTML (file) { | ||
return file.replace('.js', '.html'); | ||
} | ||
|
||
function getPNG (file) { | ||
return file.replace('.js', '.png'); | ||
} | ||
|
||
function getOutPNG (file) { | ||
return file.replace('.js', '_out.png'); | ||
} | ||
|
||
function getName (file) { | ||
return file.substr( | ||
renderDir.length, | ||
file.length - renderDir.length - fileName.length - 1 | ||
); | ||
} | ||
|
||
function loadOptions () { | ||
return { | ||
delay: 8000, | ||
viewportWidth: 800, | ||
viewportHeight: 600, | ||
headless: process.platform === 'linux' | ||
// waitForFn: () => window.mapLoaded | ||
}; | ||
} | ||
|
||
function loadFiles () { | ||
return glob.sync(path.join(renderDir, '**', fileName)); | ||
} | ||
|
||
function loadTemplate () { | ||
return template(fs.readFileSync(path.join(__dirname, 'render.html.tpl')), 'utf8'); | ||
} | ||
|
||
function writeTemplate (file, renderTemplate) { | ||
const mainDir = path.resolve(__dirname, '..', '..'); | ||
fs.writeFileSync(`${getHTML(file)}`, renderTemplate({ | ||
file: file, | ||
cartogl: path.resolve(mainDir, 'dist', 'carto-gl.js'), | ||
mapboxgl: path.resolve(mainDir, 'vendor', 'mapbox-gl-dev.js'), | ||
mapboxglcss: path.resolve(mainDir, 'vendor', 'mapbox-gl-dev.css') | ||
})); | ||
} | ||
|
||
module.exports = { | ||
getHTML: getHTML, | ||
getPNG: getPNG, | ||
getOutPNG: getOutPNG, | ||
getName: getName, | ||
loadFiles: loadFiles, | ||
loadOptions: loadOptions, | ||
loadTemplate: loadTemplate, | ||
writeTemplate: writeTemplate, | ||
}; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters