forked from pelias/leaflet-plugin
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
17 changed files
with
212 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": ["semistandard"], | ||
"globals": { | ||
"define": false, | ||
"XMLHttpRequest": false | ||
} | ||
} |
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 +1,3 @@ | ||
node_modules | ||
node_modules | ||
.DS_Store | ||
coverage/ |
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
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
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
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
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,15 @@ | ||
{ | ||
"extends": ["semistandard"], | ||
"globals": { | ||
"L": true, | ||
"module": false, | ||
"define": false, | ||
"expect": false, | ||
"it": false, | ||
"describe": false, | ||
"sinon": false, | ||
"happen": false, | ||
"beforeEach": false, | ||
"afterEach": false | ||
} | ||
} |
Empty file.
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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset='utf-8'> | ||
<title>Pelias Leaflet Geocoder Spec Runner</title> | ||
<link rel='stylesheet' type='text/css' href='../node_modules/mocha/mocha.css'> | ||
<link rel='stylesheet' type='text/css' href='../node_modules/leaflet/dist/leaflet.css'> | ||
</head> | ||
<body> | ||
<div id='mocha'></div> | ||
<script src='../node_modules/expect.js/index.js'></script> | ||
<script type='text/javascript' src='../node_modules/mocha/mocha.js'></script> | ||
<script type='text/javascript' src='../node_modules/happen/happen.js'></script> | ||
<script type='text/javascript' src='../node_modules/sinon/pkg/sinon.js'></script> | ||
<script type='text/javascript' src='../node_modules/leaflet/dist/leaflet.js'></script> | ||
|
||
<!-- source files --> | ||
<script type='text/javascript' src='../dist/pelias-leaflet-geocoder.js'></script> | ||
|
||
<script> | ||
mocha.setup({ | ||
ui: 'bdd', | ||
ignoreLeaks: true | ||
}); | ||
</script> | ||
|
||
<!-- spec files --> | ||
<script type='text/javascript' src='suites/ControlSpec.js'></script> | ||
|
||
<script> | ||
(window.mochaPhantomJS || window.mocha).run(); | ||
</script> | ||
</body> | ||
</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,77 @@ | ||
// Karma configuration | ||
module.exports = function (config) { | ||
|
||
var files = [ | ||
// Test ependencies | ||
'node_modules/sinon/pkg/sinon.js', | ||
'node_modules/expect.js/index.js', | ||
'node_modules/happen/happen.js', | ||
// Leaflet library | ||
'node_modules/leaflet/dist/leaflet.js', | ||
// Geocoder plugin | ||
'dist/pelias-leaflet-geocoder.js', | ||
// Tests | ||
'spec/suites/**/*.js', | ||
// Misc | ||
{ pattern: 'dist/images/*.png', included: false } | ||
]; | ||
|
||
config.set({ | ||
// base path, that will be used to resolve files and exclude | ||
basePath: '../', | ||
|
||
plugins: [ | ||
'karma-mocha', | ||
'karma-coverage', | ||
'karma-phantomjs-launcher', | ||
'karma-chrome-launcher', | ||
'karma-safari-launcher', | ||
'karma-firefox-launcher', | ||
], | ||
|
||
// frameworks to use | ||
frameworks: ['mocha'], | ||
|
||
// list of files / patterns to load in the browser | ||
files: files, | ||
exclude: [], | ||
|
||
// test results reporter to use | ||
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage' | ||
reporters: ['dots'], | ||
|
||
// web server port | ||
port: 9876, | ||
|
||
// level of logging | ||
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG | ||
logLevel: config.LOG_WARN, | ||
|
||
// enable / disable colors in the output (reporters and logs) | ||
colors: true, | ||
|
||
// enable / disable watching file and executing tests whenever any file changes | ||
autoWatch: false, | ||
|
||
// Start these browsers, currently available: | ||
// - Chrome | ||
// - ChromeCanary | ||
// - Firefox | ||
// - Opera | ||
// - Safari (only Mac) | ||
// - PhantomJS | ||
// - IE (only Windows) | ||
browsers: ['PhantomJS'], | ||
|
||
// If browser does not capture in given timeout [ms], kill it | ||
captureTimeout: 5000, | ||
|
||
// Workaround for PhantomJS random DISCONNECTED error | ||
browserDisconnectTimeout: 10000, // default 2000 | ||
browserDisconnectTolerance: 1, // default 0 | ||
|
||
// Continuous Integration mode | ||
// if true, it capture browsers, run tests and exit | ||
singleRun: true | ||
}); | ||
}; |
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,37 @@ | ||
describe('Control', function () { | ||
var map; | ||
|
||
beforeEach(function () { | ||
map = L.map(document.createElement('div')); | ||
}); | ||
|
||
describe('#addTo', function () { | ||
it('adds the geocoder control to the map', function () { | ||
var geocoder = new L.Control.Geocoder(); | ||
geocoder.addTo(map); | ||
expect(map.getContainer().querySelector('.leaflet-pelias-control')).to.equal(geocoder.getContainer()); | ||
}); | ||
}); | ||
|
||
// Note: this is Leaflet v1 | ||
// Previous versions of Leaflet: geocoder.removeFrom(map); | ||
describe('#remove', function () { | ||
it('removes the geocoder control from the map', function () { | ||
var geocoder = new L.Control.Geocoder(); | ||
geocoder.addTo(map).remove(); | ||
expect(map.getContainer().querySelector('.leaflet-pelias-control')).to.equal(null); | ||
}); | ||
|
||
it('calls onRemove if defined', function () { | ||
var geocoder = new L.Control.Geocoder(); | ||
geocoder.onRemove = sinon.spy(); | ||
geocoder.addTo(map).remove(); | ||
expect(geocoder.onRemove.called).to.be(true); | ||
}); | ||
|
||
it('is a no-op if the geocoder control has not been added', function () { | ||
var geocoder = new L.Control.Geocoder(); | ||
expect(geocoder.remove()).to.equal(geocoder); | ||
}); | ||
}); | ||
}); |
Empty file.