Use mocha
This commit is contained in:
parent
b84be89095
commit
a2f7d7e834
@ -32,7 +32,7 @@ function getFiles(compsBase32) {
|
||||
|
||||
if (compsBase32) {
|
||||
comps = parseInt(compsBase32, 32).toString(2).split('');
|
||||
console.log('Managing dependencies...')
|
||||
console.log('Managing dependencies...');
|
||||
}
|
||||
|
||||
function addFiles(srcs) {
|
||||
@ -160,6 +160,8 @@ exports.test = function() {
|
||||
testConfig = {configFile : __dirname + '/../spec/karma.conf.js'};
|
||||
|
||||
testConfig.browsers = ['PhantomJS'];
|
||||
if (isArgv('--chrome')) testConfig.browsers.push('Chrome');
|
||||
if (isArgv('--ff')) testConfig.browsers.push('Firefox');
|
||||
|
||||
if (isArgv('--chrome')) {
|
||||
testConfig.browsers.push('Chrome');
|
||||
@ -170,7 +172,7 @@ exports.test = function() {
|
||||
|
||||
if (isArgv('--cov')) {
|
||||
testConfig.preprocessors = {
|
||||
'**/src/**/*.js': 'coverage',
|
||||
'**/src/**/*.js': 'coverage'
|
||||
};
|
||||
testConfig.coverageReporter = {
|
||||
type : 'html',
|
||||
@ -184,4 +186,4 @@ exports.test = function() {
|
||||
function isArgv(optName) {
|
||||
return process.argv.indexOf(optName) !== -1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
1253
spec/expect.js
Normal file
1253
spec/expect.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Jasmine Spec Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="jasmine/jasmine.css">
|
||||
<script type="text/javascript" src="jasmine/jasmine.js"></script>
|
||||
<script type="text/javascript" src="jasmine/jasmine-html.js"></script>
|
||||
<meta charset="utf-8">
|
||||
<title>Spec Runner</title>
|
||||
<link rel="stylesheet" type="text/css" href="mocha/mocha.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="expect.js"></script>
|
||||
<script type="text/javascript" src="mocha/mocha.js"></script>
|
||||
<script type="text/javascript" src="happen.js"></script>
|
||||
<script type="text/javascript" src="sinon.js"></script>
|
||||
|
||||
<!-- source files -->
|
||||
<script type="text/javascript" src="before.js"></script>
|
||||
@ -13,6 +18,10 @@
|
||||
|
||||
<script type="text/javascript" src="../debug/leaflet-include.js"></script>
|
||||
|
||||
<script>
|
||||
mocha.setup('bdd');
|
||||
mocha.ignoreLeaks();
|
||||
</script>
|
||||
|
||||
<!-- spec files -->
|
||||
|
||||
@ -59,22 +68,9 @@
|
||||
|
||||
<!-- /map -->
|
||||
<script type="text/javascript" src="suites/map/MapSpec.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script type="text/javascript">
|
||||
(function() {
|
||||
var jasmineEnv = jasmine.getEnv();
|
||||
jasmineEnv.updateInterval = 1000;
|
||||
|
||||
var htmlReporter = new jasmine.HtmlReporter();
|
||||
jasmineEnv.addReporter(htmlReporter);
|
||||
|
||||
jasmineEnv.specFilter = function(spec) {
|
||||
return htmlReporter.specFilter(spec);
|
||||
};
|
||||
|
||||
jasmineEnv.execute();
|
||||
})();
|
||||
</script>
|
||||
<script>
|
||||
(window.mochaPhantomJS || window.mocha).run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -1,20 +0,0 @@
|
||||
Copyright (c) 2008-2011 Pivotal Labs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@ -1,681 +0,0 @@
|
||||
jasmine.HtmlReporterHelpers = {};
|
||||
|
||||
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) {
|
||||
el.appendChild(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
||||
var results = child.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
|
||||
return status;
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
||||
var parentDiv = this.dom.summary;
|
||||
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
||||
var parent = child[parentSuite];
|
||||
|
||||
if (parent) {
|
||||
if (typeof this.views.suites[parent.id] == 'undefined') {
|
||||
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
||||
}
|
||||
parentDiv = this.views.suites[parent.id].element;
|
||||
}
|
||||
|
||||
parentDiv.appendChild(childElement);
|
||||
};
|
||||
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
||||
for(var fn in jasmine.HtmlReporterHelpers) {
|
||||
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter = function(_doc) {
|
||||
var self = this;
|
||||
var doc = _doc || window.document;
|
||||
|
||||
var reporterView;
|
||||
|
||||
var dom = {};
|
||||
|
||||
// Jasmine Reporter Public Interface
|
||||
self.logRunningSpecs = false;
|
||||
|
||||
self.reportRunnerStarting = function(runner) {
|
||||
var specs = runner.specs() || [];
|
||||
|
||||
if (specs.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
createReporterDom(runner.env.versionString());
|
||||
doc.body.appendChild(dom.reporter);
|
||||
setExceptionHandling();
|
||||
|
||||
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
||||
reporterView.addSpecs(specs, self.specFilter);
|
||||
};
|
||||
|
||||
self.reportRunnerResults = function(runner) {
|
||||
reporterView && reporterView.complete();
|
||||
};
|
||||
|
||||
self.reportSuiteResults = function(suite) {
|
||||
reporterView.suiteComplete(suite);
|
||||
};
|
||||
|
||||
self.reportSpecStarting = function(spec) {
|
||||
if (self.logRunningSpecs) {
|
||||
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
self.reportSpecResults = function(spec) {
|
||||
reporterView.specComplete(spec);
|
||||
};
|
||||
|
||||
self.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.specFilter = function(spec) {
|
||||
if (!focusedSpecName()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return spec.getFullName().indexOf(focusedSpecName()) === 0;
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function focusedSpecName() {
|
||||
var specName;
|
||||
|
||||
(function memoizeFocusedSpec() {
|
||||
if (specName) {
|
||||
return;
|
||||
}
|
||||
|
||||
var paramMap = [];
|
||||
var params = jasmine.HtmlReporter.parameters(doc);
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
specName = paramMap.spec;
|
||||
})();
|
||||
|
||||
return specName;
|
||||
}
|
||||
|
||||
function createReporterDom(version) {
|
||||
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
||||
dom.banner = self.createDom('div', { className: 'banner' },
|
||||
self.createDom('span', { className: 'title' }, "Jasmine "),
|
||||
self.createDom('span', { className: 'version' }, version)),
|
||||
|
||||
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
||||
dom.alert = self.createDom('div', {className: 'alert'},
|
||||
self.createDom('span', { className: 'exceptions' },
|
||||
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
|
||||
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
|
||||
dom.results = self.createDom('div', {className: 'results'},
|
||||
dom.summary = self.createDom('div', { className: 'summary' }),
|
||||
dom.details = self.createDom('div', { id: 'details' }))
|
||||
);
|
||||
}
|
||||
|
||||
function noTryCatch() {
|
||||
return window.location.search.match(/catch=false/);
|
||||
}
|
||||
|
||||
function searchWithCatch() {
|
||||
var params = jasmine.HtmlReporter.parameters(window.document);
|
||||
var removed = false;
|
||||
var i = 0;
|
||||
|
||||
while (!removed && i < params.length) {
|
||||
if (params[i].match(/catch=/)) {
|
||||
params.splice(i, 1);
|
||||
removed = true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
|
||||
return params.join("&");
|
||||
}
|
||||
|
||||
function setExceptionHandling() {
|
||||
var chxCatch = document.getElementById('no_try_catch');
|
||||
|
||||
if (noTryCatch()) {
|
||||
chxCatch.setAttribute('checked', true);
|
||||
jasmine.CATCH_EXCEPTIONS = false;
|
||||
}
|
||||
chxCatch.onclick = function() {
|
||||
window.location.search = searchWithCatch();
|
||||
};
|
||||
}
|
||||
};
|
||||
jasmine.HtmlReporter.parameters = function(doc) {
|
||||
var paramStr = doc.location.search.substring(1);
|
||||
var params = [];
|
||||
|
||||
if (paramStr.length > 0) {
|
||||
params = paramStr.split('&');
|
||||
}
|
||||
return params;
|
||||
}
|
||||
jasmine.HtmlReporter.sectionLink = function(sectionName) {
|
||||
var link = '?';
|
||||
var params = [];
|
||||
|
||||
if (sectionName) {
|
||||
params.push('spec=' + encodeURIComponent(sectionName));
|
||||
}
|
||||
if (!jasmine.CATCH_EXCEPTIONS) {
|
||||
params.push("catch=false");
|
||||
}
|
||||
if (params.length > 0) {
|
||||
link += params.join("&");
|
||||
}
|
||||
|
||||
return link;
|
||||
};
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
||||
jasmine.HtmlReporter.ReporterView = function(dom) {
|
||||
this.startedAt = new Date();
|
||||
this.runningSpecCount = 0;
|
||||
this.completeSpecCount = 0;
|
||||
this.passedCount = 0;
|
||||
this.failedCount = 0;
|
||||
this.skippedCount = 0;
|
||||
|
||||
this.createResultsMenu = function() {
|
||||
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
||||
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
||||
' | ',
|
||||
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
||||
|
||||
this.summaryMenuItem.onclick = function() {
|
||||
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
||||
};
|
||||
|
||||
this.detailsMenuItem.onclick = function() {
|
||||
showDetails();
|
||||
};
|
||||
};
|
||||
|
||||
this.addSpecs = function(specs, specFilter) {
|
||||
this.totalSpecCount = specs.length;
|
||||
|
||||
this.views = {
|
||||
specs: {},
|
||||
suites: {}
|
||||
};
|
||||
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
var spec = specs[i];
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
|
||||
if (specFilter(spec)) {
|
||||
this.runningSpecCount++;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.specComplete = function(spec) {
|
||||
this.completeSpecCount++;
|
||||
|
||||
if (isUndefined(this.views.specs[spec.id])) {
|
||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
||||
}
|
||||
|
||||
var specView = this.views.specs[spec.id];
|
||||
|
||||
switch (specView.status()) {
|
||||
case 'passed':
|
||||
this.passedCount++;
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.failedCount++;
|
||||
break;
|
||||
|
||||
case 'skipped':
|
||||
this.skippedCount++;
|
||||
break;
|
||||
}
|
||||
|
||||
specView.refresh();
|
||||
this.refresh();
|
||||
};
|
||||
|
||||
this.suiteComplete = function(suite) {
|
||||
var suiteView = this.views.suites[suite.id];
|
||||
if (isUndefined(suiteView)) {
|
||||
return;
|
||||
}
|
||||
suiteView.refresh();
|
||||
};
|
||||
|
||||
this.refresh = function() {
|
||||
|
||||
if (isUndefined(this.resultsMenu)) {
|
||||
this.createResultsMenu();
|
||||
}
|
||||
|
||||
// currently running UI
|
||||
if (isUndefined(this.runningAlert)) {
|
||||
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
|
||||
dom.alert.appendChild(this.runningAlert);
|
||||
}
|
||||
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
||||
|
||||
// skipped specs UI
|
||||
if (isUndefined(this.skippedAlert)) {
|
||||
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
|
||||
}
|
||||
|
||||
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.skippedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.skippedAlert);
|
||||
}
|
||||
|
||||
// passing specs UI
|
||||
if (isUndefined(this.passedAlert)) {
|
||||
this.passedAlert = this.createDom('span', { href: jasmine.HtmlReporter.sectionLink(), className: "passingAlert bar" });
|
||||
}
|
||||
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
||||
|
||||
// failing specs UI
|
||||
if (isUndefined(this.failedAlert)) {
|
||||
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
|
||||
}
|
||||
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
|
||||
|
||||
if (this.failedCount === 1 && isDefined(dom.alert)) {
|
||||
dom.alert.appendChild(this.failedAlert);
|
||||
dom.alert.appendChild(this.resultsMenu);
|
||||
}
|
||||
|
||||
// summary info
|
||||
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
|
||||
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
||||
};
|
||||
|
||||
this.complete = function() {
|
||||
dom.alert.removeChild(this.runningAlert);
|
||||
|
||||
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
||||
|
||||
if (this.failedCount === 0) {
|
||||
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
||||
} else {
|
||||
showDetails();
|
||||
}
|
||||
|
||||
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
|
||||
};
|
||||
|
||||
return this;
|
||||
|
||||
function showDetails() {
|
||||
if (dom.reporter.className.search(/showDetails/) === -1) {
|
||||
dom.reporter.className += " showDetails";
|
||||
}
|
||||
}
|
||||
|
||||
function isUndefined(obj) {
|
||||
return typeof obj === 'undefined';
|
||||
}
|
||||
|
||||
function isDefined(obj) {
|
||||
return !isUndefined(obj);
|
||||
}
|
||||
|
||||
function specPluralizedFor(count) {
|
||||
var str = count + " spec";
|
||||
if (count > 1) {
|
||||
str += "s"
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
|
||||
|
||||
|
||||
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
||||
this.spec = spec;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.symbol = this.createDom('li', { className: 'pending' });
|
||||
this.dom.symbolSummary.appendChild(this.symbol);
|
||||
|
||||
this.summary = this.createDom('div', { className: 'specSummary' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.description)
|
||||
);
|
||||
|
||||
this.detail = this.createDom('div', { className: 'specDetail' },
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
||||
title: this.spec.getFullName()
|
||||
}, this.spec.getFullName())
|
||||
);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.spec);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
||||
this.symbol.className = this.status();
|
||||
|
||||
switch (this.status()) {
|
||||
case 'skipped':
|
||||
break;
|
||||
|
||||
case 'passed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
break;
|
||||
|
||||
case 'failed':
|
||||
this.appendSummaryToSuiteDiv();
|
||||
this.appendFailureDetail();
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
||||
this.summary.className += ' ' + this.status();
|
||||
this.appendToSummary(this.spec, this.summary);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
||||
this.detail.className += ' ' + this.status();
|
||||
|
||||
var resultItems = this.spec.results().getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
this.detail.appendChild(messagesDiv);
|
||||
this.dom.details.appendChild(this.detail);
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
||||
this.suite = suite;
|
||||
this.dom = dom;
|
||||
this.views = views;
|
||||
|
||||
this.element = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
|
||||
);
|
||||
|
||||
this.appendToSummary(this.suite, this.element);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
||||
return this.getSpecStatus(this.suite);
|
||||
};
|
||||
|
||||
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
||||
this.element.className += " " + this.status();
|
||||
};
|
||||
|
||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
||||
|
||||
/* @deprecated Use jasmine.HtmlReporter instead
|
||||
*/
|
||||
jasmine.TrivialReporter = function(doc) {
|
||||
this.document = doc || document;
|
||||
this.suiteDivs = {};
|
||||
this.logRunningSpecs = false;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
||||
var el = document.createElement(type);
|
||||
|
||||
for (var i = 2; i < arguments.length; i++) {
|
||||
var child = arguments[i];
|
||||
|
||||
if (typeof child === 'string') {
|
||||
el.appendChild(document.createTextNode(child));
|
||||
} else {
|
||||
if (child) { el.appendChild(child); }
|
||||
}
|
||||
}
|
||||
|
||||
for (var attr in attrs) {
|
||||
if (attr == "className") {
|
||||
el[attr] = attrs[attr];
|
||||
} else {
|
||||
el.setAttribute(attr, attrs[attr]);
|
||||
}
|
||||
}
|
||||
|
||||
return el;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
||||
var showPassed, showSkipped;
|
||||
|
||||
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
||||
this.createDom('div', { className: 'banner' },
|
||||
this.createDom('div', { className: 'logo' },
|
||||
this.createDom('span', { className: 'title' }, "Jasmine"),
|
||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
||||
this.createDom('div', { className: 'options' },
|
||||
"Show ",
|
||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
||||
)
|
||||
),
|
||||
|
||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
||||
);
|
||||
|
||||
this.document.body.appendChild(this.outerDiv);
|
||||
|
||||
var suites = runner.suites();
|
||||
for (var i = 0; i < suites.length; i++) {
|
||||
var suite = suites[i];
|
||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
||||
this.suiteDivs[suite.id] = suiteDiv;
|
||||
var parentDiv = this.outerDiv;
|
||||
if (suite.parentSuite) {
|
||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
||||
}
|
||||
parentDiv.appendChild(suiteDiv);
|
||||
}
|
||||
|
||||
this.startedAt = new Date();
|
||||
|
||||
var self = this;
|
||||
showPassed.onclick = function(evt) {
|
||||
if (showPassed.checked) {
|
||||
self.outerDiv.className += ' show-passed';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
||||
}
|
||||
};
|
||||
|
||||
showSkipped.onclick = function(evt) {
|
||||
if (showSkipped.checked) {
|
||||
self.outerDiv.className += ' show-skipped';
|
||||
} else {
|
||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
||||
var results = runner.results();
|
||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
||||
this.runnerDiv.setAttribute("class", className);
|
||||
//do it twice for IE
|
||||
this.runnerDiv.setAttribute("className", className);
|
||||
var specs = runner.specs();
|
||||
var specCount = 0;
|
||||
for (var i = 0; i < specs.length; i++) {
|
||||
if (this.specFilter(specs[i])) {
|
||||
specCount++;
|
||||
}
|
||||
}
|
||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
||||
|
||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
||||
var results = suite.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
||||
status = 'skipped';
|
||||
}
|
||||
this.suiteDivs[suite.id].className += " " + status;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
||||
if (this.logRunningSpecs) {
|
||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
||||
var results = spec.results();
|
||||
var status = results.passed() ? 'passed' : 'failed';
|
||||
if (results.skipped) {
|
||||
status = 'skipped';
|
||||
}
|
||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
||||
this.createDom('a', {
|
||||
className: 'description',
|
||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
||||
title: spec.getFullName()
|
||||
}, spec.description));
|
||||
|
||||
|
||||
var resultItems = results.getItems();
|
||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
||||
for (var i = 0; i < resultItems.length; i++) {
|
||||
var result = resultItems[i];
|
||||
|
||||
if (result.type == 'log') {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
||||
|
||||
if (result.trace.stack) {
|
||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (messagesDiv.childNodes.length > 0) {
|
||||
specDiv.appendChild(messagesDiv);
|
||||
}
|
||||
|
||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.log = function() {
|
||||
var console = jasmine.getGlobal().console;
|
||||
if (console && console.log) {
|
||||
if (console.log.apply) {
|
||||
console.log.apply(console, arguments);
|
||||
} else {
|
||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
||||
return this.document.location;
|
||||
};
|
||||
|
||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
||||
var paramMap = {};
|
||||
var params = this.getLocation().search.substring(1).split('&');
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
var p = params[i].split('=');
|
||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
||||
}
|
||||
|
||||
if (!paramMap.spec) {
|
||||
return true;
|
||||
}
|
||||
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
||||
};
|
@ -1,82 +0,0 @@
|
||||
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
||||
|
||||
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
|
||||
#HTMLReporter a { text-decoration: none; }
|
||||
#HTMLReporter a:hover { text-decoration: underline; }
|
||||
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
|
||||
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
|
||||
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#HTMLReporter .version { color: #aaaaaa; }
|
||||
#HTMLReporter .banner { margin-top: 14px; }
|
||||
#HTMLReporter .duration { color: #aaaaaa; float: right; }
|
||||
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
||||
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
|
||||
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
|
||||
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
|
||||
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
|
||||
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
|
||||
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
|
||||
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
|
||||
#HTMLReporter .exceptions { color: #fff; float: right; margin-top: 5px; margin-right: 5px; }
|
||||
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
||||
#HTMLReporter .runningAlert { background-color: #666666; }
|
||||
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
|
||||
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
|
||||
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
|
||||
#HTMLReporter .passingAlert { background-color: #a6b779; }
|
||||
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
|
||||
#HTMLReporter .failingAlert { background-color: #cf867e; }
|
||||
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
|
||||
#HTMLReporter .results { margin-top: 14px; }
|
||||
#HTMLReporter #details { display: none; }
|
||||
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
||||
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter.showDetails .summary { display: none; }
|
||||
#HTMLReporter.showDetails #details { display: block; }
|
||||
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
||||
#HTMLReporter .summary { margin-top: 14px; }
|
||||
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
|
||||
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
|
||||
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
|
||||
#HTMLReporter .description + .suite { margin-top: 0; }
|
||||
#HTMLReporter .suite { margin-top: 14px; }
|
||||
#HTMLReporter .suite a { color: #333333; }
|
||||
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
|
||||
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
|
||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
||||
#HTMLReporter .resultMessage span.result { display: block; }
|
||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
||||
|
||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
||||
#TrivialReporter .runner.running { background-color: yellow; }
|
||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
||||
#TrivialReporter .suite .suite { margin: 5px; }
|
||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
||||
#TrivialReporter .failed { background-color: #fbb; }
|
||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
||||
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
|
File diff suppressed because it is too large
Load Diff
@ -10,10 +10,12 @@ for (var i=0; i < libSources.length; i++) {
|
||||
|
||||
// list of files / patterns to load in the browser
|
||||
files = [].concat([
|
||||
JASMINE,
|
||||
JASMINE_ADAPTER,
|
||||
MOCHA,
|
||||
MOCHA_ADAPTER,
|
||||
"before.js",
|
||||
"karma.js"
|
||||
"karma.js",
|
||||
"sinon.js",
|
||||
"expect.js"
|
||||
], libSources, [
|
||||
"after.js",
|
||||
"happen.js",
|
||||
|
231
spec/mocha/mocha.css
Normal file
231
spec/mocha/mocha.css
Normal file
@ -0,0 +1,231 @@
|
||||
@charset "utf-8";
|
||||
|
||||
body {
|
||||
font: 20px/1.5 "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
padding: 60px 50px;
|
||||
}
|
||||
|
||||
#mocha ul, #mocha li {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#mocha ul {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
#mocha h1, #mocha h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#mocha h1 {
|
||||
margin-top: 15px;
|
||||
font-size: 1em;
|
||||
font-weight: 200;
|
||||
}
|
||||
|
||||
#mocha h1 a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#mocha h1 a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
#mocha .suite .suite h1 {
|
||||
margin-top: 0;
|
||||
font-size: .8em;
|
||||
}
|
||||
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha h2 {
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#mocha .suite {
|
||||
margin-left: 15px;
|
||||
}
|
||||
|
||||
#mocha .test {
|
||||
margin-left: 15px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#mocha .test.pending:hover h2::after {
|
||||
content: '(pending)';
|
||||
font-family: arial;
|
||||
}
|
||||
|
||||
#mocha .test.pass.medium .duration {
|
||||
background: #C09853;
|
||||
}
|
||||
|
||||
#mocha .test.pass.slow .duration {
|
||||
background: #B94A48;
|
||||
}
|
||||
|
||||
#mocha .test.pass::before {
|
||||
content: '✓';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
color: #00d6b2;
|
||||
}
|
||||
|
||||
#mocha .test.pass .duration {
|
||||
font-size: 9px;
|
||||
margin-left: 5px;
|
||||
padding: 2px 5px;
|
||||
color: white;
|
||||
-webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-moz-box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
box-shadow: inset 0 1px 1px rgba(0,0,0,.2);
|
||||
-webkit-border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-ms-border-radius: 5px;
|
||||
-o-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
#mocha .test.pass.fast .duration {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha .test.pending {
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.pending::before {
|
||||
content: '◦';
|
||||
color: #0b97c4;
|
||||
}
|
||||
|
||||
#mocha .test.fail {
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test.fail pre {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#mocha .test.fail::before {
|
||||
content: '✖';
|
||||
font-size: 12px;
|
||||
display: block;
|
||||
float: left;
|
||||
margin-right: 5px;
|
||||
color: #c00;
|
||||
}
|
||||
|
||||
#mocha .test pre.error {
|
||||
color: #c00;
|
||||
max-height: 300px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
#mocha .test pre {
|
||||
display: block;
|
||||
float: left;
|
||||
clear: left;
|
||||
font: 12px/1.5 monaco, monospace;
|
||||
margin: 5px;
|
||||
padding: 15px;
|
||||
border: 1px solid #eee;
|
||||
border-bottom-color: #ddd;
|
||||
-webkit-border-radius: 3px;
|
||||
-webkit-box-shadow: 0 1px 3px #eee;
|
||||
-moz-border-radius: 3px;
|
||||
-moz-box-shadow: 0 1px 3px #eee;
|
||||
}
|
||||
|
||||
#mocha .test h2 {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#mocha .test a.replay {
|
||||
position: absolute;
|
||||
top: 3px;
|
||||
right: 0;
|
||||
text-decoration: none;
|
||||
vertical-align: middle;
|
||||
display: block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
line-height: 15px;
|
||||
text-align: center;
|
||||
background: #eee;
|
||||
font-size: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
border-radius: 15px;
|
||||
-webkit-transition: opacity 200ms;
|
||||
-moz-transition: opacity 200ms;
|
||||
transition: opacity 200ms;
|
||||
opacity: 0.3;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#mocha .test:hover a.replay {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
#mocha-report.pass .test.fail {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha-report.fail .test.pass {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#mocha-error {
|
||||
color: #c00;
|
||||
font-size: 1.5 em;
|
||||
font-weight: 100;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
#mocha-stats {
|
||||
position: fixed;
|
||||
top: 15px;
|
||||
right: 10px;
|
||||
font-size: 12px;
|
||||
margin: 0;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
#mocha-stats .progress {
|
||||
float: right;
|
||||
padding-top: 0;
|
||||
}
|
||||
|
||||
#mocha-stats em {
|
||||
color: black;
|
||||
}
|
||||
|
||||
#mocha-stats a {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
#mocha-stats a:hover {
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
|
||||
#mocha-stats li {
|
||||
display: inline-block;
|
||||
margin: 0 5px;
|
||||
list-style: none;
|
||||
padding-top: 11px;
|
||||
}
|
||||
|
||||
code .comment { color: #ddd }
|
||||
code .init { color: #2F6FAD }
|
||||
code .string { color: #5890AD }
|
||||
code .keyword { color: #8A6343 }
|
||||
code .number { color: #2F6FAD }
|
5340
spec/mocha/mocha.js
Normal file
5340
spec/mocha/mocha.js
Normal file
File diff suppressed because it is too large
Load Diff
4223
spec/sinon.js
Normal file
4223
spec/sinon.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,12 @@
|
||||
describe('L#noConflict', function() {
|
||||
it('restores the previous L value and returns Leaflet namespace', function(){
|
||||
|
||||
expect(L.version).toBeDefined();
|
||||
expect(L.version).to.be.ok();
|
||||
|
||||
var L2 = L.noConflict();
|
||||
|
||||
expect(L).toEqual('test');
|
||||
expect(L2.version).toBeDefined();
|
||||
expect(L).to.eql('test');
|
||||
expect(L2.version).to.be.ok();
|
||||
|
||||
window.L = L2;
|
||||
});
|
||||
|
@ -11,25 +11,25 @@ describe("Control.Attribution", function () {
|
||||
});
|
||||
|
||||
it("contains just prefix if no attributions added", function () {
|
||||
expect(container.innerHTML).toEqual('prefix');
|
||||
expect(container.innerHTML).to.eql('prefix');
|
||||
});
|
||||
|
||||
describe('#addAttribution', function () {
|
||||
it('adds one attribution correctly', function () {
|
||||
control.addAttribution('foo');
|
||||
expect(container.innerHTML).toEqual('prefix | foo');
|
||||
expect(container.innerHTML).to.eql('prefix | foo');
|
||||
});
|
||||
|
||||
it('adds no duplicate attributions', function () {
|
||||
control.addAttribution('foo');
|
||||
control.addAttribution('foo');
|
||||
expect(container.innerHTML).toEqual('prefix | foo');
|
||||
expect(container.innerHTML).to.eql('prefix | foo');
|
||||
});
|
||||
|
||||
it('adds several attributions listed with comma', function () {
|
||||
control.addAttribution('foo');
|
||||
control.addAttribution('bar');
|
||||
expect(container.innerHTML).toEqual('prefix | foo, bar');
|
||||
expect(container.innerHTML).to.eql('prefix | foo, bar');
|
||||
});
|
||||
});
|
||||
|
||||
@ -38,7 +38,7 @@ describe("Control.Attribution", function () {
|
||||
control.addAttribution('foo');
|
||||
control.addAttribution('bar');
|
||||
control.removeAttribution('foo');
|
||||
expect(container.innerHTML).toEqual('prefix | bar');
|
||||
expect(container.innerHTML).to.eql('prefix | bar');
|
||||
});
|
||||
it('does nothing if removing attribution that was not present', function () {
|
||||
control.addAttribution('foo');
|
||||
@ -47,21 +47,21 @@ describe("Control.Attribution", function () {
|
||||
control.removeAttribution('baz');
|
||||
control.removeAttribution('baz');
|
||||
control.removeAttribution('');
|
||||
expect(container.innerHTML).toEqual('prefix | foo');
|
||||
expect(container.innerHTML).to.eql('prefix | foo');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setPrefix', function () {
|
||||
it('changes prefix', function () {
|
||||
control.setPrefix('bla');
|
||||
expect(container.innerHTML).toEqual('bla');
|
||||
expect(container.innerHTML).to.eql('bla');
|
||||
});
|
||||
});
|
||||
|
||||
describe('control.attribution factory', function () {
|
||||
it('creates Control.Attribution instance', function () {
|
||||
var options = {prefix: 'prefix'};
|
||||
expect(L.control.attribution(options)).toEqual(new L.Control.Attribution(options));
|
||||
expect(L.control.attribution(options)).to.eql(new L.Control.Attribution(options));
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -9,26 +9,26 @@ describe("Control.Layers", function () {
|
||||
it("is fired on input that changes the base layer", function () {
|
||||
var baseLayers = {"Layer 1": L.tileLayer(), "Layer 2": L.tileLayer()},
|
||||
layers = L.control.layers(baseLayers).addTo(map),
|
||||
spy = jasmine.createSpy();
|
||||
spy = sinon.spy();
|
||||
|
||||
map.on('baselayerchange', spy)
|
||||
.whenReady(function(){
|
||||
.whenReady(function() {
|
||||
happen.click(layers._baseLayersList.getElementsByTagName("input")[0]);
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.mostRecentCall.args[0].layer).toBe(baseLayers["Layer 1"]);
|
||||
expect(spy.called).to.be.ok();
|
||||
expect(spy.mostRecentCall.args[0].layer).to.be(baseLayers["Layer 1"]);
|
||||
});
|
||||
});
|
||||
|
||||
it("is not fired on input that doesn't change the base layer", function () {
|
||||
var overlays = {"Marker 1": L.marker([0, 0]), "Marker 2": L.marker([0, 0])},
|
||||
layers = L.control.layers({}, overlays).addTo(map),
|
||||
spy = jasmine.createSpy();
|
||||
spy = sinon.spy();
|
||||
|
||||
map.on('baselayerchange', spy);
|
||||
happen.click(layers._overlaysList.getElementsByTagName("input")[0]);
|
||||
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
@ -42,13 +42,13 @@ describe("Control.Layers", function () {
|
||||
overlay = L.marker([0, 0]),
|
||||
layers = L.control.layers({"Base": baseLayer}, {"Overlay": overlay}).addTo(map);
|
||||
|
||||
spyOn(layers, '_update').andCallThrough();
|
||||
var spy = sinon.spy(layers, '_update');
|
||||
|
||||
map.addLayer(overlay);
|
||||
map.removeLayer(overlay);
|
||||
|
||||
expect(layers._update).toHaveBeenCalled();
|
||||
expect(layers._update.callCount).toEqual(2);
|
||||
expect(spy.called).to.be.ok();
|
||||
expect(spy.callCount).to.eql(2);
|
||||
});
|
||||
|
||||
it("not when a non-included layer is added or removed", function () {
|
||||
@ -56,12 +56,12 @@ describe("Control.Layers", function () {
|
||||
overlay = L.marker([0, 0]),
|
||||
layers = L.control.layers({"Base": baseLayer}).addTo(map);
|
||||
|
||||
spyOn(layers, '_update').andCallThrough();
|
||||
var spy = sinon.spy(layers, '_update');
|
||||
|
||||
map.addLayer(overlay);
|
||||
map.removeLayer(overlay);
|
||||
|
||||
expect(layers._update).not.toHaveBeenCalled();
|
||||
expect(spy.called).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -6,8 +6,8 @@ describe("Class", function() {
|
||||
method;
|
||||
|
||||
beforeEach(function() {
|
||||
constructor = jasmine.createSpy("Klass constructor");
|
||||
method = jasmine.createSpy("Klass#bar method");
|
||||
constructor = sinon.spy();
|
||||
method = sinon.spy();
|
||||
|
||||
Klass = L.Class.extend({
|
||||
statics: {bla: 1},
|
||||
@ -22,12 +22,12 @@ describe("Class", function() {
|
||||
it("creates a class with the given constructor & properties", function() {
|
||||
var a = new Klass();
|
||||
|
||||
expect(constructor).toHaveBeenCalled();
|
||||
expect(a.foo).toEqual(5);
|
||||
expect(constructor.called).to.be.ok();
|
||||
expect(a.foo).to.eql(5);
|
||||
|
||||
a.bar();
|
||||
|
||||
expect(method).toHaveBeenCalled();
|
||||
expect(method.called).to.be.ok();
|
||||
});
|
||||
|
||||
it("inherits parent classes' constructor & properties", function() {
|
||||
@ -35,36 +35,36 @@ describe("Class", function() {
|
||||
|
||||
var b = new Klass2();
|
||||
|
||||
expect(b instanceof Klass).toBeTruthy();
|
||||
expect(b instanceof Klass2).toBeTruthy();
|
||||
expect(b instanceof Klass).to.be.ok();
|
||||
expect(b instanceof Klass2).to.be.ok();
|
||||
|
||||
expect(constructor).toHaveBeenCalled();
|
||||
expect(b.baz).toEqual(2);
|
||||
expect(constructor.called).to.be.ok();
|
||||
expect(b.baz).to.eql(2);
|
||||
|
||||
b.bar();
|
||||
|
||||
expect(method).toHaveBeenCalled();
|
||||
expect(method.called).to.be.ok();
|
||||
});
|
||||
|
||||
it("supports static properties", function() {
|
||||
expect(Klass.bla).toEqual(1);
|
||||
expect(Klass.bla).to.eql(1);
|
||||
});
|
||||
|
||||
it("inherits parent static properties", function() {
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
expect(Klass2.bla).toEqual(1);
|
||||
expect(Klass2.bla).to.eql(1);
|
||||
});
|
||||
|
||||
it("overrides parent static properties", function() {
|
||||
var Klass2 = Klass.extend({statics: {bla: 2}});
|
||||
|
||||
expect(Klass2.bla).toEqual(2);
|
||||
expect(Klass2.bla).to.eql(2);
|
||||
});
|
||||
|
||||
it("includes the given mixin", function() {
|
||||
var a = new Klass();
|
||||
expect(a.mixin).toBeTruthy();
|
||||
expect(a.mixin).to.be.ok();
|
||||
});
|
||||
|
||||
it("includes multiple mixins", function() {
|
||||
@ -73,15 +73,15 @@ describe("Class", function() {
|
||||
});
|
||||
var a = new Klass2();
|
||||
|
||||
expect(a.mixin).toBeTruthy();
|
||||
expect(a.mixin2).toBeTruthy();
|
||||
expect(a.mixin).to.be.ok();
|
||||
expect(a.mixin2).to.be.ok();
|
||||
});
|
||||
|
||||
it("grants the ability to include the given mixin", function() {
|
||||
Klass.include({mixin2: true});
|
||||
|
||||
var a = new Klass();
|
||||
expect(a.mixin2).toBeTruthy();
|
||||
expect(a.mixin2).to.be.ok();
|
||||
});
|
||||
|
||||
it("merges options instead of replacing them", function() {
|
||||
@ -100,7 +100,7 @@ describe("Class", function() {
|
||||
|
||||
var a = new KlassWithOptions2();
|
||||
|
||||
expect(a.options).toEqual({
|
||||
expect(a.options).to.eql({
|
||||
foo1: 1,
|
||||
foo2: 3,
|
||||
foo3: 4
|
||||
@ -108,20 +108,20 @@ describe("Class", function() {
|
||||
});
|
||||
|
||||
it("adds constructor hooks correctly", function () {
|
||||
var spy1 = jasmine.createSpy("init hook 1");
|
||||
var spy1 = sinon.spy();
|
||||
|
||||
Klass.addInitHook(spy1);
|
||||
Klass.addInitHook('bar', 1, 2, 3);
|
||||
|
||||
var a = new Klass();
|
||||
|
||||
expect(spy1).toHaveBeenCalled();
|
||||
expect(method).toHaveBeenCalledWith(1, 2, 3);
|
||||
expect(spy1.called).to.be.ok();
|
||||
expect(method.calledWith(1, 2, 3));
|
||||
});
|
||||
|
||||
it("inherits constructor hooks", function () {
|
||||
var spy1 = jasmine.createSpy("init hook 1"),
|
||||
spy2 = jasmine.createSpy("init hook 2");
|
||||
var spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy();
|
||||
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
@ -130,13 +130,13 @@ describe("Class", function() {
|
||||
|
||||
var a = new Klass2();
|
||||
|
||||
expect(spy1).toHaveBeenCalled();
|
||||
expect(spy2).toHaveBeenCalled();
|
||||
expect(spy1.called).to.be.ok();
|
||||
expect(spy2.called).to.be.ok();
|
||||
});
|
||||
|
||||
it("does not call child constructor hooks", function () {
|
||||
var spy1 = jasmine.createSpy("init hook 1"),
|
||||
spy2 = jasmine.createSpy("init hook 2");
|
||||
var spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy();
|
||||
|
||||
var Klass2 = Klass.extend({});
|
||||
|
||||
@ -145,8 +145,8 @@ describe("Class", function() {
|
||||
|
||||
var a = new Klass();
|
||||
|
||||
expect(spy1).toHaveBeenCalled();
|
||||
expect(spy2).not.toHaveBeenCalled();
|
||||
expect(spy1.called).to.be.ok();
|
||||
expect(spy2.called).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -11,35 +11,35 @@ describe('Events', function() {
|
||||
|
||||
it('fires all listeners added through #addEventListener', function() {
|
||||
var obj = new Klass(),
|
||||
spy = jasmine.createSpy(),
|
||||
spy2 = jasmine.createSpy(),
|
||||
spy3 = jasmine.createSpy(),
|
||||
spy4 = jasmine.createSpy(),
|
||||
spy5 = jasmine.createSpy();
|
||||
spy6 = jasmine.createSpy();
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
spy3 = sinon.spy(),
|
||||
spy4 = sinon.spy(),
|
||||
spy5 = sinon.spy();
|
||||
spy6 = sinon.spy();
|
||||
|
||||
obj.addEventListener('test', spy);
|
||||
obj.addEventListener('test', spy1);
|
||||
obj.addEventListener('test', spy2);
|
||||
obj.addEventListener('other', spy3);
|
||||
obj.addEventListener({ test: spy4, other: spy5 });
|
||||
obj.addEventListener({'test other': spy6 });
|
||||
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy2).not.toHaveBeenCalled();
|
||||
expect(spy3).not.toHaveBeenCalled();
|
||||
expect(spy4).not.toHaveBeenCalled();
|
||||
expect(spy5).not.toHaveBeenCalled();
|
||||
expect(spy6).not.toHaveBeenCalled();
|
||||
expect(spy1.called).to.be(false);
|
||||
expect(spy2.called).to.be(false);
|
||||
expect(spy3.called).to.be(false);
|
||||
expect(spy4.called).to.be(false);
|
||||
expect(spy5.called).to.be(false);
|
||||
expect(spy6.called).to.be(false);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy2).toHaveBeenCalled();
|
||||
expect(spy3).not.toHaveBeenCalled();
|
||||
expect(spy4).toHaveBeenCalled();
|
||||
expect(spy5).not.toHaveBeenCalled();
|
||||
expect(spy6).toHaveBeenCalled();
|
||||
expect(spy6.calls.length).toEqual(1);
|
||||
expect(spy1.called).to.be(true);
|
||||
expect(spy2.called).to.be(true);
|
||||
expect(spy3.called).to.be(false);
|
||||
expect(spy4.called).to.be(true);
|
||||
expect(spy5.called).to.be(false);
|
||||
expect(spy6.called).to.be(true);
|
||||
expect(spy6.callCount).to.be(1);
|
||||
});
|
||||
|
||||
it('provides event object to listeners and executes them in the right context', function() {
|
||||
@ -50,31 +50,31 @@ describe('Events', function() {
|
||||
foo = {};
|
||||
|
||||
function listener1(e) {
|
||||
expect(e.type).toEqual('test');
|
||||
expect(e.target).toEqual(obj);
|
||||
expect(this).toEqual(obj);
|
||||
expect(e.baz).toEqual(1);
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj);
|
||||
expect(this).to.eql(obj);
|
||||
expect(e.baz).to.eql(1);
|
||||
}
|
||||
|
||||
function listener2(e) {
|
||||
expect(e.type).toEqual('test');
|
||||
expect(e.target).toEqual(obj2);
|
||||
expect(this).toEqual(foo);
|
||||
expect(e.baz).toEqual(2);
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj2);
|
||||
expect(this).to.eql(foo);
|
||||
expect(e.baz).to.eql(2);
|
||||
}
|
||||
|
||||
function listener3(e) {
|
||||
expect(e.type).toEqual('test');
|
||||
expect(e.target).toEqual(obj3);
|
||||
expect(this).toEqual(obj3);
|
||||
expect(e.baz).toEqual(3);
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj3);
|
||||
expect(this).to.eql(obj3);
|
||||
expect(e.baz).to.eql(3);
|
||||
}
|
||||
|
||||
function listener4(e) {
|
||||
expect(e.type).toEqual('test');
|
||||
expect(e.target).toEqual(obj4);
|
||||
expect(this).toEqual(foo);
|
||||
expect(e.baz).toEqual(4);
|
||||
expect(e.type).to.eql('test');
|
||||
expect(e.target).to.eql(obj4);
|
||||
expect(this).to.eql(foo);
|
||||
expect(e.baz).to.eql(4);
|
||||
}
|
||||
|
||||
obj.addEventListener('test', listener1);
|
||||
@ -90,18 +90,18 @@ describe('Events', function() {
|
||||
|
||||
it('calls no listeners removed through #removeEventListener', function() {
|
||||
var obj = new Klass(),
|
||||
spy = jasmine.createSpy(),
|
||||
spy2 = jasmine.createSpy(),
|
||||
spy3 = jasmine.createSpy(),
|
||||
spy4 = jasmine.createSpy(),
|
||||
spy5 = jasmine.createSpy();
|
||||
spy = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
spy3 = sinon.spy(),
|
||||
spy4 = sinon.spy(),
|
||||
spy5 = sinon.spy();
|
||||
|
||||
obj.addEventListener('test', spy);
|
||||
obj.removeEventListener('test', spy);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).to.be(false);
|
||||
|
||||
obj.addEventListener('test2', spy2);
|
||||
obj.addEventListener('test2', spy3);
|
||||
@ -109,8 +109,8 @@ describe('Events', function() {
|
||||
|
||||
obj.fireEvent('test2');
|
||||
|
||||
expect(spy2).not.toHaveBeenCalled();
|
||||
expect(spy3).not.toHaveBeenCalled();
|
||||
expect(spy2.called).to.be(false);
|
||||
expect(spy3.called).to.be(false);
|
||||
|
||||
obj.addEventListener('test3', spy4);
|
||||
obj.addEventListener('test4', spy5);
|
||||
@ -122,45 +122,45 @@ describe('Events', function() {
|
||||
obj.fireEvent('test3');
|
||||
obj.fireEvent('test4');
|
||||
|
||||
expect(spy4).not.toHaveBeenCalled();
|
||||
expect(spy5).not.toHaveBeenCalled();
|
||||
expect(spy4.called).to.be(false);
|
||||
expect(spy5.called).to.be(false);
|
||||
});
|
||||
|
||||
// added due to context-sensitive removeListener optimization
|
||||
it('fires multiple listeners with the same context with id', function () {
|
||||
var obj = new Klass(),
|
||||
spy = jasmine.createSpy(),
|
||||
spy2 = jasmine.createSpy(),
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
L.Util.stamp(foo);
|
||||
|
||||
obj.addEventListener('test', spy, foo);
|
||||
obj.addEventListener('test', spy1, foo);
|
||||
obj.addEventListener('test', spy2, foo);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy2).toHaveBeenCalled();
|
||||
expect(spy1.called).to.be(true);
|
||||
expect(spy2.called).to.be(true);
|
||||
});
|
||||
|
||||
it('removes listeners with stamped contexts', function () {
|
||||
var obj = new Klass(),
|
||||
spy = jasmine.createSpy(),
|
||||
spy2 = jasmine.createSpy(),
|
||||
spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
L.Util.stamp(foo);
|
||||
|
||||
obj.addEventListener('test', spy, foo);
|
||||
obj.addEventListener('test', spy1, foo);
|
||||
obj.addEventListener('test', spy2, foo);
|
||||
|
||||
obj.removeEventListener('test', spy, foo);
|
||||
obj.removeEventListener('test', spy1, foo);
|
||||
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy2).toHaveBeenCalled();
|
||||
expect(spy1.called).to.be(false);
|
||||
expect(spy2.called).to.be(true);
|
||||
});
|
||||
|
||||
it('removes listeners with a stamp originally added without one', function() {
|
||||
@ -208,23 +208,23 @@ describe('Events', function() {
|
||||
|
||||
it('works like #addEventListener && #removeEventListener', function() {
|
||||
var obj = new Klass(),
|
||||
spy = jasmine.createSpy();
|
||||
spy = sinon.spy();
|
||||
|
||||
obj.on('test', spy);
|
||||
obj.fire('test');
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be(true);
|
||||
|
||||
obj.off('test', spy);
|
||||
obj.fireEvent('test');
|
||||
|
||||
expect(spy.callCount).toBeLessThan(2);
|
||||
expect(spy.callCount).to.be.lessThan(2);
|
||||
});
|
||||
|
||||
it('does not override existing methods with the same name', function() {
|
||||
var spy1 = jasmine.createSpy(),
|
||||
spy2 = jasmine.createSpy(),
|
||||
spy3 = jasmine.createSpy();
|
||||
var spy1 = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
spy3 = sinon.spy();
|
||||
|
||||
var Klass2 = L.Class.extend({
|
||||
includes: L.Mixin.Events,
|
||||
@ -236,13 +236,13 @@ describe('Events', function() {
|
||||
var obj = new Klass2();
|
||||
|
||||
obj.on();
|
||||
expect(spy1).toHaveBeenCalled();
|
||||
expect(spy1.called).to.be(true);
|
||||
|
||||
obj.off();
|
||||
expect(spy2).toHaveBeenCalled();
|
||||
expect(spy2.called).to.be(true);
|
||||
|
||||
obj.fire();
|
||||
expect(spy3).toHaveBeenCalled();
|
||||
expect(spy3.called).to.be(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ describe('Util', function() {
|
||||
baz: 3
|
||||
});
|
||||
|
||||
expect(a).toEqual({
|
||||
expect(a).to.eql({
|
||||
foo: 5,
|
||||
bar: 7,
|
||||
baz: 3
|
||||
@ -26,7 +26,7 @@ describe('Util', function() {
|
||||
it('accepts more than 2 arguments', function() {
|
||||
L.Util.extend(a, {bar: 7}, {baz: 3});
|
||||
|
||||
expect(a).toEqual({
|
||||
expect(a).to.eql({
|
||||
foo: 5,
|
||||
bar: 7,
|
||||
baz: 3
|
||||
@ -40,13 +40,13 @@ describe('Util', function() {
|
||||
return this;
|
||||
};
|
||||
|
||||
var fn2 = L.Util.bind(fn, 5);
|
||||
var fn2 = L.Util.bind(fn, { foo: 'bar' });
|
||||
|
||||
expect(fn2()).toEqual(5);
|
||||
expect(fn2()).to.eql({ foo: 'bar' });
|
||||
});
|
||||
|
||||
it('passes additional arguments to the bound function', function () {
|
||||
var fn = jasmine.createSpy(),
|
||||
var fn = sinon.spy(),
|
||||
foo = {},
|
||||
a = {},
|
||||
b = {};
|
||||
@ -55,7 +55,7 @@ describe('Util', function() {
|
||||
|
||||
fn2();
|
||||
|
||||
expect(fn).toHaveBeenCalledWith(a, b);
|
||||
expect(fn.calledWith(a, b)).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
@ -64,26 +64,26 @@ describe('Util', function() {
|
||||
var a = {},
|
||||
id = L.Util.stamp(a);
|
||||
|
||||
expect(typeof id).toEqual('number');
|
||||
expect(L.Util.stamp(a)).toEqual(id);
|
||||
expect(typeof id).to.eql('number');
|
||||
expect(L.Util.stamp(a)).to.eql(id);
|
||||
|
||||
var b = {},
|
||||
id2 = L.Util.stamp(b);
|
||||
|
||||
expect(id2).not.toEqual(id);
|
||||
expect(id2).not.to.eql(id);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#falseFn', function () {
|
||||
it('returns false', function () {
|
||||
expect(L.Util.falseFn()).toBe(false);
|
||||
expect(L.Util.falseFn()).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#formatNum', function () {
|
||||
it('formats numbers with a given precision', function () {
|
||||
expect(L.Util.formatNum(13.12325555, 3)).toEqual(13.123);
|
||||
expect(L.Util.formatNum(13.12325555)).toEqual(13.12326);
|
||||
expect(L.Util.formatNum(13.12325555, 3)).to.eql(13.123);
|
||||
expect(L.Util.formatNum(13.12325555)).to.eql(13.12326);
|
||||
});
|
||||
});
|
||||
|
||||
@ -96,7 +96,7 @@ describe('Util', function() {
|
||||
result: "?bar=7&baz=3"
|
||||
};
|
||||
|
||||
expect(L.Util.getParamString(a.obj,a.url)).toEqual(a.result);
|
||||
expect(L.Util.getParamString(a.obj,a.url)).to.eql(a.result);
|
||||
|
||||
var b = {
|
||||
url: "http://example.com/get?justone=qs",
|
||||
@ -104,7 +104,7 @@ describe('Util', function() {
|
||||
result: "&bar=7&baz=3"
|
||||
};
|
||||
|
||||
expect(L.Util.getParamString(b.obj,b.url)).toEqual(b.result);
|
||||
expect(L.Util.getParamString(b.obj,b.url)).to.eql(b.result);
|
||||
|
||||
var c = {
|
||||
url: undefined,
|
||||
@ -112,72 +112,49 @@ describe('Util', function() {
|
||||
result: "?bar=7&baz=3"
|
||||
};
|
||||
|
||||
expect(L.Util.getParamString(c.obj,c.url)).toEqual(c.result);
|
||||
expect(L.Util.getParamString(c.obj,c.url)).to.eql(c.result);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#requestAnimFrame', function () {
|
||||
it('calles a function on next frame, unless canceled', function () {
|
||||
var spy = jasmine.createSpy(),
|
||||
spy2 = jasmine.createSpy(),
|
||||
called = false,
|
||||
it('calles a function on next frame, unless canceled', function (done) {
|
||||
var spy = sinon.spy(),
|
||||
spy2 = sinon.spy(),
|
||||
foo = {};
|
||||
|
||||
runs(function () {
|
||||
L.Util.requestAnimFrame(spy);
|
||||
L.Util.requestAnimFrame(spy);
|
||||
|
||||
L.Util.requestAnimFrame(function () {
|
||||
called = true;
|
||||
expect(this).toEqual(foo);
|
||||
spy();
|
||||
}, foo);
|
||||
L.Util.requestAnimFrame(function () {
|
||||
expect(this).to.eql(foo);
|
||||
done();
|
||||
}, foo);
|
||||
|
||||
L.Util.cancelAnimFrame(spy);
|
||||
});
|
||||
|
||||
waitsFor(function () {
|
||||
return called;
|
||||
}, 'function should be called', 500);
|
||||
|
||||
runs(function () {
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy2).not.toHaveBeenCalled();
|
||||
});
|
||||
L.Util.cancelAnimFrame(spy);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#limitExecByInterval', function() {
|
||||
it('limits execution to not more often than specified time interval', function () {
|
||||
var spy = jasmine.createSpy(),
|
||||
check = false;
|
||||
it('limits execution to not more often than specified time interval', function (done) {
|
||||
var spy = sinon.spy();
|
||||
|
||||
var fn = L.Util.limitExecByInterval(spy, 20);
|
||||
|
||||
runs(function () {
|
||||
fn();
|
||||
fn();
|
||||
fn();
|
||||
fn();
|
||||
fn();
|
||||
fn();
|
||||
|
||||
expect(spy.calls.length).toEqual(1);
|
||||
expect(spy.callCount).to.eql(1);
|
||||
|
||||
setTimeout(function () {
|
||||
check = true;
|
||||
}, 30);
|
||||
});
|
||||
|
||||
waitsFor(function () {
|
||||
return check;
|
||||
});
|
||||
|
||||
runs(function () {
|
||||
expect(spy.calls.length).toEqual(2);
|
||||
});
|
||||
setTimeout(function () {
|
||||
expect(spy.callCount).to.eql(2);
|
||||
done();
|
||||
}, 30);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#splitWords', function () {
|
||||
it('splits words into an array', function () {
|
||||
expect(L.Util.splitWords('foo bar baz')).toEqual(['foo', 'bar', 'baz']);
|
||||
expect(L.Util.splitWords('foo bar baz')).to.eql(['foo', 'bar', 'baz']);
|
||||
});
|
||||
});
|
||||
|
||||
@ -192,17 +169,17 @@ describe('Util', function() {
|
||||
bar: 'Dave'
|
||||
});
|
||||
|
||||
expect(str).toEqual('Hello Vlad and Dave!');
|
||||
expect(str).to.eql('Hello Vlad and Dave!');
|
||||
});
|
||||
|
||||
it('does not modify text without a token variable', function () {
|
||||
expect(L.Util.template('foo', {})).toEqual('foo');
|
||||
expect(L.Util.template('foo', {})).to.eql('foo');
|
||||
});
|
||||
|
||||
it('throws when a template token is not given', function () {
|
||||
expect(function () {
|
||||
L.Util.template(tpl, {foo: 'bar'});
|
||||
}).toThrow();
|
||||
}).to.throwError();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -25,16 +25,16 @@ describe('DomEvent', function() {
|
||||
|
||||
describe('#addListener', function() {
|
||||
it('adds a listener and calls it on event', function() {
|
||||
var listener1 = jasmine.createSpy('listener1'),
|
||||
listener2 = jasmine.createSpy('listener2');
|
||||
var listener1 = sinon.spy(),
|
||||
listener2 = sinon.spy();
|
||||
|
||||
L.DomEvent.addListener(el, 'click', listener1);
|
||||
L.DomEvent.addListener(el, 'click', listener2);
|
||||
|
||||
simulateClick(el);
|
||||
|
||||
expect(listener1).toHaveBeenCalled();
|
||||
expect(listener2).toHaveBeenCalled();
|
||||
expect(listener1.called).to.be.ok();
|
||||
expect(listener2.called).to.be.ok();
|
||||
});
|
||||
|
||||
it('binds "this" to the given context', function() {
|
||||
@ -47,7 +47,7 @@ describe('DomEvent', function() {
|
||||
|
||||
simulateClick(el);
|
||||
|
||||
expect(result).toEqual(obj);
|
||||
expect(result).to.eql(obj);
|
||||
});
|
||||
|
||||
it('passes an event object to the listener', function() {
|
||||
@ -58,27 +58,27 @@ describe('DomEvent', function() {
|
||||
});
|
||||
simulateClick(el);
|
||||
|
||||
expect(type).toEqual('click');
|
||||
expect(type).to.eql('click');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#removeListener', function() {
|
||||
it('removes a previously added listener', function() {
|
||||
var listener = jasmine.createSpy('listener');
|
||||
var listener = sinon.spy();
|
||||
|
||||
L.DomEvent.addListener(el, 'click', listener);
|
||||
L.DomEvent.removeListener(el, 'click', listener);
|
||||
|
||||
simulateClick(el);
|
||||
|
||||
expect(listener).not.toHaveBeenCalled();
|
||||
expect(listener.called).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#stopPropagation', function() {
|
||||
it('stops propagation of the given event', function() {
|
||||
var child = document.createElement('div'),
|
||||
listener = jasmine.createSpy('listener');
|
||||
listener = sinon.spy();
|
||||
|
||||
el.appendChild(child);
|
||||
|
||||
@ -87,7 +87,7 @@ describe('DomEvent', function() {
|
||||
|
||||
simulateClick(child);
|
||||
|
||||
expect(listener).not.toHaveBeenCalled();
|
||||
expect(listener.called).to.not.be.ok();
|
||||
|
||||
el.removeChild(child);
|
||||
});
|
||||
@ -96,7 +96,7 @@ describe('DomEvent', function() {
|
||||
it('prevents the default action of event', function() {
|
||||
L.DomEvent.addListener(el, 'click', L.DomEvent.preventDefault);
|
||||
|
||||
expect(simulateClick(el)).toBe(false);
|
||||
expect(simulateClick(el)).to.be(false);
|
||||
});
|
||||
});
|
||||
});
|
@ -15,48 +15,48 @@ describe('DomUtil', function() {
|
||||
describe('#get', function() {
|
||||
it('gets element by id if the given argument is string', function() {
|
||||
el.id = 'testId';
|
||||
expect(L.DomUtil.get(el.id)).toBe(el);
|
||||
expect(L.DomUtil.get(el.id)).to.eql(el);
|
||||
});
|
||||
|
||||
it('returns the element if it is given as an argument', function() {
|
||||
expect(L.DomUtil.get(el)).toBe(el);
|
||||
expect(L.DomUtil.get(el)).to.eql(el);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#addClass, #removeClass, #hasClass', function() {
|
||||
it('has defined class for test element', function() {
|
||||
el.className = 'bar foo baz ';
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).toBeTruthy();
|
||||
expect(L.DomUtil.hasClass(el, 'bar')).toBeTruthy();
|
||||
expect(L.DomUtil.hasClass(el, 'baz')).toBeTruthy();
|
||||
expect(L.DomUtil.hasClass(el, 'boo')).toBeFalsy();
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
|
||||
expect(L.DomUtil.hasClass(el, 'bar')).to.be.ok();
|
||||
expect(L.DomUtil.hasClass(el, 'baz')).to.be.ok();
|
||||
expect(L.DomUtil.hasClass(el, 'boo')).to.not.be.ok();
|
||||
});
|
||||
|
||||
it('adds or removes the class', function() {
|
||||
el.className = '';
|
||||
L.DomUtil.addClass(el, 'foo');
|
||||
|
||||
expect(el.className).toEqual('foo');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).toBeTruthy();
|
||||
expect(el.className).to.eql('foo');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
|
||||
|
||||
L.DomUtil.addClass(el, 'bar');
|
||||
expect(el.className).toEqual('foo bar');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).toBeTruthy();
|
||||
expect(el.className).to.eql('foo bar');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.be.ok();
|
||||
|
||||
L.DomUtil.removeClass(el, 'foo');
|
||||
expect(el.className).toEqual('bar');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).toBeFalsy();
|
||||
expect(el.className).to.eql('bar');
|
||||
expect(L.DomUtil.hasClass(el, 'foo')).to.not.be.ok();
|
||||
|
||||
el.className = 'foo bar barz';
|
||||
L.DomUtil.removeClass(el, 'bar');
|
||||
expect(el.className).toEqual('foo barz');
|
||||
expect(el.className).to.eql('foo barz');
|
||||
});
|
||||
});
|
||||
|
||||
describe('#documentIsLtr', function () {
|
||||
it('returns true if doc direction is ltr', function () {
|
||||
expect(L.DomUtil.documentIsLtr()).toBe(true);
|
||||
expect(L.DomUtil.documentIsLtr()).toBe(true); // cached
|
||||
expect(L.DomUtil.documentIsLtr()).to.eql(true);
|
||||
expect(L.DomUtil.documentIsLtr()).to.eql(true); // cached
|
||||
});
|
||||
});
|
||||
|
||||
@ -77,13 +77,13 @@ describe('DomUtil', function() {
|
||||
|
||||
document.body.appendChild(div);
|
||||
|
||||
expect(L.DomUtil.getViewportOffset(div2)).toEqual(new L.Point(260, 260));
|
||||
expect(L.DomUtil.getViewportOffset(div2)).to.eql(new L.Point(260, 260));
|
||||
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#setPosition', noSpecs);
|
||||
// describe('#setPosition', noSpecs);
|
||||
|
||||
describe('#getStyle', noSpecs);
|
||||
// describe('#getStyle', noSpecs);
|
||||
});
|
||||
|
@ -14,27 +14,27 @@ describe('LatLngBounds', function() {
|
||||
new L.LatLng(14, 12),
|
||||
new L.LatLng(30, 40)
|
||||
]);
|
||||
expect(b).toEqual(a);
|
||||
expect(b.getNorthWest()).toEqual(new L.LatLng(30, 12));
|
||||
expect(b).to.eql(a);
|
||||
expect(b.getNorthWest()).to.eql(new L.LatLng(30, 12));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#extend', function () {
|
||||
it('extends the bounds by a given point', function () {
|
||||
a.extend(new L.LatLng(20, 50));
|
||||
expect(a.getNorthEast()).toEqual(new L.LatLng(30, 50));
|
||||
expect(a.getNorthEast()).to.eql(new L.LatLng(30, 50));
|
||||
});
|
||||
|
||||
it('extends the bounds by given bounds', function () {
|
||||
a.extend([[20, 50], [8, 40]]);
|
||||
|
||||
expect(a.getSouthEast()).toEqual(new L.LatLng(8, 50));
|
||||
expect(a.getSouthEast()).to.eql(new L.LatLng(8, 50));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getCenter', function () {
|
||||
it('returns the bounds center', function () {
|
||||
expect(a.getCenter()).toEqual(new L.LatLng(22, 26));
|
||||
expect(a.getCenter()).to.eql(new L.LatLng(22, 26));
|
||||
});
|
||||
});
|
||||
|
||||
@ -42,94 +42,94 @@ describe('LatLngBounds', function() {
|
||||
it('pads the bounds by a given ratio', function () {
|
||||
var b = a.pad(0.5);
|
||||
|
||||
expect(b).toEqual(L.latLngBounds([[6, -2], [38, 54]]));
|
||||
expect(b).to.eql(L.latLngBounds([[6, -2], [38, 54]]));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#equals', function () {
|
||||
it('returns true if bounds equal', function () {
|
||||
expect(a.equals([[14, 12], [30, 40]])).toBe(true);
|
||||
expect(a.equals([[14, 13], [30, 40]])).toBe(false);
|
||||
expect(a.equals(null)).toBe(false);
|
||||
expect(a.equals([[14, 12], [30, 40]])).to.eql(true);
|
||||
expect(a.equals([[14, 13], [30, 40]])).to.eql(false);
|
||||
expect(a.equals(null)).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isValid', function() {
|
||||
it('returns true if properly set up', function() {
|
||||
expect(a.isValid()).toBeTruthy();
|
||||
expect(a.isValid()).to.be.ok();
|
||||
});
|
||||
it('returns false if is invalid', function() {
|
||||
expect(c.isValid()).toBeFalsy();
|
||||
expect(c.isValid()).to.not.be.ok();
|
||||
});
|
||||
it('returns true if extended', function() {
|
||||
c.extend([0, 0]);
|
||||
expect(c.isValid()).toBeTruthy();
|
||||
expect(c.isValid()).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getWest', function () {
|
||||
it('returns a proper bbox west value', function() {
|
||||
expect(a.getWest()).toEqual(12);
|
||||
expect(a.getWest()).to.eql(12);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSouth', function () {
|
||||
it('returns a proper bbox south value', function() {
|
||||
expect(a.getSouth()).toEqual(14);
|
||||
expect(a.getSouth()).to.eql(14);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getEast', function () {
|
||||
it('returns a proper bbox east value', function() {
|
||||
expect(a.getEast()).toEqual(40);
|
||||
expect(a.getEast()).to.eql(40);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getNorth', function () {
|
||||
it('returns a proper bbox north value', function() {
|
||||
expect(a.getNorth()).toEqual(30);
|
||||
expect(a.getNorth()).to.eql(30);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#toBBoxString', function () {
|
||||
it('returns a proper left,bottom,right,top bbox', function() {
|
||||
expect(a.toBBoxString()).toEqual("12,14,40,30");
|
||||
expect(a.toBBoxString()).to.eql("12,14,40,30");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getNorthWest', function () {
|
||||
it('returns a proper north-west LatLng', function() {
|
||||
expect(a.getNorthWest()).toEqual(new L.LatLng(a.getNorth(), a.getWest()));
|
||||
expect(a.getNorthWest()).to.eql(new L.LatLng(a.getNorth(), a.getWest()));
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('#getSouthEast', function () {
|
||||
it('returns a proper south-east LatLng', function() {
|
||||
expect(a.getSouthEast()).toEqual(new L.LatLng(a.getSouth(), a.getEast()));
|
||||
expect(a.getSouthEast()).to.eql(new L.LatLng(a.getSouth(), a.getEast()));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#contains', function () {
|
||||
it('returns true if contains latlng point', function () {
|
||||
expect(a.contains([16, 20])).toBe(true);
|
||||
expect(L.latLngBounds(a).contains([5, 20])).toBe(false);
|
||||
expect(a.contains([16, 20])).to.eql(true);
|
||||
expect(L.latLngBounds(a).contains([5, 20])).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns true if contains bounds', function () {
|
||||
expect(a.contains([[16, 20], [20, 40]])).toBe(true);
|
||||
expect(a.contains([[16, 50], [8, 40]])).toBe(false);
|
||||
expect(a.contains([[16, 20], [20, 40]])).to.eql(true);
|
||||
expect(a.contains([[16, 50], [8, 40]])).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#intersects', function () {
|
||||
it('returns true if intersects the given bounds', function () {
|
||||
expect(a.intersects([[16, 20], [50, 60]])).toBe(true);
|
||||
expect(a.contains([[40, 50], [50, 60]])).toBe(false);
|
||||
expect(a.intersects([[16, 20], [50, 60]])).to.eql(true);
|
||||
expect(a.contains([[40, 50], [50, 60]])).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -2,18 +2,18 @@ describe('LatLng', function() {
|
||||
describe('constructor', function() {
|
||||
it("sets lat and lng", function() {
|
||||
var a = new L.LatLng(25, 74);
|
||||
expect(a.lat).toEqual(25);
|
||||
expect(a.lng).toEqual(74);
|
||||
expect(a.lat).to.eql(25);
|
||||
expect(a.lng).to.eql(74);
|
||||
|
||||
var b = new L.LatLng(-25, -74);
|
||||
expect(b.lat).toEqual(-25);
|
||||
expect(b.lng).toEqual(-74);
|
||||
expect(b.lat).to.eql(-25);
|
||||
expect(b.lng).to.eql(-74);
|
||||
});
|
||||
|
||||
it('throws an error if invalid lat or lng', function () {
|
||||
expect(function () {
|
||||
var a = new L.LatLng(NaN, NaN);
|
||||
}).toThrow();
|
||||
}).to.throwError();
|
||||
});
|
||||
});
|
||||
|
||||
@ -21,51 +21,51 @@ describe('LatLng', function() {
|
||||
it("returns true if compared objects are equal within a certain margin", function() {
|
||||
var a = new L.LatLng(10, 20);
|
||||
var b = new L.LatLng(10 + 1.0E-10, 20 - 1.0E-10);
|
||||
expect(a.equals(b)).toBe(true);
|
||||
expect(a.equals(b)).to.eql(true);
|
||||
});
|
||||
|
||||
it("returns false if compared objects are not equal within a certain margin", function() {
|
||||
var a = new L.LatLng(10, 20);
|
||||
var b = new L.LatLng(10, 23.3);
|
||||
expect(a.equals(b)).toBe(false);
|
||||
expect(a.equals(b)).to.eql(false);
|
||||
});
|
||||
|
||||
it('returns false if passed non-valid object', function () {
|
||||
var a = new L.LatLng(10, 20);
|
||||
expect(a.equals(null)).toBe(false);
|
||||
expect(a.equals(null)).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#wrap', function () {
|
||||
it("wraps longitude to lie between -180 and 180 by default", function() {
|
||||
var a = new L.LatLng(0, 190).wrap().lng;
|
||||
expect(a).toEqual(-170);
|
||||
expect(a).to.eql(-170);
|
||||
|
||||
var b = new L.LatLng(0, 360).wrap().lng;
|
||||
expect(b).toEqual(0);
|
||||
expect(b).to.eql(0);
|
||||
|
||||
var c = new L.LatLng(0, 380).wrap().lng;
|
||||
expect(c).toEqual(20);
|
||||
expect(c).to.eql(20);
|
||||
|
||||
var d = new L.LatLng(0, -190).wrap().lng;
|
||||
expect(d).toEqual(170);
|
||||
expect(d).to.eql(170);
|
||||
|
||||
var e = new L.LatLng(0, -360).wrap().lng;
|
||||
expect(e).toEqual(0);
|
||||
expect(e).to.eql(0);
|
||||
|
||||
var f = new L.LatLng(0, -380).wrap().lng;
|
||||
expect(f).toEqual(-20);
|
||||
expect(f).to.eql(-20);
|
||||
|
||||
var g = new L.LatLng(0, 90).wrap().lng;
|
||||
expect(g).toEqual(90);
|
||||
expect(g).to.eql(90);
|
||||
|
||||
var h = new L.LatLng(0, 180).wrap().lng;
|
||||
expect(h).toEqual(180);
|
||||
expect(h).to.eql(180);
|
||||
});
|
||||
|
||||
it("wraps longitude within the given range", function() {
|
||||
var a = new L.LatLng(0, 190).wrap(-100, 100).lng;
|
||||
expect(a).toEqual(-10);
|
||||
expect(a).to.eql(-10);
|
||||
});
|
||||
|
||||
});
|
||||
@ -73,7 +73,7 @@ describe('LatLng', function() {
|
||||
describe('#toString', function () {
|
||||
it('formats a string', function () {
|
||||
var a = new L.LatLng(10.333333333, 20.2222222);
|
||||
expect(a.toString(3)).toEqual('LatLng(10.333, 20.222)');
|
||||
expect(a.toString(3)).to.eql('LatLng(10.333, 20.222)');
|
||||
});
|
||||
});
|
||||
|
||||
@ -82,7 +82,7 @@ describe('LatLng', function() {
|
||||
var a = new L.LatLng(50.5, 30.5);
|
||||
var b = new L.LatLng(50, 1);
|
||||
|
||||
expect(Math.abs(Math.round(a.distanceTo(b) / 1000) - 2084) < 5).toBe(true);
|
||||
expect(Math.abs(Math.round(a.distanceTo(b) / 1000) - 2084) < 5).to.eql(true);
|
||||
});
|
||||
});
|
||||
|
||||
@ -90,28 +90,28 @@ describe('LatLng', function() {
|
||||
it('returns LatLng instance as is', function () {
|
||||
var a = new L.LatLng(50, 30);
|
||||
|
||||
expect(L.latLng(a)).toBe(a);
|
||||
expect(L.latLng(a)).to.eql(a);
|
||||
});
|
||||
|
||||
it('accepts an array of coordinates', function () {
|
||||
expect(L.latLng([50, 30])).toEqual(new L.LatLng(50, 30));
|
||||
expect(L.latLng([50, 30])).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('passes null or undefined as is', function () {
|
||||
expect(L.latLng(undefined)).toBe(undefined);
|
||||
expect(L.latLng(null)).toBe(null);
|
||||
expect(L.latLng(undefined)).to.eql(undefined);
|
||||
expect(L.latLng(null)).to.eql(null);
|
||||
});
|
||||
|
||||
it('creates a LatLng object from two coordinates', function () {
|
||||
expect(L.latLng(50, 30)).toEqual(new L.LatLng(50, 30));
|
||||
expect(L.latLng(50, 30)).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('accepts an object with lat/lng', function () {
|
||||
expect(L.latLng({lat: 50, lng: 30})).toEqual(new L.LatLng(50, 30));
|
||||
expect(L.latLng({lat: 50, lng: 30})).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
|
||||
it('accepts an object with lat/lon', function () {
|
||||
expect(L.latLng({lat: 50, lon: 30})).toEqual(new L.LatLng(50, 30));
|
||||
expect(L.latLng({lat: 50, lon: 30})).to.eql(new L.LatLng(50, 30));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -1,28 +1,22 @@
|
||||
xdescribe("Projection.Mercator", function() {
|
||||
describe("Projection.Mercator", function() {
|
||||
var p = L.Projection.Mercator;
|
||||
|
||||
beforeEach(function() {
|
||||
function almostEqual(a, b, p) {
|
||||
return Math.abs(a - b) <= (p || 1.0E-12);
|
||||
}
|
||||
this.addMatchers({
|
||||
toAlmostEqual: function(expected, margin) {
|
||||
var p1 = this.actual,
|
||||
p2 = expected;
|
||||
return almostEqual(p1.x, p2.x, margin) && almostEqual(p1.y, p2.y, margin);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
expect.Assertion.prototype.near = function(expected, delta) {
|
||||
delta = 0 || 1.0;
|
||||
expect(this.obj.x).to
|
||||
.be.within(expected.x - delta, expected.y + delta);
|
||||
expect(this.obj.y).to
|
||||
.be.within(expected.y - delta, expected.x + delta);
|
||||
};
|
||||
|
||||
describe("#project", function() {
|
||||
it("projects", function() {
|
||||
//edge cases
|
||||
expect(p.project(new L.LatLng(0, 0))).toAlmostEqual(new L.Point(0, 0));
|
||||
expect(p.project(new L.LatLng(90, 180))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
|
||||
expect(p.project(new L.LatLng(-90, -180))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
|
||||
expect(p.project(new L.LatLng(0, 0))).near(new L.Point(0, 0));
|
||||
expect(p.project(new L.LatLng(90, 180))).near(new L.Point(-Math.PI, Math.PI));
|
||||
expect(p.project(new L.LatLng(-90, -180))).near(new L.Point(-Math.PI, -Math.PI));
|
||||
|
||||
expect(p.project(new L.LatLng(50, 30))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
|
||||
expect(p.project(new L.LatLng(50, 30))).near(new L.Point(0.523598775598, 1.010683188683));
|
||||
});
|
||||
});
|
||||
|
||||
@ -32,11 +26,11 @@ xdescribe("Projection.Mercator", function() {
|
||||
return p.project(p.unproject(point));
|
||||
}
|
||||
|
||||
expect(pr(new L.Point(0, 0))).toAlmostEqual(new L.Point(0, 0));
|
||||
expect(pr(new L.Point(-Math.PI, Math.PI))).toAlmostEqual(new L.Point(-Math.PI, Math.PI));
|
||||
expect(pr(new L.Point(-Math.PI, -Math.PI))).toAlmostEqual(new L.Point(-Math.PI, -Math.PI));
|
||||
expect(pr(new L.Point(0, 0))).near(new L.Point(0, 0));
|
||||
expect(pr(new L.Point(-Math.PI, Math.PI))).near(new L.Point(-Math.PI, Math.PI));
|
||||
expect(pr(new L.Point(-Math.PI, -Math.PI))).near(new L.Point(-Math.PI, -Math.PI));
|
||||
|
||||
expect(pr(new L.Point(0.523598775598, 1.010683188683))).toAlmostEqual(new L.Point(0.523598775598, 1.010683188683));
|
||||
expect(pr(new L.Point(0.523598775598, 1.010683188683))).near(new L.Point(0.523598775598, 1.010683188683));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -15,73 +15,73 @@ describe('Bounds', function() {
|
||||
|
||||
describe('constructor', function() {
|
||||
it('creates bounds with proper min & max on (Point, Point)', function() {
|
||||
expect(a.min).toEqual(new L.Point(14, 12));
|
||||
expect(a.max).toEqual(new L.Point(30, 40));
|
||||
expect(a.min).to.eql(new L.Point(14, 12));
|
||||
expect(a.max).to.eql(new L.Point(30, 40));
|
||||
});
|
||||
it('creates bounds with proper min & max on (Point[])', function() {
|
||||
expect(b.min).toEqual(new L.Point(14, 12));
|
||||
expect(b.max).toEqual(new L.Point(30, 40));
|
||||
expect(b.min).to.eql(new L.Point(14, 12));
|
||||
expect(b.max).to.eql(new L.Point(30, 40));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#extend', function() {
|
||||
it('extends the bounds to contain the given point', function() {
|
||||
a.extend(new L.Point(50, 20));
|
||||
expect(a.min).toEqual(new L.Point(14, 12));
|
||||
expect(a.max).toEqual(new L.Point(50, 40));
|
||||
expect(a.min).to.eql(new L.Point(14, 12));
|
||||
expect(a.max).to.eql(new L.Point(50, 40));
|
||||
|
||||
b.extend(new L.Point(25, 50));
|
||||
expect(b.min).toEqual(new L.Point(14, 12));
|
||||
expect(b.max).toEqual(new L.Point(30, 50));
|
||||
expect(b.min).to.eql(new L.Point(14, 12));
|
||||
expect(b.max).to.eql(new L.Point(30, 50));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getCenter', function() {
|
||||
it('returns the center point', function() {
|
||||
expect(a.getCenter()).toEqual(new L.Point(22, 26));
|
||||
expect(a.getCenter()).to.eql(new L.Point(22, 26));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#contains', function() {
|
||||
it('contains other bounds or point', function() {
|
||||
a.extend(new L.Point(50, 10));
|
||||
expect(a.contains(b)).toBeTruthy();
|
||||
expect(b.contains(a)).toBeFalsy();
|
||||
expect(a.contains(new L.Point(24, 25))).toBeTruthy();
|
||||
expect(a.contains(new L.Point(54, 65))).toBeFalsy();
|
||||
expect(a.contains(b)).to.be.ok();
|
||||
expect(b.contains(a)).to.not.be.ok();
|
||||
expect(a.contains(new L.Point(24, 25))).to.be.ok();
|
||||
expect(a.contains(new L.Point(54, 65))).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isValid', function() {
|
||||
it('returns true if properly set up', function() {
|
||||
expect(a.isValid()).toBeTruthy();
|
||||
expect(a.isValid()).to.be.ok();
|
||||
});
|
||||
it('returns false if is invalid', function() {
|
||||
expect(c.isValid()).toBeFalsy();
|
||||
expect(c.isValid()).to.not.be.ok();
|
||||
});
|
||||
it('returns true if extended', function() {
|
||||
c.extend([0, 0]);
|
||||
expect(c.isValid()).toBeTruthy();
|
||||
expect(c.isValid()).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe('#getSize', function () {
|
||||
it('returns the size of the bounds as point', function () {
|
||||
expect(a.getSize()).toEqual(new L.Point(16, 28));
|
||||
expect(a.getSize()).to.eql(new L.Point(16, 28));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#intersects', function () {
|
||||
it('returns true if bounds intersect', function () {
|
||||
expect(a.intersects(b)).toBe(true);
|
||||
expect(a.intersects(new L.Bounds(new L.Point(100, 100), new L.Point(120, 120)))).toEqual(false);
|
||||
expect(a.intersects(b)).to.be(true);
|
||||
expect(a.intersects(new L.Bounds(new L.Point(100, 100), new L.Point(120, 120)))).to.eql(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('L.bounds factory', function () {
|
||||
it('creates bounds from array of number arrays', function () {
|
||||
var bounds = L.bounds([[14, 12], [30, 40]]);
|
||||
expect(bounds).toEqual(a);
|
||||
expect(bounds).to.eql(a);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -14,16 +14,16 @@ describe('LineUtil', function () {
|
||||
|
||||
var segment = L.LineUtil.clipSegment(a, b, bounds);
|
||||
|
||||
expect(segment[0]).toEqual(new L.Point(5, 5));
|
||||
expect(segment[1]).toEqual(new L.Point(10, 10));
|
||||
expect(segment[0]).to.eql(new L.Point(5, 5));
|
||||
expect(segment[1]).to.eql(new L.Point(10, 10));
|
||||
|
||||
var c = new L.Point(5, -5);
|
||||
var d = new L.Point(20, 10);
|
||||
|
||||
var segment2 = L.LineUtil.clipSegment(c, d, bounds);
|
||||
|
||||
expect(segment2[0]).toEqual(new L.Point(10, 0));
|
||||
expect(segment2[1]).toEqual(new L.Point(15, 5));
|
||||
expect(segment2[0]).to.eql(new L.Point(10, 0));
|
||||
expect(segment2[1]).to.eql(new L.Point(15, 5));
|
||||
});
|
||||
|
||||
it('uses last bit code and reject segments out of bounds', function () {
|
||||
@ -31,7 +31,7 @@ describe('LineUtil', function () {
|
||||
var b = new L.Point(25, 20);
|
||||
var segment = L.LineUtil.clipSegment(a, b, bounds, true);
|
||||
|
||||
expect(segment).toBe(false);
|
||||
expect(segment).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
@ -42,11 +42,11 @@ describe('LineUtil', function () {
|
||||
var p = new L.Point(0, 0);
|
||||
|
||||
it('calculates distance from point to segment', function () {
|
||||
expect(L.LineUtil.pointToSegmentDistance(p, p1, p2)).toEqual(Math.sqrt(200) / 2);
|
||||
expect(L.LineUtil.pointToSegmentDistance(p, p1, p2)).to.eql(Math.sqrt(200) / 2);
|
||||
});
|
||||
|
||||
it('calculates point closest to segment', function () {
|
||||
expect(L.LineUtil.closestPointOnSegment(p, p1, p2)).toEqual(new L.Point(5, 5));
|
||||
expect(L.LineUtil.closestPointOnSegment(p, p1, p2)).to.eql(new L.Point(5, 5));
|
||||
});
|
||||
});
|
||||
|
||||
@ -64,7 +64,7 @@ describe('LineUtil', function () {
|
||||
|
||||
var simplified = L.LineUtil.simplify(points, 0.1);
|
||||
|
||||
expect(simplified).toEqual([
|
||||
expect(simplified).to.eql([
|
||||
new L.Point(0, 0),
|
||||
new L.Point(1, 0),
|
||||
new L.Point(2, 1)
|
||||
|
@ -4,14 +4,14 @@ describe("Point", function() {
|
||||
|
||||
it("creates a point with the given x and y", function() {
|
||||
var p = new L.Point(1.5, 2.5);
|
||||
expect(p.x).toEqual(1.5);
|
||||
expect(p.y).toEqual(2.5);
|
||||
expect(p.x).to.eql(1.5);
|
||||
expect(p.y).to.eql(2.5);
|
||||
});
|
||||
|
||||
it("rounds the given x and y if the third argument is true", function() {
|
||||
var p = new L.Point(1.3, 2.7, true);
|
||||
expect(p.x).toEqual(1);
|
||||
expect(p.y).toEqual(3);
|
||||
expect(p.x).to.eql(1);
|
||||
expect(p.y).to.eql(3);
|
||||
});
|
||||
});
|
||||
|
||||
@ -19,31 +19,31 @@ describe("Point", function() {
|
||||
it('subtracts the given point from this one', function() {
|
||||
var a = new L.Point(50, 30),
|
||||
b = new L.Point(20, 10);
|
||||
expect(a.subtract(b)).toEqual(new L.Point(30, 20));
|
||||
expect(a.subtract(b)).to.eql(new L.Point(30, 20));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#add', function() {
|
||||
it('adds given point to this one', function() {
|
||||
expect(new L.Point(50, 30).add(new L.Point(20, 10))).toEqual(new L.Point(70, 40));
|
||||
expect(new L.Point(50, 30).add(new L.Point(20, 10))).to.eql(new L.Point(70, 40));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#divideBy', function() {
|
||||
it('divides this point by the given amount', function() {
|
||||
expect(new L.Point(50, 30).divideBy(5)).toEqual(new L.Point(10, 6));
|
||||
expect(new L.Point(50, 30).divideBy(5)).to.eql(new L.Point(10, 6));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#multiplyBy', function() {
|
||||
it('multiplies this point by the given amount', function() {
|
||||
expect(new L.Point(50, 30).multiplyBy(2)).toEqual(new L.Point(100, 60));
|
||||
expect(new L.Point(50, 30).multiplyBy(2)).to.eql(new L.Point(100, 60));
|
||||
});
|
||||
});
|
||||
|
||||
describe('#floor', function () {
|
||||
it('returns a new point with floored coordinates', function () {
|
||||
expect(new L.Point(50.56, 30.123).floor()).toEqual(new L.Point(50, 30));
|
||||
expect(new L.Point(50.56, 30.123).floor()).to.eql(new L.Point(50, 30));
|
||||
});
|
||||
});
|
||||
|
||||
@ -51,7 +51,7 @@ describe("Point", function() {
|
||||
it('calculates distance between two points', function () {
|
||||
var p1 = new L.Point(0, 30);
|
||||
var p2 = new L.Point(40, 0);
|
||||
expect(p1.distanceTo(p2)).toEqual(50.0);
|
||||
expect(p1.distanceTo(p2)).to.eql(50.0);
|
||||
});
|
||||
});
|
||||
|
||||
@ -61,8 +61,8 @@ describe("Point", function() {
|
||||
var p2 = new L.Point(20.4, 50.12);
|
||||
var p3 = new L.Point(20.5, 50.13);
|
||||
|
||||
expect(p1.equals(p2)).toBe(true);
|
||||
expect(p1.equals(p3)).toBe(false);
|
||||
expect(p1.equals(p2)).to.be(true);
|
||||
expect(p1.equals(p3)).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
@ -73,32 +73,32 @@ describe("Point", function() {
|
||||
p3 = new L.Point(60, -20),
|
||||
p4 = new L.Point(-40, -40);
|
||||
|
||||
expect(p1.contains(p2)).toBe(true);
|
||||
expect(p1.contains(p3)).toBe(false);
|
||||
expect(p1.contains(p4)).toBe(false);
|
||||
expect(p1.contains(p2)).to.be(true);
|
||||
expect(p1.contains(p3)).to.be(false);
|
||||
expect(p1.contains(p4)).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#toString', function () {
|
||||
it('formats a string out of point coordinates', function () {
|
||||
expect(new L.Point(50, 30) + '').toEqual('Point(50, 30)');
|
||||
expect(new L.Point(50, 30) + '').to.eql('Point(50, 30)');
|
||||
});
|
||||
});
|
||||
|
||||
describe('L.point factory', function () {
|
||||
it('leaves L.Point instances as is', function () {
|
||||
var p = new L.Point(50, 30);
|
||||
expect(L.point(p)).toBe(p);
|
||||
expect(L.point(p)).to.be(p);
|
||||
});
|
||||
it('creates a point out of three arguments', function () {
|
||||
expect(L.point(50.1, 30.1, true)).toEqual(new L.Point(50, 30));
|
||||
expect(L.point(50.1, 30.1, true)).to.eql(new L.Point(50, 30));
|
||||
});
|
||||
it('creates a point from an array of coordinates', function () {
|
||||
expect(L.point([50, 30])).toEqual(new L.Point(50, 30));
|
||||
expect(L.point([50, 30])).to.eql(new L.Point(50, 30));
|
||||
});
|
||||
it('does not fail on invalid arguments', function () {
|
||||
expect(L.point(undefined)).toBe(undefined);
|
||||
expect(L.point(null)).toBe(null);
|
||||
expect(L.point(undefined)).to.be(undefined);
|
||||
expect(L.point(null)).to.be(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -16,7 +16,7 @@ describe('PolyUtil', function () {
|
||||
delete clipped[i]._code;
|
||||
}
|
||||
|
||||
expect(clipped).toEqual([
|
||||
expect(clipped).to.eql([
|
||||
new L.Point(7.5, 10),
|
||||
new L.Point(5, 5),
|
||||
new L.Point(10, 7.5),
|
||||
|
@ -9,11 +9,11 @@ describe("Transformation", function() {
|
||||
describe('#transform', function () {
|
||||
it("performs a transformation", function() {
|
||||
var p2 = t.transform(p, 2);
|
||||
expect(p2).toEqual(new L.Point(24, 128));
|
||||
expect(p2).to.eql(new L.Point(24, 128));
|
||||
});
|
||||
it('assumes a scale of 1 if not specified', function () {
|
||||
var p2 = t.transform(p);
|
||||
expect(p2).toEqual(new L.Point(12, 64));
|
||||
expect(p2).to.eql(new L.Point(12, 64));
|
||||
});
|
||||
});
|
||||
|
||||
@ -21,11 +21,11 @@ describe("Transformation", function() {
|
||||
it("performs a reverse transformation", function() {
|
||||
var p2 = t.transform(p, 2);
|
||||
var p3 = t.untransform(p2, 2);
|
||||
expect(p3).toEqual(p);
|
||||
expect(p3).to.eql(p);
|
||||
});
|
||||
it('assumes a scale of 1 if not specified', function () {
|
||||
var p2 = t.transform(p);
|
||||
expect(t.untransform(new L.Point(12, 64))).toEqual(new L.Point(10, 20));
|
||||
expect(t.untransform(new L.Point(12, 64))).to.eql(new L.Point(10, 20));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -16,20 +16,20 @@
|
||||
|
||||
var wasClicked = 0;
|
||||
fg2.on('click', function(e) {
|
||||
expect(e.layer).toBe(marker);
|
||||
expect(e.target).toBe(fg2);
|
||||
expect(e.layer).to.be(marker);
|
||||
expect(e.target).to.be(fg2);
|
||||
wasClicked |= 1;
|
||||
});
|
||||
|
||||
fg1.on('click', function (e) {
|
||||
expect(e.layer).toBe(marker);
|
||||
expect(e.target).toBe(fg1);
|
||||
expect(e.layer).to.be(marker);
|
||||
expect(e.target).to.be(fg1);
|
||||
wasClicked |= 2;
|
||||
});
|
||||
|
||||
marker.fire('click', { type: 'click' });
|
||||
|
||||
expect(wasClicked).toBe(3);
|
||||
expect(wasClicked).to.be(3);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -4,9 +4,9 @@
|
||||
var lg = L.layerGroup(),
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
expect(lg.addLayer(marker)).toEqual(lg);
|
||||
expect(lg.addLayer(marker)).to.eql(lg);
|
||||
|
||||
expect(lg.hasLayer(marker)).toBe(true);
|
||||
expect(lg.hasLayer(marker)).to.be(true);
|
||||
});
|
||||
});
|
||||
describe("#removeLayer", function () {
|
||||
@ -15,9 +15,9 @@
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
lg.addLayer(marker);
|
||||
expect(lg.removeLayer(marker)).toEqual(lg);
|
||||
expect(lg.removeLayer(marker)).to.eql(lg);
|
||||
|
||||
expect(lg.hasLayer(marker)).toBe(false);
|
||||
expect(lg.hasLayer(marker)).to.be(false);
|
||||
});
|
||||
});
|
||||
describe("#clearLayers", function () {
|
||||
@ -26,9 +26,9 @@
|
||||
marker = L.marker([0, 0]);
|
||||
|
||||
lg.addLayer(marker);
|
||||
expect(lg.clearLayers()).toEqual(lg);
|
||||
expect(lg.clearLayers()).to.eql(lg);
|
||||
|
||||
expect(lg.hasLayer(marker)).toBe(false);
|
||||
expect(lg.hasLayer(marker)).to.be(false);
|
||||
});
|
||||
});
|
||||
describe("#getLayers", function () {
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
lg.addLayer(marker);
|
||||
|
||||
expect(lg.getLayers()).toEqual([marker]);
|
||||
expect(lg.getLayers()).to.eql([marker]);
|
||||
});
|
||||
});
|
||||
describe("#eachLayer", function () {
|
||||
@ -50,8 +50,8 @@
|
||||
lg.addLayer(marker);
|
||||
|
||||
lg.eachLayer(function(layer) {
|
||||
expect(layer).toEqual(marker);
|
||||
expect(this).toEqual(ctx);
|
||||
expect(layer).to.eql(marker);
|
||||
expect(this).to.eql(ctx);
|
||||
}, ctx);
|
||||
});
|
||||
});
|
||||
|
@ -17,8 +17,8 @@ describe('TileLayer', function () {
|
||||
maxZoom: maxZoom,
|
||||
minZoom: minZoom
|
||||
}).addTo(map);
|
||||
expect(map.getMaxZoom()).toBe(maxZoom);
|
||||
expect(map.getMinZoom()).toBe(minZoom);
|
||||
expect(map.getMaxZoom()).to.be(maxZoom);
|
||||
expect(map.getMinZoom()).to.be(minZoom);
|
||||
});
|
||||
});
|
||||
|
||||
@ -27,7 +27,7 @@ describe('TileLayer', function () {
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
var layer = L.tileLayer(tileUrl).addTo(map);
|
||||
expect(layer.getContainer()).toBeTruthy();
|
||||
expect(layer.getContainer()).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
@ -36,22 +36,22 @@ describe('TileLayer', function () {
|
||||
map.setView([0, 0], 1);
|
||||
|
||||
L.tileLayer(tileUrl, { minZoom:10, maxZoom: 15 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(10);
|
||||
expect(map.getMaxZoom()).toBe(15);
|
||||
expect(map.getMinZoom()).to.be(10);
|
||||
expect(map.getMaxZoom()).to.be(15);
|
||||
|
||||
L.tileLayer(tileUrl, { minZoom:5, maxZoom: 10 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(5); // changed
|
||||
expect(map.getMaxZoom()).toBe(15); // unchanged
|
||||
expect(map.getMinZoom()).to.be(5); // changed
|
||||
expect(map.getMaxZoom()).to.be(15); // unchanged
|
||||
|
||||
|
||||
L.tileLayer(tileUrl,{ minZoom:10, maxZoom: 20 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(5); // unchanged
|
||||
expect(map.getMaxZoom()).toBe(20); // changed
|
||||
expect(map.getMinZoom()).to.be(5); // unchanged
|
||||
expect(map.getMaxZoom()).to.be(20); // changed
|
||||
|
||||
|
||||
L.tileLayer(tileUrl, { minZoom:0, maxZoom: 25 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(0); // changed
|
||||
expect(map.getMaxZoom()).toBe(25); // changed
|
||||
expect(map.getMinZoom()).to.be(0); // changed
|
||||
expect(map.getMaxZoom()).to.be(25); // changed
|
||||
});
|
||||
});
|
||||
describe("when a tilelayer is removed from a map", function () {
|
||||
@ -62,24 +62,24 @@ describe('TileLayer', function () {
|
||||
L.tileLayer(tileUrl, { minZoom:0, maxZoom: 25 }).addTo(map)
|
||||
];
|
||||
map.whenReady(function() {
|
||||
expect(map.getMinZoom()).toBe(0);
|
||||
expect(map.getMaxZoom()).toBe(25);
|
||||
expect(map.getMinZoom()).to.be(0);
|
||||
expect(map.getMaxZoom()).to.be(25);
|
||||
|
||||
map.removeLayer(tiles[0]);
|
||||
expect(map.getMinZoom()).toBe(0);
|
||||
expect(map.getMaxZoom()).toBe(25);
|
||||
expect(map.getMinZoom()).to.be(0);
|
||||
expect(map.getMaxZoom()).to.be(25);
|
||||
|
||||
map.removeLayer(tiles[3]);
|
||||
expect(map.getMinZoom()).toBe(5);
|
||||
expect(map.getMaxZoom()).toBe(20);
|
||||
expect(map.getMinZoom()).to.be(5);
|
||||
expect(map.getMaxZoom()).to.be(20);
|
||||
|
||||
map.removeLayer(tiles[2]);
|
||||
expect(map.getMinZoom()).toBe(5);
|
||||
expect(map.getMaxZoom()).toBe(10);
|
||||
expect(map.getMinZoom()).to.be(5);
|
||||
expect(map.getMaxZoom()).to.be(10);
|
||||
|
||||
map.removeLayer(tiles[1]);
|
||||
expect(map.getMinZoom()).toBe(0);
|
||||
expect(map.getMaxZoom()).toBe(Infinity);
|
||||
expect(map.getMinZoom()).to.be(0);
|
||||
expect(map.getMaxZoom()).to.be(Infinity);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -10,7 +10,7 @@
|
||||
it("takes that radius", function() {
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 }).addTo(map);
|
||||
|
||||
expect(marker._radius).toBe(20);
|
||||
expect(marker._radius).to.be(20);
|
||||
});
|
||||
});
|
||||
|
||||
@ -19,7 +19,7 @@
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.setRadius(15);
|
||||
marker.addTo(map);
|
||||
expect(marker._radius).toBe(15);
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.addTo(map);
|
||||
marker.setRadius(15);
|
||||
expect(marker._radius).toBe(15);
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.addTo(map);
|
||||
marker.setStyle({ radius: 15 });
|
||||
expect(marker._radius).toBe(15);
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
describe("and setStyle is used to change the radius before adding", function () {
|
||||
@ -45,7 +45,7 @@
|
||||
var marker = L.circleMarker([0, 0], { radius: 20 });
|
||||
marker.setStyle({ radius: 15 });
|
||||
marker.addTo(map);
|
||||
expect(marker._radius).toBe(15);
|
||||
expect(marker._radius).to.be(15);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -10,8 +10,8 @@ describe('Circle', function () {
|
||||
it('returns bounds', function () {
|
||||
var bounds = circle.getBounds();
|
||||
|
||||
expect(bounds.getSouthWest().equals([49.998203369, 29.997204939])).toBeTruthy();
|
||||
expect(bounds.getNorthEast().equals([50.001796631, 30.002795061])).toBeTruthy();
|
||||
expect(bounds.getSouthWest().equals([49.998203369, 29.997204939])).to.be.ok();
|
||||
expect(bounds.getNorthEast().equals([50.001796631, 30.002795061])).to.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -16,8 +16,8 @@ describe('Polygon', function() {
|
||||
|
||||
var polygon = new L.Polygon(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
expect(polygon._latlngs).toNotEqual(sourceLatLngs);
|
||||
expect(sourceLatLngs).to.eql(originalLatLngs);
|
||||
expect(polygon._latlngs).to.not.eql(sourceLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
@ -33,7 +33,7 @@ describe('Polygon', function() {
|
||||
|
||||
polygon.setLatLngs(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
expect(sourceLatLngs).to.eql(originalLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
@ -49,7 +49,7 @@ describe('Polygon', function() {
|
||||
|
||||
polygon.spliceLatLngs(1, 1, [7, 8]);
|
||||
|
||||
expect(polygon._latlngs).toEqual([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
||||
expect(polygon._latlngs).to.eql([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -19,17 +19,17 @@ describe('PolylineGeometry', function() {
|
||||
});
|
||||
map.addLayer(polyline);
|
||||
|
||||
expect(polyline.closestLayerPoint(p1)).toEqual(null);
|
||||
expect(polyline.closestLayerPoint(p1)).to.be(null);
|
||||
|
||||
polyline.setLatLngs(latlngs);
|
||||
var point = polyline.closestLayerPoint(p1);
|
||||
expect(point).not.toEqual(null);
|
||||
expect(point.distance).not.toEqual(Infinity);
|
||||
expect(point.distance).not.toEqual(NaN);
|
||||
expect(point).not.to.be(null);
|
||||
expect(point.distance).to.not.be(Infinity);
|
||||
expect(point.distance).to.not.be(NaN);
|
||||
|
||||
var point2 = polyline.closestLayerPoint(p2);
|
||||
|
||||
expect(point.distance).toBeLessThan(point2.distance);
|
||||
expect(point.distance).to.be.lessThan(point2.distance);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -16,8 +16,8 @@ describe('Polyline', function() {
|
||||
|
||||
var polyline = new L.Polyline(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
expect(polyline._latlngs).toNotEqual(sourceLatLngs);
|
||||
expect(sourceLatLngs).to.eql(originalLatLngs);
|
||||
expect(polyline._latlngs).to.not.eql(sourceLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
@ -33,7 +33,7 @@ describe('Polyline', function() {
|
||||
|
||||
polyline.setLatLngs(sourceLatLngs);
|
||||
|
||||
expect(sourceLatLngs).toEqual(originalLatLngs);
|
||||
expect(sourceLatLngs).to.eql(originalLatLngs);
|
||||
});
|
||||
});
|
||||
|
||||
@ -49,7 +49,7 @@ describe('Polyline', function() {
|
||||
|
||||
polyline.spliceLatLngs(1, 1, [7, 8]);
|
||||
|
||||
expect(polyline._latlngs).toEqual([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
||||
expect(polyline._latlngs).to.eql([L.latLng([1, 2]), L.latLng([7, 8]), L.latLng([5, 6])]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -3,36 +3,38 @@ describe("Map", function () {
|
||||
spy;
|
||||
beforeEach(function () {
|
||||
map = L.map(document.createElement('div'));
|
||||
spy = jasmine.createSpy();
|
||||
});
|
||||
|
||||
describe("#remove", function () {
|
||||
it("fires an unload event if loaded", function () {
|
||||
var container = document.createElement('div'),
|
||||
map = new L.Map(container).setView([0, 0], 0);
|
||||
map = new L.Map(container).setView([0, 0], 0),
|
||||
spy = sinon.spy();
|
||||
map.on('unload', spy);
|
||||
map.remove();
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
|
||||
it("fires no unload event if not loaded", function () {
|
||||
var container = document.createElement('div'),
|
||||
map = new L.Map(container);
|
||||
map = new L.Map(container),
|
||||
spy = sinon.spy();
|
||||
map.on('unload', spy);
|
||||
map.remove();
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).not.to.be.ok();
|
||||
});
|
||||
|
||||
it("undefines container._leaflet", function () {
|
||||
var container = document.createElement('div'),
|
||||
map = new L.Map(container);
|
||||
map.remove();
|
||||
expect(container._leaflet).toBeUndefined();
|
||||
expect(container._leaflet).to.be(undefined);
|
||||
});
|
||||
|
||||
it("unbinds events", function () {
|
||||
var container = document.createElement('div'),
|
||||
map = new L.Map(container).setView([0, 0], 1);
|
||||
map = new L.Map(container).setView([0, 0], 1),
|
||||
spy = sinon.spy();
|
||||
map.on('click dblclick mousedown mouseup mousemove', spy);
|
||||
map.remove();
|
||||
happen.click(container);
|
||||
@ -40,7 +42,7 @@ describe("Map", function () {
|
||||
happen.mousedown(container);
|
||||
happen.mouseup(container);
|
||||
happen.mousemove(container);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).to.not.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
@ -48,36 +50,38 @@ describe("Map", function () {
|
||||
it ('throws if not set before', function () {
|
||||
expect(function () {
|
||||
map.getCenter();
|
||||
}).toThrow();
|
||||
}).to.throwError();
|
||||
});
|
||||
});
|
||||
|
||||
describe("#whenReady", function () {
|
||||
describe("when the map has not yet been loaded", function () {
|
||||
it("calls the callback when the map is loaded", function () {
|
||||
var spy = sinon.spy();
|
||||
map.whenReady(spy);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).to.not.be.ok();
|
||||
|
||||
map.setView([0, 0], 1);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the map has already been loaded", function () {
|
||||
it("calls the callback immediately", function () {
|
||||
var spy = sinon.spy();
|
||||
map.setView([0, 0], 1);
|
||||
map.whenReady(spy);
|
||||
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("#setView", function () {
|
||||
it("sets the view of the map", function () {
|
||||
expect(map.setView([51.505, -0.09], 13)).toBe(map);
|
||||
expect(map.getZoom()).toBe(13);
|
||||
expect(map.getCenter().distanceTo([51.505, -0.09])).toBeLessThan(5);
|
||||
expect(map.setView([51.505, -0.09], 13)).to.be(map);
|
||||
expect(map.getZoom()).to.be(13);
|
||||
expect(map.getCenter().distanceTo([51.505, -0.09])).to.be.lessThan(5);
|
||||
});
|
||||
});
|
||||
|
||||
@ -97,40 +101,43 @@ describe("Map", function () {
|
||||
map = L.map(c, { minZoom: 5, maxZoom: 10 });
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:5, maxZoom: 15 }).addTo(map);
|
||||
expect(map.getMinZoom()).toBe(5);
|
||||
expect(map.getMaxZoom()).toBe(10);
|
||||
expect(map.getMinZoom()).to.be(5);
|
||||
expect(map.getMaxZoom()).to.be(10);
|
||||
});
|
||||
});
|
||||
|
||||
describe("#addLayer", function () {
|
||||
describe("When the first layer is added to a map", function () {
|
||||
it("fires a zoomlevelschange event", function () {
|
||||
var spy = sinon.spy();
|
||||
map.on("zoomlevelschange", spy);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).not.to.be.ok();
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a new layer with greater zoomlevel coverage than the current layer is added to a map", function () {
|
||||
it("fires a zoomlevelschange event", function () {
|
||||
var spy = sinon.spy();
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
||||
map.on("zoomlevelschange", spy);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).not.to.be.ok();
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 15 }).addTo(map);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
|
||||
describe("when a new layer with the same or lower zoomlevel coverage as the current layer is added to a map", function () {
|
||||
it("fires no zoomlevelschange event", function () {
|
||||
var spy = sinon.spy();
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
||||
map.on("zoomlevelschange", spy);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).not.to.be.ok();
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).not.to.be.ok();
|
||||
L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 5 }).addTo(map);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).not.to.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -139,12 +146,13 @@ describe("Map", function () {
|
||||
describe("when the last tile layer on a map is removed", function () {
|
||||
it("fires a zoomlevelschange event", function () {
|
||||
map.whenReady(function(){
|
||||
var spy = sinon.spy();
|
||||
var tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map);
|
||||
|
||||
map.on("zoomlevelschange", spy);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).not.to.be.ok();
|
||||
map.removeLayer(tl);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -152,13 +160,14 @@ describe("Map", function () {
|
||||
describe("when a tile layer is removed from a map and it had greater zoom level coverage than the remainding layer", function () {
|
||||
it("fires a zoomlevelschange event", function () {
|
||||
map.whenReady(function(){
|
||||
var tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
|
||||
var spy = sinon.spy(),
|
||||
tl = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 10 }).addTo(map),
|
||||
t2 = L.tileLayer("{z}{x}{y}", { minZoom:0, maxZoom: 15 }).addTo(map);
|
||||
|
||||
map.on("zoomlevelschange", spy);
|
||||
expect(spy).not.toHaveBeenCalled();
|
||||
expect(spy.called).to.not.be.ok();
|
||||
map.removeLayer(t2);
|
||||
expect(spy).toHaveBeenCalled();
|
||||
expect(spy.called).to.be.ok();
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -183,26 +192,28 @@ describe("Map", function () {
|
||||
|
||||
describe("#eachLayer", function () {
|
||||
it("returns self", function () {
|
||||
expect(map.eachLayer(function () {})).toBe(map);
|
||||
expect(map.eachLayer(function () {})).to.be(map);
|
||||
});
|
||||
|
||||
it("calls the provided function for each layer", function () {
|
||||
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
||||
t2 = L.tileLayer("{z}{x}{y}").addTo(map);
|
||||
t2 = L.tileLayer("{z}{x}{y}").addTo(map),
|
||||
spy = sinon.spy();
|
||||
|
||||
map.eachLayer(spy);
|
||||
|
||||
expect(spy.calls.length).toEqual(2);
|
||||
expect(spy.calls[0].args).toEqual([t1]);
|
||||
expect(spy.calls[1].args).toEqual([t2]);
|
||||
expect(spy.callCount).to.eql(2);
|
||||
expect(spy.firstCall.args).to.eql([t1]);
|
||||
expect(spy.secondCall.args).to.eql([t2]);
|
||||
});
|
||||
|
||||
it("calls the provided function with the provided context", function () {
|
||||
var t1 = L.tileLayer("{z}{x}{y}").addTo(map);
|
||||
var t1 = L.tileLayer("{z}{x}{y}").addTo(map),
|
||||
spy = sinon.spy();
|
||||
|
||||
map.eachLayer(spy, map);
|
||||
|
||||
expect(spy.calls[0].object).toEqual(map);
|
||||
expect(spy.thisValues[0]).to.eql(map);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user