Replaced jasmine testing framework by mocha, expect.js and sinon

as discussed in #319
This commit is contained in:
Tobias Bieniek
2013-03-13 04:32:43 +01:00
parent a0b1d74bb5
commit 89ab68cde7
53 changed files with 13096 additions and 5163 deletions

View File

@@ -469,7 +469,7 @@ def proj4js_zip(t):
if sys.platform == 'win32': if sys.platform == 'win32':
@target('test', '%(PHANTOMJS)s', INTERNAL_SRC, PROJ4JS, 'test/requireall.js', phony=True) @target('test', '%(PHANTOMJS)s', INTERNAL_SRC, PROJ4JS, 'test/requireall.js', phony=True)
def test(t): def test(t):
t.run(PHANTOMJS, 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html') t.run(PHANTOMJS, 'test/mocha-phantomjs.coffee', 'test/ol.html')
# FIXME the PHANTOMJS should be a pake variable, not a constant # FIXME the PHANTOMJS should be a pake variable, not a constant
@target(PHANTOMJS, PHANTOMJS_WINDOWS_ZIP, clean=False) @target(PHANTOMJS, PHANTOMJS_WINDOWS_ZIP, clean=False)
@@ -484,7 +484,7 @@ if sys.platform == 'win32':
else: else:
@target('test', INTERNAL_SRC, PROJ4JS, 'test/requireall.js', phony=True) @target('test', INTERNAL_SRC, PROJ4JS, 'test/requireall.js', phony=True)
def test(t): def test(t):
t.run('%(PHANTOMJS)s', 'test/phantom-jasmine/run_jasmine_test.coffee', 'test/ol.html') t.run('%(PHANTOMJS)s', 'test/mocha-phantomjs.coffee', 'test/ol.html')
@target('fixme', phony=True) @target('fixme', phony=True)

1253
test/expect-0.2.0/expect.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,616 +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);
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 = doc.location.search.substring(1).split('&');
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'}),
dom.results = self.createDom('div', {className: 'results'},
dom.summary = self.createDom('div', { className: 'summary' }),
dom.details = self.createDom('div', { id: 'details' }))
);
}
};
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: "?", 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: "?", 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: "?", 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: '?spec=' + encodeURIComponent(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: '?spec=' + encodeURIComponent(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;
};

View File

@@ -1,81 +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 .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

View File

@@ -1,11 +0,0 @@
beforeEach(function() {
var parent = this.getMatchersClass_();
this.addMatchers({
toBeA: function(type) {
return this.actual instanceof type;
},
toRoughlyEqual: function(other, tol) {
return Math.abs(this.actual - other) <= tol;
}
});
});

5
test/jquery-1.9.1/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,8 +1,10 @@
Copyright (c) 2008-2011 Pivotal Labs (The MIT License)
Copyright (c) 2011-2013 TJ Holowaychuk <tj@vision-media.ca>
Permission is hereby granted, free of charge, to any person obtaining Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including 'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to permit persons to whom the Software is furnished to do so, subject to
@@ -11,10 +13,10 @@ the following conditions:
The above copyright notice and this permission notice shall be The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software. included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

231
test/mocha-1.8.1/mocha.css Normal file
View 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
test/mocha-1.8.1/mocha.js Normal file

File diff suppressed because it is too large Load Diff

261
test/mocha-phantomjs.coffee Normal file
View File

@@ -0,0 +1,261 @@
system = require 'system'
webpage = require 'webpage'
USAGE = """
Usage: phantomjs mocha-phantomjs.coffee URL REPORTER [CONFIG]
"""
class Reporter
constructor: (@reporter, @config) ->
@url = system.args[1]
@columns = parseInt(system.env.COLUMNS or 75) * .75 | 0
@mochaStarted = false
@mochaStartWait = @config.timeout || 6000
@startTime = Date.now()
@fail(USAGE) unless @url
run: ->
@initPage()
@loadPage()
# Subclass Hooks
customizeRunner: (options) ->
undefined
customizeProcessStdout: (options) ->
undefined
customizeConsole: (options) ->
undefined
customizeOptions: ->
columns: @columns
# Private
fail: (msg, errno) ->
console.log msg if msg
phantom.exit errno || 1
finish: ->
phantom.exit @page.evaluate -> mochaPhantomJS.failures
initPage: ->
@page = webpage.create
settings: @config.settings
@page.customHeaders = @config.headers if @config.headers
for name, value of @config.cookies
@page.addCookie
name: name
value: value
@page.viewportSize = @config.viewportSize if @config.viewportSize
@page.onConsoleMessage = (msg) -> console.log msg
@page.onInitialized = =>
@page.evaluate ->
window.mochaPhantomJS =
failures: 0
ended: false
started: false
run: ->
mochaPhantomJS.started = true
window.callPhantom 'mochaPhantomJS.run'
loadPage: ->
@page.open @url
@page.onLoadFinished = (status) =>
@page.onLoadFinished = ->
@onLoadFailed() if status isnt 'success'
@waitForInitMocha()
@page.onCallback = (data) =>
if data is 'mochaPhantomJS.run'
@waitForRunMocha() if @injectJS()
onLoadFailed: ->
@fail "Failed to load the page. Check the url: #{@url}"
injectJS: ->
if @page.evaluate(-> window.mocha?)
@page.injectJs 'mocha-phantomjs/core_extensions.js'
@page.evaluate @customizeProcessStdout, @customizeOptions()
@page.evaluate @customizeConsole, @customizeOptions()
true
else
@fail "Failed to find mocha on the page."
false
runMocha: ->
if @config.useColors is false then @page.evaluate -> Mocha.reporters.Base.useColors = false
@page.evaluate @runner, @reporter
@mochaStarted = @page.evaluate -> mochaPhantomJS.runner or false
if @mochaStarted
@mochaRunAt = new Date().getTime()
@page.evaluate @customizeRunner, @customizeOptions()
@waitForMocha()
else
@fail "Failed to start mocha."
waitForMocha: =>
ended = @page.evaluate -> mochaPhantomJS.ended
if ended then @finish() else setTimeout @waitForMocha, 100
waitForInitMocha: =>
setTimeout @waitForInitMocha, 100 unless @checkStarted()
waitForRunMocha: =>
if @checkStarted() then @runMocha() else setTimeout @waitForRunMocha, 100
checkStarted: =>
started = @page.evaluate -> mochaPhantomJS.started
if !started && @mochaStartWait && @startTime + @mochaStartWait < Date.now()
@fail "Failed to start mocha: Init timeout", 255
started
runner: (reporter) ->
try
mocha.setup reporter: reporter
mochaPhantomJS.runner = mocha.run()
if mochaPhantomJS.runner
cleanup = ->
mochaPhantomJS.failures = mochaPhantomJS.runner.failures
mochaPhantomJS.ended = true
if mochaPhantomJS.runner?.stats?.end
cleanup()
else
mochaPhantomJS.runner.on 'end', cleanup
catch error
false
class Spec extends Reporter
constructor: (config) ->
super 'spec', config
customizeProcessStdout: (options) ->
process.stdout.write = (string) ->
return if string is process.cursor.deleteLine or string is process.cursor.beginningOfLine
console.log string
customizeConsole: (options) ->
process.cursor.CRMatcher = /\s+◦\s\S/
process.cursor.CRCleaner = process.cursor.up + process.cursor.deleteLine
origLog = console.log
console.log = ->
string = console.format.apply(console, arguments)
if string.match(process.cursor.CRMatcher)
process.cursor.CRCleanup = true
else if process.cursor.CRCleanup
string = process.cursor.CRCleaner + string
process.cursor.CRCleanup = false
origLog.call console, string
class Dot extends Reporter
constructor: (config) ->
super 'dot', config
customizeProcessStdout: (options) ->
process.cursor.margin = 2
process.cursor.CRMatcher = /\u001b\[\d\dm\\u001b\[0m/
process.stdout.columns = options.columns
process.stdout.allowedFirstNewLine = false
process.stdout.write = (string) ->
if string is '\n '
unless process.stdout.allowedFirstNewLine
process.stdout.allowedFirstNewLine = true
else
return
else if string.match(process.cursor.CRMatcher)
if process.cursor.count is process.stdout.columns
process.cursor.count = 0
forward = process.cursor.margin
string = process.cursor.forwardN(forward) + string
else
forward = process.cursor.margin + process.cursor.count
string = process.cursor.up + process.cursor.forwardN(forward) + string
++process.cursor.count
console.log string
class Tap extends Reporter
constructor: (config) ->
super 'tap', config
class List extends Reporter
constructor: (config) ->
super 'list', config
customizeProcessStdout: (options) ->
process.stdout.write = (string) ->
return if string is process.cursor.deleteLine or string is process.cursor.beginningOfLine
console.log string
customizeProcessStdout: (options) ->
process.cursor.CRMatcher = /\u001b\[90m.*:\s\u001b\[0m/
process.cursor.CRCleaner = (string) -> process.cursor.up + process.cursor.deleteLine + string + process.cursor.up + process.cursor.up
origLog = console.log
console.log = ->
string = console.format.apply(console, arguments)
if string.match /\u001b\[32m\s\s-\u001b\[0m/
string = string
process.cursor.CRCleanup = false
if string.match(process.cursor.CRMatcher)
process.cursor.CRCleanup = true
else if process.cursor.CRCleanup
string = process.cursor.CRCleaner(string)
process.cursor.CRCleanup = false
origLog.call console, string
class Min extends Reporter
constructor: (config) ->
super 'min', config
class Doc extends Reporter
constructor: (config) ->
super 'doc', config
class Teamcity extends Reporter
constructor: (config) ->
super 'teamcity', config
class Xunit extends Reporter
constructor: (config) ->
super 'xunit', config
class Json extends Reporter
constructor: (config) ->
super 'json', config
class JsonCov extends Reporter
constructor: (config) ->
super 'json-cov', config
class HtmlCov extends Reporter
constructor: (config) ->
super 'html-cov', config
reporterString = system.args[2] || 'spec'
reporterString = ("#{s.charAt(0).toUpperCase()}#{s.slice(1)}" for s in reporterString.split('-')).join('')
reporterKlass = try
eval(reporterString)
catch error
undefined
config = JSON.parse(system.args[3] || '{}')
if reporterKlass
reporter = new reporterKlass config
reporter.run()
else
console.log "Reporter class not implemented: #{reporterString}"
phantom.exit 1

View File

@@ -0,0 +1,86 @@
(function(){
// A shim for non ES5 supporting browsers, like PhantomJS. Lovingly inspired by:
// http://www.angrycoding.com/2011/09/to-bind-or-not-to-bind-that-is-in.html
if (!('bind' in Function.prototype)) {
Function.prototype.bind = function() {
var funcObj = this;
var extraArgs = Array.prototype.slice.call(arguments);
var thisObj = extraArgs.shift();
return function() {
return funcObj.apply(thisObj, extraArgs.concat(Array.prototype.slice.call(arguments)));
};
};
}
// Mocha needs process.stdout.write in order to change the cursor position. However,
// PhantomJS console.log always puts a new line character when logging and no STDOUT or
// stream access is available, outside writing to /dev/stdout, etc. To work around
// this, runner classes typically override `process.stdout.write` as needed to simulate
// write to standard out using cursor commands.
process.cursor = {
count: 0,
margin: 0,
buffer: '',
CRCleanup: false,
CRMatcher: undefined,
CRCleaner: undefined,
hide: '\u001b[?25l',
show: '\u001b[?25h',
deleteLine: '\u001b[2K',
beginningOfLine: '\u001b[0G',
up: '\u001b[A',
down: '\u001b[B',
forward: '\u001b[C',
forwardN: function(n){ return '\u001b[' + n + 'C'; },
backward: '\u001b[D',
nextLine: '\u001b[E',
previousLine: '\u001b[F'
}
process.stdout.columns = 0;
process.stdout.write = function(string) { console.log(string); }
// Mocha needs the formating feature of console.log so copy node's format function and
// monkey-patch it into place. This code is copied from node's, links copyright applies.
// https://github.com/joyent/node/blob/master/lib/util.js
console.format = function(f) {
if (typeof f !== 'string') {
var objects = [];
for (var i = 0; i < arguments.length; i++) {
objects.push(JSON.stringify(arguments[i]));
}
return objects.join(' ');
}
var i = 1;
var args = arguments;
var len = args.length;
var str = String(f).replace(/%[sdj%]/g, function(x) {
if (x === '%%') return '%';
if (i >= len) return x;
switch (x) {
case '%s': return String(args[i++]);
case '%d': return Number(args[i++]);
case '%j': return JSON.stringify(args[i++]);
default:
return x;
}
});
for (var x = args[i]; i < len; x = args[++i]) {
if (x === null || typeof x !== 'object') {
str += ' ' + x;
} else {
str += ' ' + JSON.stringify(x);
}
}
return str;
};
var origError = console.error;
console.error = function(){ origError.call(console, console.format.apply(console, arguments)); };
var origLog = console.log;
console.log = function(){ origLog.call(console, console.format.apply(console, arguments)); };
})();

View File

@@ -1,10 +1,5 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- FIXME console reporter output does not include name of top-level describe -->
<!-- FIXME console reporter requires window.console_reporter. This is to be
reported to phantom-jasmine -->
<!-- <!--
Note: we assume that Plovr is available at <hostname>:9810, where Note: we assume that Plovr is available at <hostname>:9810, where
@@ -19,12 +14,24 @@
<head> <head>
<title>OL Spec Runner</title> <title>OL Spec Runner</title>
<link rel="shortcut icon" type="image/png" href="jasmine-1.2.0/jasmine_favicon.png"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="jasmine-1.2.0/jasmine.css"> <link rel="stylesheet" type="text/css" href="mocha-1.8.1/mocha.css">
<script type="text/javascript" src="jasmine-1.2.0/jasmine.js"></script> </head>
<script type="text/javascript" src="jasmine-1.2.0/jasmine-html.js"></script>
<script type="text/javascript" src="phantom-jasmine/console-runner.js"></script> <body>
<script type="text/javascript" src="jasmine-extensions.js"></script> <div id="mocha"></div>
<script type="text/javascript" src="jquery-1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="expect-0.2.0/expect.js"></script>
<script type="text/javascript" src="sinon-1.6.0/sinon.js"></script>
<script type="text/javascript" src="mocha-1.8.1/mocha.js"></script>
<script type="text/javascript" src="test-extensions.js"></script>
<script>
mocha.setup({
ui: 'bdd',
ignoreLeaks: true
});
</script>
<script type="text/javascript" src="../build/proj4js/lib/proj4js-combined.js"></script> <script type="text/javascript" src="../build/proj4js/lib/proj4js-combined.js"></script>
<script type="text/javascript"> <script type="text/javascript">
@@ -41,75 +48,21 @@
+ 'src="http://' + plovrHost + '/compile?id=test&mode=RAW">' + 'src="http://' + plovrHost + '/compile?id=test&mode=RAW">'
+ '</scr' + 'ipt>'; + '</scr' + 'ipt>';
// this function will fix the links of the result to also include
// the once defined URL Parametrs passed to the testsuite.
function fixLinks() {
if (doc.getElementsByTagName) {
var candidates = doc.getElementsByTagName('a'),
link,
hrefExpression = /\?spec/,
i = 0, len = candidates.length;
for(; i < len; i++){
link = candidates[i];
if (hrefExpression.test(link.href)) {
link.href += '&plov_host=' + encodeURIComponent(plovrHost);
}
}
}
}
// write out the script-tag to load the compiled result // write out the script-tag to load the compiled result
doc.write(script); doc.write(script);
// overwrite jasmines finishCallback to fix the links
jasmine.Runner.prototype.finishCallback = function() {
jasmine.getEnv().reporter.reportRunnerResults(this);
fixLinks();
};
})(document, location); })(document, location);
</script> </script>
<script type="text/javascript"> <script type="text/javascript">
if (window.mochaPhantomJS) {
(function() { mochaPhantomJS.run();
var jasmineEnv = jasmine.getEnv(); } else {
jasmineEnv.updateInterval = 1000; mocha.run();
}
// HTML reporter
var htmlReporter = new jasmine.HtmlReporter();
jasmineEnv.addReporter(htmlReporter);
jasmineEnv.specFilter = function(spec) {
return htmlReporter.specFilter(spec);
};
// Console reporter (for headless testing)
var consoleReporter = new jasmine.ConsoleReporter();
jasmineEnv.addReporter(consoleReporter);
// The run_jasmine_test.coffee script (from phantom-jasmine)
// assumes that the console reporter instance is available
// in the global namespace object as "console_reporter".
// Stupid.
window.console_reporter = consoleReporter;
var currentWindowOnload = window.onload;
window.onload = function() {
if (currentWindowOnload) {
currentWindowOnload();
}
jasmineEnv.execute();
};
})();
</script> </script>
</head>
<body>
<div id="map"></div> <div id="map"></div>
</body> </body>
</html> </html>

View File

@@ -1,161 +0,0 @@
/**
Jasmine Reporter that outputs test results to the browser console.
Useful for running in a headless environment such as PhantomJs, ZombieJs etc.
Usage:
// From your html file that loads jasmine:
jasmine.getEnv().addReporter(new jasmine.ConsoleReporter());
jasmine.getEnv().execute();
*/
(function(jasmine, console) {
if (!jasmine) {
throw "jasmine library isn't loaded!";
}
var ANSI = {};
ANSI.color_map = {
"green" : 32,
"red" : 31
};
ANSI.colorize_text = function(text, color) {
var color_code = this.color_map[color];
return "\033[" + color_code + "m" + text + "\033[0m";
};
var ConsoleReporter = function() {
if (!console || !console.log) { throw "console isn't present!"; }
this.status = this.statuses.stopped;
};
var proto = ConsoleReporter.prototype;
proto.statuses = {
stopped : "stopped",
running : "running",
fail : "fail",
success : "success"
};
proto.reportRunnerStarting = function(runner) {
this.status = this.statuses.running;
this.start_time = (new Date()).getTime();
this.executed_specs = 0;
this.passed_specs = 0;
this.log("Starting...");
};
proto.reportRunnerResults = function(runner) {
var failed = this.executed_specs - this.passed_specs;
var spec_str = this.executed_specs + (this.executed_specs === 1 ? " spec, " : " specs, ");
var fail_str = failed + (failed === 1 ? " failure in " : " failures in ");
var color = (failed > 0)? "red" : "green";
var dur = (new Date()).getTime() - this.start_time;
this.log("");
this.log("Finished");
this.log("-----------------");
this.log(spec_str + fail_str + (dur/1000) + "s.", color);
this.status = (failed > 0)? this.statuses.fail : this.statuses.success;
/* Print something that signals that testing is over so that headless browsers
like PhantomJs know when to terminate. */
this.log("");
this.log("ConsoleReporter finished");
};
proto.reportSpecStarting = function(spec) {
this.executed_specs++;
};
proto.reportSpecResults = function(spec) {
if (spec.results().passed()) {
this.passed_specs++;
return;
}
var resultText = spec.suite.description + " : " + spec.description;
this.log(resultText, "red");
var items = spec.results().getItems();
for (var i = 0; i < items.length; i++) {
var trace = items[i].trace.stack || items[i].trace;
this.log(trace, "red");
}
};
/**
* Will hold the title of the current 'group'.
*/
proto.lastTitle = "";
/**
* Pads given string up to a target length with a given character on either
* the left or right side.
*/
proto.pad = function(string, len, char, side){
var str = string + "",
whichSide = side || 'left',
buff = "",
padChar = char || " ",
padded = "",
iterEnd = len - str.length;
while(buff.length < iterEnd) {
buff += padChar;
}
if (side === 'left') {
padded = buff + str;
} else {
padded = str + buff;
}
// we still need a substring when we are called with e.g. " . " as char.
return padded.substring(0, len);
};
/**
* Pads given string up to a target length with a given character on the right
* side.
*/
proto.padRight = function(str, len, char){
return this.pad(str, len, char, 'right');
};
/**
* Pads given string up to a target length with a given character on the right
* side.
*/
proto.padLeft = function(str, len, char){
return this.pad(str, len, char, 'left');
};
proto.reportSuiteResults = function(suite) {
if (!suite.parentSuite) { return; }
// determine title from full name (wo/ own description)
var title = suite.getFullName().replace(new RegExp(suite.description + "$"), "");
if (this.lastTitle !== title) {
// when title differs, we have a new 'group'
this.log("\n" + title);
}
// always set current title
this.lastTitle = title;
var results = suite.results();
var failed = results.totalCount - results.passedCount;
var color = (failed > 0) ? "red" : "green";
var logStr = " " + this.padRight(suite.description + " ", 60, '.') +
this.padLeft(results.passedCount, 4) + "/" +
this.padRight(results.totalCount, 4) + " ok";
this.log(logStr, color);
};
proto.log = function(str, color) {
var text = (color)? ANSI.colorize_text(str, color) : str;
console.log(text);
};
jasmine.ConsoleReporter = ConsoleReporter;
})(jasmine, console);

View File

@@ -1,46 +0,0 @@
#!/usr/local/bin/phantomjs
# Runs a Jasmine Suite from an html page
# @page is a PhantomJs page object
# @exit_func is the function to call in order to exit the script
class PhantomJasmineRunner
constructor: (@page, @exit_func = phantom.exit) ->
@tries = 0
@max_tries = 10
get_status: -> @page.evaluate(-> console_reporter.status)
terminate: ->
switch @get_status()
when "success" then @exit_func 0
when "fail" then @exit_func 1
else @exit_func 2
# Script Begin
if phantom.args.length == 0
console.log "Need a url as the argument"
phantom.exit 1
page = new WebPage()
runner = new PhantomJasmineRunner(page)
# Don't supress console output
page.onConsoleMessage = (msg) ->
console.log msg
# Terminate when the reporter singals that testing is over.
# We cannot use a callback function for this (because page.evaluate is sandboxed),
# so we have to *observe* the website.
if msg == "ConsoleReporter finished"
runner.terminate()
address = phantom.args[0]
page.open address, (status) ->
if status != "success"
console.log "can't load the address!"
phantom.exit 1
# Now we wait until onConsoleMessage reads the termination signal from the log.

4223
test/sinon-1.6.0/sinon.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -6,21 +6,21 @@ describe('ol.array', function() {
it('returns expected value', function() { it('returns expected value', function() {
var arr = [1000, 500, 100]; var arr = [1000, 500, 100];
expect(ol.array.binaryFindNearest(arr, 10000)).toEqual(0); expect(ol.array.binaryFindNearest(arr, 10000)).to.eql(0);
expect(ol.array.binaryFindNearest(arr, 1000)).toEqual(0); expect(ol.array.binaryFindNearest(arr, 1000)).to.eql(0);
expect(ol.array.binaryFindNearest(arr, 900)).toEqual(0); expect(ol.array.binaryFindNearest(arr, 900)).to.eql(0);
expect(ol.array.binaryFindNearest(arr, 750)).toEqual(1); expect(ol.array.binaryFindNearest(arr, 750)).to.eql(1);
expect(ol.array.binaryFindNearest(arr, 550)).toEqual(1); expect(ol.array.binaryFindNearest(arr, 550)).to.eql(1);
expect(ol.array.binaryFindNearest(arr, 500)).toEqual(1); expect(ol.array.binaryFindNearest(arr, 500)).to.eql(1);
expect(ol.array.binaryFindNearest(arr, 450)).toEqual(1); expect(ol.array.binaryFindNearest(arr, 450)).to.eql(1);
expect(ol.array.binaryFindNearest(arr, 300)).toEqual(2); expect(ol.array.binaryFindNearest(arr, 300)).to.eql(2);
expect(ol.array.binaryFindNearest(arr, 200)).toEqual(2); expect(ol.array.binaryFindNearest(arr, 200)).to.eql(2);
expect(ol.array.binaryFindNearest(arr, 100)).toEqual(2); expect(ol.array.binaryFindNearest(arr, 100)).to.eql(2);
expect(ol.array.binaryFindNearest(arr, 50)).toEqual(2); expect(ol.array.binaryFindNearest(arr, 50)).to.eql(2);
}); });
}); });
@@ -28,21 +28,21 @@ describe('ol.array', function() {
it('returns expected value', function() { it('returns expected value', function() {
var arr = [1000, 500, 100]; var arr = [1000, 500, 100];
expect(ol.array.linearFindNearest(arr, 10000)).toEqual(0); expect(ol.array.linearFindNearest(arr, 10000)).to.eql(0);
expect(ol.array.linearFindNearest(arr, 1000)).toEqual(0); expect(ol.array.linearFindNearest(arr, 1000)).to.eql(0);
expect(ol.array.linearFindNearest(arr, 900)).toEqual(0); expect(ol.array.linearFindNearest(arr, 900)).to.eql(0);
expect(ol.array.linearFindNearest(arr, 750)).toEqual(1); expect(ol.array.linearFindNearest(arr, 750)).to.eql(1);
expect(ol.array.linearFindNearest(arr, 550)).toEqual(1); expect(ol.array.linearFindNearest(arr, 550)).to.eql(1);
expect(ol.array.linearFindNearest(arr, 500)).toEqual(1); expect(ol.array.linearFindNearest(arr, 500)).to.eql(1);
expect(ol.array.linearFindNearest(arr, 450)).toEqual(1); expect(ol.array.linearFindNearest(arr, 450)).to.eql(1);
expect(ol.array.linearFindNearest(arr, 300)).toEqual(2); expect(ol.array.linearFindNearest(arr, 300)).to.eql(2);
expect(ol.array.linearFindNearest(arr, 200)).toEqual(2); expect(ol.array.linearFindNearest(arr, 200)).to.eql(2);
expect(ol.array.linearFindNearest(arr, 100)).toEqual(2); expect(ol.array.linearFindNearest(arr, 100)).to.eql(2);
expect(ol.array.linearFindNearest(arr, 50)).toEqual(2); expect(ol.array.linearFindNearest(arr, 50)).to.eql(2);
}); });
}); });
}); });

View File

@@ -9,9 +9,9 @@ describe('ol.collection', function() {
describe('create an empty collection', function() { describe('create an empty collection', function() {
it('creates an empty collection', function() { it('creates an empty collection', function() {
expect(collection.getLength()).toEqual(0); expect(collection.getLength()).to.eql(0);
expect(goog.array.equals(collection.getArray(), [])).toBeTruthy(); expect(goog.array.equals(collection.getArray(), [])).to.be.ok();
expect(collection.getAt(0)).toBeUndefined(); expect(collection.getAt(0)).to.be(undefined);
}); });
}); });
@@ -19,18 +19,18 @@ describe('ol.collection', function() {
it('creates the expected collection', function() { it('creates the expected collection', function() {
var array = [0, 1, 2]; var array = [0, 1, 2];
var collection = new ol.Collection(array); var collection = new ol.Collection(array);
expect(collection.getAt(0)).toEqual(0); expect(collection.getAt(0)).to.eql(0);
expect(collection.getAt(1)).toEqual(1); expect(collection.getAt(1)).to.eql(1);
expect(collection.getAt(2)).toEqual(2); expect(collection.getAt(2)).to.eql(2);
}); });
}); });
describe('push to a collection', function() { describe('push to a collection', function() {
it('adds elements to the collection', function() { it('adds elements to the collection', function() {
collection.push(1); collection.push(1);
expect(collection.getLength()).toEqual(1); expect(collection.getLength()).to.eql(1);
expect(goog.array.equals(collection.getArray(), [1])).toBeTruthy(); expect(goog.array.equals(collection.getArray(), [1])).to.be.ok();
expect(collection.getAt(0)).toEqual(1); expect(collection.getAt(0)).to.eql(1);
}); });
}); });
@@ -38,9 +38,9 @@ describe('ol.collection', function() {
it('removes elements from the collection', function() { it('removes elements from the collection', function() {
collection.push(1); collection.push(1);
collection.pop(); collection.pop();
expect(collection.getLength()).toEqual(0); expect(collection.getLength()).to.eql(0);
expect(goog.array.equals(collection.getArray(), [])).toBeTruthy(); expect(goog.array.equals(collection.getArray(), [])).to.be.ok();
expect(collection.getAt(0)).toBeUndefined(); expect(collection.getAt(0)).to.be(undefined);
}); });
}); });
@@ -48,18 +48,18 @@ describe('ol.collection', function() {
it('inserts elements at the correct location', function() { it('inserts elements at the correct location', function() {
collection = new ol.Collection([0, 2]); collection = new ol.Collection([0, 2]);
collection.insertAt(1, 1); collection.insertAt(1, 1);
expect(collection.getAt(0)).toEqual(0); expect(collection.getAt(0)).to.eql(0);
expect(collection.getAt(1)).toEqual(1); expect(collection.getAt(1)).to.eql(1);
expect(collection.getAt(2)).toEqual(2); expect(collection.getAt(2)).to.eql(2);
}); });
}); });
describe('setAt', function() { describe('setAt', function() {
it('sets at the correct location', function() { it('sets at the correct location', function() {
collection.setAt(1, 1); collection.setAt(1, 1);
expect(collection.getLength()).toEqual(2); expect(collection.getLength()).to.eql(2);
expect(collection.getAt(0)).toBeUndefined(); expect(collection.getAt(0)).to.be(undefined);
expect(collection.getAt(1)).toEqual(1); expect(collection.getAt(1)).to.eql(1);
}); });
}); });
@@ -67,20 +67,20 @@ describe('ol.collection', function() {
it('removes elements at the correction', function() { it('removes elements at the correction', function() {
var collection = new ol.Collection([0, 1, 2]); var collection = new ol.Collection([0, 1, 2]);
collection.removeAt(1); collection.removeAt(1);
expect(collection.getAt(0)).toEqual(0); expect(collection.getAt(0)).to.eql(0);
expect(collection.getAt(1)).toEqual(2); expect(collection.getAt(1)).to.eql(2);
}); });
}); });
describe('forEach', function() { describe('forEach', function() {
var cb; var cb;
beforeEach(function() { beforeEach(function() {
cb = jasmine.createSpy(); cb = sinon.spy();
}); });
describe('on an empty collection', function() { describe('on an empty collection', function() {
it('does not call the callback', function() { it('does not call the callback', function() {
collection.forEach(cb); collection.forEach(cb);
expect(cb).not.toHaveBeenCalled(); expect(cb.called).to.not.be.ok();
}); });
}); });
describe('on a non-empty collection', function() { describe('on a non-empty collection', function() {
@@ -88,7 +88,7 @@ describe('ol.collection', function() {
collection.push(1); collection.push(1);
collection.push(2); collection.push(2);
collection.forEach(cb); collection.forEach(cb);
expect(cb.calls.length).toEqual(2); expect(cb.callCount).to.eql(2);
}); });
}); });
describe('scope', function() { describe('scope', function() {
@@ -99,7 +99,7 @@ describe('ol.collection', function() {
collection.forEach(function(elem) { collection.forEach(function(elem) {
that = this; that = this;
}, uniqueObj); }, uniqueObj);
expect(that).toBe(uniqueObj); expect(that).to.be(uniqueObj);
}); });
}); });
}); });
@@ -107,29 +107,29 @@ describe('ol.collection', function() {
describe('remove', function() { describe('remove', function() {
it('removes the first matching element', function() { it('removes the first matching element', function() {
var collection = new ol.Collection([0, 1, 2]); var collection = new ol.Collection([0, 1, 2]);
expect(collection.remove(1)).toEqual(1); expect(collection.remove(1)).to.eql(1);
expect(collection.getArray()).toEqual([0, 2]); expect(collection.getArray()).to.eql([0, 2]);
expect(collection.getLength()).toEqual(2); expect(collection.getLength()).to.eql(2);
}); });
it('fires a remove event', function() { it('fires a remove event', function() {
var collection = new ol.Collection([0, 1, 2]); var collection = new ol.Collection([0, 1, 2]);
var cb = jasmine.createSpy(); var cb = sinon.spy();
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb); goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb);
expect(collection.remove(1)).toEqual(1); expect(collection.remove(1)).to.eql(1);
expect(cb).toHaveBeenCalled(); expect(cb.called).to.be.ok();
expect(cb.mostRecentCall.args[0].elem).toEqual(1); expect(cb.lastCall.args[0].elem).to.eql(1);
}); });
it('does not remove more than one matching element', function() { it('does not remove more than one matching element', function() {
var collection = new ol.Collection([0, 1, 1, 2]); var collection = new ol.Collection([0, 1, 1, 2]);
expect(collection.remove(1)).toEqual(1); expect(collection.remove(1)).to.eql(1);
expect(collection.getArray()).toEqual([0, 1, 2]); expect(collection.getArray()).to.eql([0, 1, 2]);
expect(collection.getLength()).toEqual(3); expect(collection.getLength()).to.eql(3);
}); });
it('returns undefined if the element is not found', function() { it('returns undefined if the element is not found', function() {
var collection = new ol.Collection([0, 1, 2]); var collection = new ol.Collection([0, 1, 2]);
expect(collection.remove(3)).toBeUndefined(); expect(collection.remove(3)).to.be(undefined);
expect(collection.getArray()).toEqual([0, 1, 2]); expect(collection.getArray()).to.eql([0, 1, 2]);
expect(collection.getLength()).toEqual(3); expect(collection.getLength()).to.eql(3);
}); });
}); });
@@ -145,8 +145,8 @@ describe('ol.collection', function() {
removed = e.elem; removed = e.elem;
}); });
collection.setAt(1, 1); collection.setAt(1, 1);
expect(added).toEqual(1); expect(added).to.eql(1);
expect(removed).toEqual('b'); expect(removed).to.eql('b');
}); });
}); });
@@ -159,7 +159,7 @@ describe('ol.collection', function() {
removed = e.elem; removed = e.elem;
}); });
collection.pop(); collection.pop();
expect(removed).toEqual('a'); expect(removed).to.eql('a');
}); });
}); });
@@ -172,7 +172,7 @@ describe('ol.collection', function() {
added = e.elem; added = e.elem;
}); });
collection.insertAt(1, 1); collection.insertAt(1, 1);
expect(added).toEqual(1); expect(added).to.eql(1);
}); });
}); });
@@ -184,14 +184,14 @@ describe('ol.collection', function() {
added.push(e.elem); added.push(e.elem);
}); });
collection.setAt(2, 0); collection.setAt(2, 0);
expect(collection.getLength()).toEqual(3); expect(collection.getLength()).to.eql(3);
expect(collection.getAt(0)).toBeUndefined(); expect(collection.getAt(0)).to.be(undefined);
expect(collection.getAt(1)).toBeUndefined(); expect(collection.getAt(1)).to.be(undefined);
expect(collection.getAt(2)).toEqual(0); expect(collection.getAt(2)).to.eql(0);
expect(added.length).toEqual(3); expect(added.length).to.eql(3);
expect(added[0]).toEqual(undefined); expect(added[0]).to.eql(undefined);
expect(added[1]).toEqual(undefined); expect(added[1]).to.eql(undefined);
expect(added[2]).toEqual(0); expect(added[2]).to.eql(0);
}); });
}); });
@@ -199,28 +199,28 @@ describe('ol.collection', function() {
var collection, cb; var collection, cb;
beforeEach(function() { beforeEach(function() {
collection = new ol.Collection([0, 1, 2]); collection = new ol.Collection([0, 1, 2]);
cb = jasmine.createSpy(); cb = sinon.spy();
goog.events.listen(collection, 'length_changed', cb); goog.events.listen(collection, 'length_changed', cb);
}); });
describe('insertAt', function() { describe('insertAt', function() {
it('triggers length_changed event', function() { it('triggers length_changed event', function() {
collection.insertAt(2, 3); collection.insertAt(2, 3);
expect(cb).toHaveBeenCalled(); expect(cb.called).to.be.ok();
}); });
}); });
describe('removeAt', function() { describe('removeAt', function() {
it('triggers length_changed event', function() { it('triggers length_changed event', function() {
collection.removeAt(0); collection.removeAt(0);
expect(cb).toHaveBeenCalled(); expect(cb.called).to.be.ok();
}); });
}); });
describe('setAt', function() { describe('setAt', function() {
it('does not trigger length_changed event', function() { it('does not trigger length_changed event', function() {
collection.setAt(1, 1); collection.setAt(1, 1);
expect(cb).not.toHaveBeenCalled(); expect(cb.called).to.not.be.ok();
}); });
}); });
}); });
@@ -233,7 +233,7 @@ describe('ol.collection', function() {
elem = e.elem; elem = e.elem;
}); });
collection.push(1); collection.push(1);
expect(elem).toEqual(1); expect(elem).to.eql(1);
}); });
}); });
@@ -241,16 +241,16 @@ describe('ol.collection', function() {
var collection, cb1, cb2; var collection, cb1, cb2;
beforeEach(function() { beforeEach(function() {
collection = new ol.Collection([1]); collection = new ol.Collection([1]);
cb1 = jasmine.createSpy(); cb1 = sinon.spy();
cb2 = jasmine.createSpy(); cb2 = sinon.spy();
}); });
describe('setAt', function() { describe('setAt', function() {
it('triggers remove', function() { it('triggers remove', function() {
goog.events.listen(collection, ol.CollectionEventType.ADD, cb1); goog.events.listen(collection, ol.CollectionEventType.ADD, cb1);
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb2); goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb2);
collection.setAt(0, 2); collection.setAt(0, 2);
expect(cb1.mostRecentCall.args[0].elem).toEqual(2); expect(cb2.lastCall.args[0].elem).to.eql(1);
expect(cb2.mostRecentCall.args[0].elem).toEqual(1); expect(cb1.lastCall.args[0].elem).to.eql(2);
}); });
}); });
describe('pop', function() { describe('pop', function() {
@@ -258,7 +258,7 @@ describe('ol.collection', function() {
var elem; var elem;
goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb1); goog.events.listen(collection, ol.CollectionEventType.REMOVE, cb1);
collection.pop(); collection.pop();
expect(cb1.mostRecentCall.args[0].elem).toEqual(1); expect(cb1.lastCall.args[0].elem).to.eql(1);
}); });
}); });
}); });
@@ -266,10 +266,10 @@ describe('ol.collection', function() {
describe('extending a collection', function() { describe('extending a collection', function() {
it('adds elements to end of the collection', function() { it('adds elements to end of the collection', function() {
collection.extend([1, 2]); collection.extend([1, 2]);
expect(collection.getLength()).toEqual(2); expect(collection.getLength()).to.eql(2);
expect(goog.array.equals(collection.getArray(), [1, 2])).toBeTruthy(); expect(goog.array.equals(collection.getArray(), [1, 2])).to.be.ok();
expect(collection.getAt(0)).toEqual(1); expect(collection.getAt(0)).to.eql(1);
expect(collection.getAt(1)).toEqual(2); expect(collection.getAt(1)).to.eql(2);
}); });
}); });

View File

@@ -9,15 +9,15 @@ describe('ol.Color', function() {
// legit r // legit r
c = new ol.Color(10.5, 11, 12, 0.5); c = new ol.Color(10.5, 11, 12, 0.5);
expect(c.r).toBe(10.5); expect(c.r).to.be(10.5);
// under r // under r
c = new ol.Color(-10, 11, 12, 0.5); c = new ol.Color(-10, 11, 12, 0.5);
expect(c.r).toBe(0); expect(c.r).to.be(0);
// over r // over r
c = new ol.Color(300, 11, 12, 0.5); c = new ol.Color(300, 11, 12, 0.5);
expect(c.r).toBe(255); expect(c.r).to.be(255);
}); });
it('limits g to 0-255', function() { it('limits g to 0-255', function() {
@@ -25,15 +25,15 @@ describe('ol.Color', function() {
// legit g // legit g
c = new ol.Color(10, 11.5, 12, 0.5); c = new ol.Color(10, 11.5, 12, 0.5);
expect(c.g).toBe(11.5); expect(c.g).to.be(11.5);
// under g // under g
c = new ol.Color(10, -11, 12, 0.5); c = new ol.Color(10, -11, 12, 0.5);
expect(c.g).toBe(0); expect(c.g).to.be(0);
// over g // over g
c = new ol.Color(10, 275, 12, 0.5); c = new ol.Color(10, 275, 12, 0.5);
expect(c.g).toBe(255); expect(c.g).to.be(255);
}); });
it('limits b to 0-255', function() { it('limits b to 0-255', function() {
@@ -41,15 +41,15 @@ describe('ol.Color', function() {
// legit b // legit b
c = new ol.Color(10, 11, 12.5, 0.5); c = new ol.Color(10, 11, 12.5, 0.5);
expect(c.b).toBe(12.5); expect(c.b).to.be(12.5);
// under b // under b
c = new ol.Color(10, 11, -12, 0.5); c = new ol.Color(10, 11, -12, 0.5);
expect(c.b).toBe(0); expect(c.b).to.be(0);
// over b // over b
c = new ol.Color(10, 11, 500, 0.5); c = new ol.Color(10, 11, 500, 0.5);
expect(c.b).toBe(255); expect(c.b).to.be(255);
}); });
it('limits 1 to 0-1', function() { it('limits 1 to 0-1', function() {
@@ -57,15 +57,15 @@ describe('ol.Color', function() {
// legit a // legit a
c = new ol.Color(10, 11, 12, 0.5); c = new ol.Color(10, 11, 12, 0.5);
expect(c.a).toBe(0.5); expect(c.a).to.be(0.5);
// under a // under a
c = new ol.Color(10, 11, 12, -0.5); c = new ol.Color(10, 11, 12, -0.5);
expect(c.a).toBe(0); expect(c.a).to.be(0);
// over a // over a
c = new ol.Color(10, 11, 12, 2.5); c = new ol.Color(10, 11, 12, 2.5);
expect(c.a).toBe(1); expect(c.a).to.be(1);
}); });
}); });

View File

@@ -19,7 +19,7 @@ describe('ol.control.Control', function() {
describe('dispose', function() { describe('dispose', function() {
it('removes the control element from its parent', function() { it('removes the control element from its parent', function() {
control.dispose(); control.dispose();
expect(goog.dom.getParentElement(control.element)).toBeNull(); expect(goog.dom.getParentElement(control.element)).to.be(null);
}); });
}); });
}); });

View File

@@ -329,9 +329,9 @@ describe('ol.Ellipsoid', function() {
for (i = 0; i < expected.length; ++i) { for (i = 0; i < expected.length; ++i) {
e = expected[i]; e = expected[i];
v = ol.ellipsoid.WGS84.vincenty(e.c1, e.c2, 1e-12, 100); v = ol.ellipsoid.WGS84.vincenty(e.c1, e.c2, 1e-12, 100);
expect(v.distance).toRoughlyEqual(e.vincentyDistance, 1e-8); expect(v.distance).to.roughlyEqual(e.vincentyDistance, 1e-8);
expect(v.finalBearing).toRoughlyEqual(e.vincentyFinalBearing, 1e-9); expect(v.finalBearing).to.roughlyEqual(e.vincentyFinalBearing, 1e-9);
expect(v.initialBearing).toRoughlyEqual( expect(v.initialBearing).to.roughlyEqual(
e.vincentyInitialBearing, 1e-9); e.vincentyInitialBearing, 1e-9);
} }
}); });
@@ -347,7 +347,7 @@ describe('ol.Ellipsoid', function() {
e = expected[i]; e = expected[i];
vincentyDistance = vincentyDistance =
ol.ellipsoid.WGS84.vincentyDistance(e.c1, e.c2, 1e-12, 100); ol.ellipsoid.WGS84.vincentyDistance(e.c1, e.c2, 1e-12, 100);
expect(vincentyDistance).toRoughlyEqual(e.vincentyDistance, 1e-8); expect(vincentyDistance).to.roughlyEqual(e.vincentyDistance, 1e-8);
} }
}); });
@@ -362,7 +362,7 @@ describe('ol.Ellipsoid', function() {
e = expected[i]; e = expected[i];
vincentyFinalBearing = vincentyFinalBearing =
ol.ellipsoid.WGS84.vincentyFinalBearing(e.c1, e.c2, 1e-12, 100); ol.ellipsoid.WGS84.vincentyFinalBearing(e.c1, e.c2, 1e-12, 100);
expect(vincentyFinalBearing).toRoughlyEqual( expect(vincentyFinalBearing).to.roughlyEqual(
e.vincentyFinalBearing, 1e-9); e.vincentyFinalBearing, 1e-9);
} }
}); });
@@ -378,7 +378,7 @@ describe('ol.Ellipsoid', function() {
e = expected[i]; e = expected[i];
vincentyInitialBearing = ol.ellipsoid.WGS84.vincentyInitialBearing( vincentyInitialBearing = ol.ellipsoid.WGS84.vincentyInitialBearing(
e.c1, e.c2, 1e-12, 100); e.c1, e.c2, 1e-12, 100);
expect(vincentyInitialBearing).toRoughlyEqual( expect(vincentyInitialBearing).to.roughlyEqual(
e.vincentyInitialBearing, 1e-9); e.vincentyInitialBearing, 1e-9);
} }
}); });

View File

@@ -8,23 +8,23 @@ describe('ol.Extent', function() {
it('returns true', function() { it('returns true', function() {
var extent = new ol.Extent(1, 2, 3, 4); var extent = new ol.Extent(1, 2, 3, 4);
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(1, 2))).toBeTruthy(); new ol.Coordinate(1, 2))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(1, 3))).toBeTruthy(); new ol.Coordinate(1, 3))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(1, 4))).toBeTruthy(); new ol.Coordinate(1, 4))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(2, 2))).toBeTruthy(); new ol.Coordinate(2, 2))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(2, 3))).toBeTruthy(); new ol.Coordinate(2, 3))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(2, 4))).toBeTruthy(); new ol.Coordinate(2, 4))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(3, 2))).toBeTruthy(); new ol.Coordinate(3, 2))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(3, 3))).toBeTruthy(); new ol.Coordinate(3, 3))).to.be.ok();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(3, 4))).toBeTruthy(); new ol.Coordinate(3, 4))).to.be.ok();
}); });
}); });
@@ -32,37 +32,37 @@ describe('ol.Extent', function() {
it('returns false', function() { it('returns false', function() {
var extent = new ol.Extent(1, 2, 3, 4); var extent = new ol.Extent(1, 2, 3, 4);
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(0, 1))).toBeFalsy(); new ol.Coordinate(0, 1))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(0, 2))).toBeFalsy(); new ol.Coordinate(0, 2))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(0, 3))).toBeFalsy(); new ol.Coordinate(0, 3))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(0, 4))).toBeFalsy(); new ol.Coordinate(0, 4))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(0, 5))).toBeFalsy(); new ol.Coordinate(0, 5))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(1, 1))).toBeFalsy(); new ol.Coordinate(1, 1))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(1, 5))).toBeFalsy(); new ol.Coordinate(1, 5))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(2, 1))).toBeFalsy(); new ol.Coordinate(2, 1))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(2, 5))).toBeFalsy(); new ol.Coordinate(2, 5))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(3, 1))).toBeFalsy(); new ol.Coordinate(3, 1))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(3, 5))).toBeFalsy(); new ol.Coordinate(3, 5))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(4, 1))).toBeFalsy(); new ol.Coordinate(4, 1))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(4, 2))).toBeFalsy(); new ol.Coordinate(4, 2))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(4, 3))).toBeFalsy(); new ol.Coordinate(4, 3))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(4, 4))).toBeFalsy(); new ol.Coordinate(4, 4))).to.not.be();
expect(extent.containsCoordinate( expect(extent.containsCoordinate(
new ol.Coordinate(4, 5))).toBeFalsy(); new ol.Coordinate(4, 5))).to.not.be();
}); });
}); });
}); });
@@ -73,13 +73,13 @@ describe('ol.Extent', function() {
var transformFn = ol.projection.getTransform('EPSG:4326', 'EPSG:3857'); var transformFn = ol.projection.getTransform('EPSG:4326', 'EPSG:3857');
var sourceExtent = new ol.Extent(-15, -30, 45, 60); var sourceExtent = new ol.Extent(-15, -30, 45, 60);
var destinationExtent = sourceExtent.transform(transformFn); var destinationExtent = sourceExtent.transform(transformFn);
expect(destinationExtent).not.toBeUndefined(); expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.toBeNull(); expect(destinationExtent).not.to.be(null);
// FIXME check values with third-party tool // FIXME check values with third-party tool
expect(destinationExtent.minX).toRoughlyEqual(-1669792.3618991037, 1e-9); expect(destinationExtent.minX).to.roughlyEqual(-1669792.3618991037, 1e-9);
expect(destinationExtent.minY).toRoughlyEqual(-3503549.843504376, 1e-8); expect(destinationExtent.minY).to.roughlyEqual(-3503549.843504376, 1e-8);
expect(destinationExtent.maxX).toRoughlyEqual(5009377.085697311, 1e-9); expect(destinationExtent.maxX).to.roughlyEqual(5009377.085697311, 1e-9);
expect(destinationExtent.maxY).toRoughlyEqual(8399737.889818361, 1e-9); expect(destinationExtent.maxY).to.roughlyEqual(8399737.889818361, 1e-9);
}); });
it('takes arbitrary function', function() { it('takes arbitrary function', function() {
@@ -88,12 +88,12 @@ describe('ol.Extent', function() {
}; };
var sourceExtent = new ol.Extent(-15, -30, 45, 60); var sourceExtent = new ol.Extent(-15, -30, 45, 60);
var destinationExtent = sourceExtent.transform(transformFn); var destinationExtent = sourceExtent.transform(transformFn);
expect(destinationExtent).not.toBeUndefined(); expect(destinationExtent).not.to.be(undefined);
expect(destinationExtent).not.toBeNull(); expect(destinationExtent).not.to.be(null);
expect(destinationExtent.minX).toBe(-45); expect(destinationExtent.minX).to.be(-45);
expect(destinationExtent.minY).toBe(-60); expect(destinationExtent.minY).to.be(-60);
expect(destinationExtent.maxX).toBe(15); expect(destinationExtent.maxX).to.be(15);
expect(destinationExtent.maxY).toBe(30); expect(destinationExtent.maxY).to.be(30);
}); });
}); });
@@ -103,46 +103,46 @@ describe('ol.Extent', function() {
it('works for a unit square', function() { it('works for a unit square', function() {
var extent = ol.Extent.getForView2DAndSize( var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, 0, new ol.Size(1, 1)); new ol.Coordinate(0, 0), 1, 0, new ol.Size(1, 1));
expect(extent.minX).toBe(-0.5); expect(extent.minX).to.be(-0.5);
expect(extent.minY).toBe(-0.5); expect(extent.minY).to.be(-0.5);
expect(extent.maxX).toBe(0.5); expect(extent.maxX).to.be(0.5);
expect(extent.maxY).toBe(0.5); expect(extent.maxY).to.be(0.5);
}); });
it('works for center', function() { it('works for center', function() {
var extent = ol.Extent.getForView2DAndSize( var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(5, 10), 1, 0, new ol.Size(1, 1)); new ol.Coordinate(5, 10), 1, 0, new ol.Size(1, 1));
expect(extent.minX).toBe(4.5); expect(extent.minX).to.be(4.5);
expect(extent.minY).toBe(9.5); expect(extent.minY).to.be(9.5);
expect(extent.maxX).toBe(5.5); expect(extent.maxX).to.be(5.5);
expect(extent.maxY).toBe(10.5); expect(extent.maxY).to.be(10.5);
}); });
it('works for rotation', function() { it('works for rotation', function() {
var extent = ol.Extent.getForView2DAndSize( var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, Math.PI / 4, new ol.Size(1, 1)); new ol.Coordinate(0, 0), 1, Math.PI / 4, new ol.Size(1, 1));
expect(extent.minX).toRoughlyEqual(-Math.sqrt(0.5), 1e-9); expect(extent.minX).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent.minY).toRoughlyEqual(-Math.sqrt(0.5), 1e-9); expect(extent.minY).to.roughlyEqual(-Math.sqrt(0.5), 1e-9);
expect(extent.maxX).toRoughlyEqual(Math.sqrt(0.5), 1e-9); expect(extent.maxX).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
expect(extent.maxY).toRoughlyEqual(Math.sqrt(0.5), 1e-9); expect(extent.maxY).to.roughlyEqual(Math.sqrt(0.5), 1e-9);
}); });
it('works for resolution', function() { it('works for resolution', function() {
var extent = ol.Extent.getForView2DAndSize( var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 2, 0, new ol.Size(1, 1)); new ol.Coordinate(0, 0), 2, 0, new ol.Size(1, 1));
expect(extent.minX).toBe(-1); expect(extent.minX).to.be(-1);
expect(extent.minY).toBe(-1); expect(extent.minY).to.be(-1);
expect(extent.maxX).toBe(1); expect(extent.maxX).to.be(1);
expect(extent.maxY).toBe(1); expect(extent.maxY).to.be(1);
}); });
it('works for size', function() { it('works for size', function() {
var extent = ol.Extent.getForView2DAndSize( var extent = ol.Extent.getForView2DAndSize(
new ol.Coordinate(0, 0), 1, 0, new ol.Size(10, 5)); new ol.Coordinate(0, 0), 1, 0, new ol.Size(10, 5));
expect(extent.minX).toBe(-5); expect(extent.minX).to.be(-5);
expect(extent.minY).toBe(-2.5); expect(extent.minY).to.be(-2.5);
expect(extent.maxX).toBe(5); expect(extent.maxX).to.be(5);
expect(extent.maxY).toBe(2.5); expect(extent.maxY).to.be(2.5);
}); });
}); });

View File

@@ -19,31 +19,31 @@ describe('ol.layer.Layer', function() {
}); });
it('creates an instance', function() { it('creates an instance', function() {
expect(layer).toBeA(ol.layer.Layer); expect(layer).to.be.a(ol.layer.Layer);
}); });
it('provides default brightness', function() { it('provides default brightness', function() {
expect(layer.getBrightness()).toBe(0); expect(layer.getBrightness()).to.be(0);
}); });
it('provides default contrast', function() { it('provides default contrast', function() {
expect(layer.getContrast()).toBe(1); expect(layer.getContrast()).to.be(1);
}); });
it('provides default hue', function() { it('provides default hue', function() {
expect(layer.getHue()).toBe(0); expect(layer.getHue()).to.be(0);
}); });
it('provides default opacity', function() { it('provides default opacity', function() {
expect(layer.getOpacity()).toBe(1); expect(layer.getOpacity()).to.be(1);
}); });
it('provides default saturation', function() { it('provides default saturation', function() {
expect(layer.getSaturation()).toBe(1); expect(layer.getSaturation()).to.be(1);
}); });
it('provides default visibility', function() { it('provides default visibility', function() {
expect(layer.getVisible()).toBe(true); expect(layer.getVisible()).to.be(true);
}); });
}); });
@@ -63,12 +63,12 @@ describe('ol.layer.Layer', function() {
visible: false visible: false
}); });
expect(layer.getBrightness()).toBe(0.5); expect(layer.getBrightness()).to.be(0.5);
expect(layer.getContrast()).toBe(10); expect(layer.getContrast()).to.be(10);
expect(layer.getHue()).toBe(180); expect(layer.getHue()).to.be(180);
expect(layer.getOpacity()).toBe(0.5); expect(layer.getOpacity()).to.be(0.5);
expect(layer.getSaturation()).toBe(5); expect(layer.getSaturation()).to.be(5);
expect(layer.getVisible()).toBe(false); expect(layer.getVisible()).to.be(false);
layer.dispose(); layer.dispose();
}); });
@@ -93,22 +93,22 @@ describe('ol.layer.Layer', function() {
it('accepts a positive number', function() { it('accepts a positive number', function() {
layer.setBrightness(0.3); layer.setBrightness(0.3);
expect(layer.getBrightness()).toBe(0.3); expect(layer.getBrightness()).to.be(0.3);
}); });
it('accepts a negative number', function() { it('accepts a negative number', function() {
layer.setBrightness(-0.7); layer.setBrightness(-0.7);
expect(layer.getBrightness()).toBe(-0.7); expect(layer.getBrightness()).to.be(-0.7);
}); });
it('clamps to 1', function() { it('clamps to 1', function() {
layer.setBrightness(1.5); layer.setBrightness(1.5);
expect(layer.getBrightness()).toBe(1); expect(layer.getBrightness()).to.be(1);
}); });
it('clamps to -1', function() { it('clamps to -1', function() {
layer.setBrightness(-3); layer.setBrightness(-3);
expect(layer.getBrightness()).toBe(-1); expect(layer.getBrightness()).to.be(-1);
}); });
}); });
@@ -131,17 +131,17 @@ describe('ol.layer.Layer', function() {
it('accepts a small positive number', function() { it('accepts a small positive number', function() {
layer.setContrast(0.3); layer.setContrast(0.3);
expect(layer.getContrast()).toBe(0.3); expect(layer.getContrast()).to.be(0.3);
}); });
it('clamps to 0', function() { it('clamps to 0', function() {
layer.setContrast(-0.7); layer.setContrast(-0.7);
expect(layer.getContrast()).toBe(0); expect(layer.getContrast()).to.be(0);
}); });
it('accepts a big positive number', function() { it('accepts a big positive number', function() {
layer.setContrast(42); layer.setContrast(42);
expect(layer.getContrast()).toBe(42); expect(layer.getContrast()).to.be(42);
}); });
}); });
@@ -165,22 +165,22 @@ describe('ol.layer.Layer', function() {
it('accepts a small positive number', function() { it('accepts a small positive number', function() {
layer.setHue(0.3); layer.setHue(0.3);
expect(layer.getHue()).toBe(0.3); expect(layer.getHue()).to.be(0.3);
}); });
it('accepts a small negative number', function() { it('accepts a small negative number', function() {
layer.setHue(-0.7); layer.setHue(-0.7);
expect(layer.getHue()).toBe(-0.7); expect(layer.getHue()).to.be(-0.7);
}); });
it('accepts a big positive number', function() { it('accepts a big positive number', function() {
layer.setHue(42); layer.setHue(42);
expect(layer.getHue()).toBe(42); expect(layer.getHue()).to.be(42);
}); });
it('accepts a big negative number', function() { it('accepts a big negative number', function() {
layer.setHue(-100); layer.setHue(-100);
expect(layer.getHue()).toBe(-100); expect(layer.getHue()).to.be(-100);
}); });
}); });
@@ -204,17 +204,17 @@ describe('ol.layer.Layer', function() {
it('accepts a positive number', function() { it('accepts a positive number', function() {
layer.setOpacity(0.3); layer.setOpacity(0.3);
expect(layer.getOpacity()).toBe(0.3); expect(layer.getOpacity()).to.be(0.3);
}); });
it('clamps to 0', function() { it('clamps to 0', function() {
layer.setOpacity(-1.5); layer.setOpacity(-1.5);
expect(layer.getOpacity()).toBe(0); expect(layer.getOpacity()).to.be(0);
}); });
it('clamps to 1', function() { it('clamps to 1', function() {
layer.setOpacity(3); layer.setOpacity(3);
expect(layer.getOpacity()).toBe(1); expect(layer.getOpacity()).to.be(1);
}); });
}); });
@@ -238,17 +238,17 @@ describe('ol.layer.Layer', function() {
it('accepts a small positive number', function() { it('accepts a small positive number', function() {
layer.setSaturation(0.3); layer.setSaturation(0.3);
expect(layer.getSaturation()).toBe(0.3); expect(layer.getSaturation()).to.be(0.3);
}); });
it('clamps to 0', function() { it('clamps to 0', function() {
layer.setSaturation(-0.7); layer.setSaturation(-0.7);
expect(layer.getSaturation()).toBe(0); expect(layer.getSaturation()).to.be(0);
}); });
it('accepts a big positive number', function() { it('accepts a big positive number', function() {
layer.setSaturation(42); layer.setSaturation(42);
expect(layer.getSaturation()).toBe(42); expect(layer.getSaturation()).to.be(42);
}); });
}); });
@@ -264,10 +264,10 @@ describe('ol.layer.Layer', function() {
}); });
layer.setVisible(false); layer.setVisible(false);
expect(layer.getVisible()).toBe(false); expect(layer.getVisible()).to.be(false);
layer.setVisible(true); layer.setVisible(true);
expect(layer.getVisible()).toBe(true); expect(layer.getVisible()).to.be(true);
layer.dispose(); layer.dispose();
}); });

View File

@@ -18,36 +18,36 @@ describe('ol.structs.LRUCache', function() {
describe('empty cache', function() { describe('empty cache', function() {
it('has size zero', function() { it('has size zero', function() {
expect(lruCache.getCount()).toEqual(0); expect(lruCache.getCount()).to.eql(0);
}); });
it('has no keys', function() { it('has no keys', function() {
expect(lruCache.getKeys()).toEqual([]); expect(lruCache.getKeys()).to.eql([]);
}); });
it('has no values', function() { it('has no values', function() {
expect(lruCache.getValues()).toEqual([]); expect(lruCache.getValues()).to.eql([]);
}); });
}); });
describe('populating', function() { describe('populating', function() {
it('returns the correct size', function() { it('returns the correct size', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(lruCache.getCount()).toEqual(4); expect(lruCache.getCount()).to.eql(4);
}); });
it('contains the correct keys in the correct order', function() { it('contains the correct keys in the correct order', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(lruCache.getKeys()).toEqual(['d', 'c', 'b', 'a']); expect(lruCache.getKeys()).to.eql(['d', 'c', 'b', 'a']);
}); });
it('contains the correct values in the correct order', function() { it('contains the correct values in the correct order', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(lruCache.getValues()).toEqual([3, 2, 1, 0]); expect(lruCache.getValues()).to.eql([3, 2, 1, 0]);
}); });
it('reports which keys are contained', function() { it('reports which keys are contained', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(lruCache.containsKey('a')).toBeTruthy(); expect(lruCache.containsKey('a')).to.be.ok();
expect(lruCache.containsKey('b')).toBeTruthy(); expect(lruCache.containsKey('b')).to.be.ok();
expect(lruCache.containsKey('c')).toBeTruthy(); expect(lruCache.containsKey('c')).to.be.ok();
expect(lruCache.containsKey('d')).toBeTruthy(); expect(lruCache.containsKey('d')).to.be.ok();
expect(lruCache.containsKey('e')).toBeFalsy(); expect(lruCache.containsKey('e')).to.not.be();
}); });
}); });
@@ -55,9 +55,9 @@ describe('ol.structs.LRUCache', function() {
it('moves the key to newest position', function() { it('moves the key to newest position', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
lruCache.get('a'); lruCache.get('a');
expect(lruCache.getCount()).toEqual(4); expect(lruCache.getCount()).to.eql(4);
expect(lruCache.getKeys()).toEqual(['a', 'd', 'c', 'b']); expect(lruCache.getKeys()).to.eql(['a', 'd', 'c', 'b']);
expect(lruCache.getValues()).toEqual([0, 3, 2, 1]); expect(lruCache.getValues()).to.eql([0, 3, 2, 1]);
}); });
}); });
@@ -65,9 +65,9 @@ describe('ol.structs.LRUCache', function() {
it('moves the key to newest position', function() { it('moves the key to newest position', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
lruCache.get('b'); lruCache.get('b');
expect(lruCache.getCount()).toEqual(4); expect(lruCache.getCount()).to.eql(4);
expect(lruCache.getKeys()).toEqual(['b', 'd', 'c', 'a']); expect(lruCache.getKeys()).to.eql(['b', 'd', 'c', 'a']);
expect(lruCache.getValues()).toEqual([1, 3, 2, 0]); expect(lruCache.getValues()).to.eql([1, 3, 2, 0]);
}); });
}); });
@@ -75,9 +75,9 @@ describe('ol.structs.LRUCache', function() {
it('maintains the key to newest position', function() { it('maintains the key to newest position', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
lruCache.get('d'); lruCache.get('d');
expect(lruCache.getCount()).toEqual(4); expect(lruCache.getCount()).to.eql(4);
expect(lruCache.getKeys()).toEqual(['d', 'c', 'b', 'a']); expect(lruCache.getKeys()).to.eql(['d', 'c', 'b', 'a']);
expect(lruCache.getValues()).toEqual([3, 2, 1, 0]); expect(lruCache.getValues()).to.eql([3, 2, 1, 0]);
}); });
}); });
@@ -85,8 +85,8 @@ describe('ol.structs.LRUCache', function() {
it('adds it as the newest value', function() { it('adds it as the newest value', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
lruCache.set('e', 4); lruCache.set('e', 4);
expect(lruCache.getKeys()).toEqual(['e', 'd', 'c', 'b', 'a']); expect(lruCache.getKeys()).to.eql(['e', 'd', 'c', 'b', 'a']);
expect(lruCache.getValues()).toEqual([4, 3, 2, 1, 0]); expect(lruCache.getValues()).to.eql([4, 3, 2, 1, 0]);
}); });
}); });
@@ -95,7 +95,7 @@ describe('ol.structs.LRUCache', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(function() { expect(function() {
lruCache.set('a', 0); lruCache.set('a', 0);
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -103,76 +103,76 @@ describe('ol.structs.LRUCache', function() {
it('setting raises an exception', function() { it('setting raises an exception', function() {
expect(function() { expect(function() {
lruCache.set('constructor', 0); lruCache.set('constructor', 0);
}).toThrow(); }).to.throwException();
expect(function() { expect(function() {
lruCache.set('hasOwnProperty', 0); lruCache.set('hasOwnProperty', 0);
}).toThrow(); }).to.throwException();
expect(function() { expect(function() {
lruCache.set('isPrototypeOf', 0); lruCache.set('isPrototypeOf', 0);
}).toThrow(); }).to.throwException();
expect(function() { expect(function() {
lruCache.set('propertyIsEnumerable', 0); lruCache.set('propertyIsEnumerable', 0);
}).toThrow(); }).to.throwException();
expect(function() { expect(function() {
lruCache.set('toLocaleString', 0); lruCache.set('toLocaleString', 0);
}).toThrow(); }).to.throwException();
expect(function() { expect(function() {
lruCache.set('toString', 0); lruCache.set('toString', 0);
}).toThrow(); }).to.throwException();
expect(function() { expect(function() {
lruCache.set('valueOf', 0); lruCache.set('valueOf', 0);
}).toThrow(); }).to.throwException();
}); });
it('getting returns false', function() { it('getting returns false', function() {
expect(lruCache.containsKey('constructor')).toBeFalsy(); expect(lruCache.containsKey('constructor')).to.not.be();
expect(lruCache.containsKey('hasOwnProperty')).toBeFalsy(); expect(lruCache.containsKey('hasOwnProperty')).to.not.be();
expect(lruCache.containsKey('isPrototypeOf')).toBeFalsy(); expect(lruCache.containsKey('isPrototypeOf')).to.not.be();
expect(lruCache.containsKey('propertyIsEnumerable')).toBeFalsy(); expect(lruCache.containsKey('propertyIsEnumerable')).to.not.be();
expect(lruCache.containsKey('toLocaleString')).toBeFalsy(); expect(lruCache.containsKey('toLocaleString')).to.not.be();
expect(lruCache.containsKey('toString')).toBeFalsy(); expect(lruCache.containsKey('toString')).to.not.be();
expect(lruCache.containsKey('valueOf')).toBeFalsy(); expect(lruCache.containsKey('valueOf')).to.not.be();
}); });
}); });
describe('popping a value', function() { describe('popping a value', function() {
it('returns the least-recent-used value', function() { it('returns the least-recent-used value', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(lruCache.pop()).toEqual(0); expect(lruCache.pop()).to.eql(0);
expect(lruCache.getCount()).toEqual(3); expect(lruCache.getCount()).to.eql(3);
expect(lruCache.containsKey('a')).toBeFalsy(); expect(lruCache.containsKey('a')).to.not.be();
expect(lruCache.pop()).toEqual(1); expect(lruCache.pop()).to.eql(1);
expect(lruCache.getCount()).toEqual(2); expect(lruCache.getCount()).to.eql(2);
expect(lruCache.containsKey('b')).toBeFalsy(); expect(lruCache.containsKey('b')).to.not.be();
expect(lruCache.pop()).toEqual(2); expect(lruCache.pop()).to.eql(2);
expect(lruCache.getCount()).toEqual(1); expect(lruCache.getCount()).to.eql(1);
expect(lruCache.containsKey('c')).toBeFalsy(); expect(lruCache.containsKey('c')).to.not.be();
expect(lruCache.pop()).toEqual(3); expect(lruCache.pop()).to.eql(3);
expect(lruCache.getCount()).toEqual(0); expect(lruCache.getCount()).to.eql(0);
expect(lruCache.containsKey('d')).toBeFalsy(); expect(lruCache.containsKey('d')).to.not.be();
}); });
}); });
describe('peeking at the last value', function() { describe('peeking at the last value', function() {
it('returns the last key', function() { it('returns the last key', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(lruCache.peekLast()).toEqual(0); expect(lruCache.peekLast()).to.eql(0);
}); });
it('throws an exception when the cache is empty', function() { it('throws an exception when the cache is empty', function() {
expect(function() { expect(function() {
lruCache.peekLast(); lruCache.peekLast();
}).toThrow(); }).to.throwException();
}); });
}); });
describe('peeking at the last key', function() { describe('peeking at the last key', function() {
it('returns the last key', function() { it('returns the last key', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
expect(lruCache.peekLastKey()).toEqual('a'); expect(lruCache.peekLastKey()).to.eql('a');
}); });
it('throws an exception when the cache is empty', function() { it('throws an exception when the cache is empty', function() {
expect(function() { expect(function() {
lruCache.peekLastKey(); lruCache.peekLastKey();
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -180,9 +180,9 @@ describe('ol.structs.LRUCache', function() {
it('clears the cache', function() { it('clears the cache', function() {
fillLRUCache(lruCache); fillLRUCache(lruCache);
lruCache.clear(); lruCache.clear();
expect(lruCache.getCount()).toEqual(0); expect(lruCache.getCount()).to.eql(0);
expect(lruCache.getKeys()).toEqual([]); expect(lruCache.getKeys()).to.eql([]);
expect(lruCache.getValues()).toEqual([]); expect(lruCache.getValues()).to.eql([]);
}); });
}); });

View File

@@ -19,31 +19,31 @@ describe('ol.RendererHints', function() {
it('returns defaults when no query string', function() { it('returns defaults when no query string', function() {
goog.global.location = {search: ''}; goog.global.location = {search: ''};
var hints = ol.RendererHints.createFromQueryData(); var hints = ol.RendererHints.createFromQueryData();
expect(hints).toBe(ol.DEFAULT_RENDERER_HINTS); expect(hints).to.be(ol.DEFAULT_RENDERER_HINTS);
}); });
it('returns defaults when no "renderer" or "renderers"', function() { it('returns defaults when no "renderer" or "renderers"', function() {
goog.global.location = {search: '?foo=bar'}; goog.global.location = {search: '?foo=bar'};
var hints = ol.RendererHints.createFromQueryData(); var hints = ol.RendererHints.createFromQueryData();
expect(hints).toBe(ol.DEFAULT_RENDERER_HINTS); expect(hints).to.be(ol.DEFAULT_RENDERER_HINTS);
}); });
it('returns array of one for "renderer"', function() { it('returns array of one for "renderer"', function() {
goog.global.location = {search: '?renderer=bogus'}; goog.global.location = {search: '?renderer=bogus'};
var hints = ol.RendererHints.createFromQueryData(); var hints = ol.RendererHints.createFromQueryData();
expect(hints).toEqual(['bogus']); expect(hints).to.eql(['bogus']);
}); });
it('accepts comma delimited list for "renderers"', function() { it('accepts comma delimited list for "renderers"', function() {
goog.global.location = {search: '?renderers=one,two'}; goog.global.location = {search: '?renderers=one,two'};
var hints = ol.RendererHints.createFromQueryData(); var hints = ol.RendererHints.createFromQueryData();
expect(hints).toEqual(['one', 'two']); expect(hints).to.eql(['one', 'two']);
}); });
it('works with "renderer" in second position', function() { it('works with "renderer" in second position', function() {
goog.global.location = {search: '?foo=bar&renderer=one'}; goog.global.location = {search: '?foo=bar&renderer=one'};
var hints = ol.RendererHints.createFromQueryData(); var hints = ol.RendererHints.createFromQueryData();
expect(hints).toEqual(['one']); expect(hints).to.eql(['one']);
}); });
}); });
@@ -62,7 +62,7 @@ describe('ol.Map', function() {
it('removes the viewport from its parent', function() { it('removes the viewport from its parent', function() {
map.dispose(); map.dispose();
expect(goog.dom.getParentElement(map.getViewport())).toBeNull(); expect(goog.dom.getParentElement(map.getViewport())).to.be(null);
}); });
}); });
@@ -88,8 +88,8 @@ describe('ol.Map', function() {
it('creates mousewheel interaction', function() { it('creates mousewheel interaction', function() {
options.mouseWheelZoom = true; options.mouseWheelZoom = true;
var interactions = ol.interaction.defaults(options); var interactions = ol.interaction.defaults(options);
expect(interactions.getLength()).toEqual(1); expect(interactions.getLength()).to.eql(1);
expect(interactions.getAt(0)).toBeA(ol.interaction.MouseWheelZoom); expect(interactions.getAt(0)).to.be.a(ol.interaction.MouseWheelZoom);
}); });
}); });
@@ -102,9 +102,9 @@ describe('ol.Map', function() {
describe('default zoomDelta', function() { describe('default zoomDelta', function() {
it('create double click interaction with default delta', function() { it('create double click interaction with default delta', function() {
var interactions = ol.interaction.defaults(options); var interactions = ol.interaction.defaults(options);
expect(interactions.getLength()).toEqual(1); expect(interactions.getLength()).to.eql(1);
expect(interactions.getAt(0)).toBeA(ol.interaction.DblClickZoom); expect(interactions.getAt(0)).to.be.a(ol.interaction.DblClickZoom);
expect(interactions.getAt(0).delta_).toEqual(1); expect(interactions.getAt(0).delta_).to.eql(1);
}); });
}); });
@@ -112,9 +112,9 @@ describe('ol.Map', function() {
it('create double click interaction with set delta', function() { it('create double click interaction with set delta', function() {
options.zoomDelta = 7; options.zoomDelta = 7;
var interactions = ol.interaction.defaults(options); var interactions = ol.interaction.defaults(options);
expect(interactions.getLength()).toEqual(1); expect(interactions.getLength()).to.eql(1);
expect(interactions.getAt(0)).toBeA(ol.interaction.DblClickZoom); expect(interactions.getAt(0)).to.be.a(ol.interaction.DblClickZoom);
expect(interactions.getAt(0).delta_).toEqual(7); expect(interactions.getAt(0).delta_).to.eql(7);
}); });
}); });
}); });
@@ -125,8 +125,8 @@ describe('ol.Map', function() {
var layer, map; var layer, map;
beforeEach(function() { beforeEach(function() {
// always use setTimeout based shim for requestAnimationFrame // always use setTimeout based shim for requestAnimationFrame
spyOn(goog.async.AnimationDelay.prototype, 'getRaf_') sinon.stub(goog.async.AnimationDelay.prototype, 'getRaf_',
.andCallFake(function() {return null;}); function() {return null;});
layer = new ol.layer.TileLayer({ layer = new ol.layer.TileLayer({
source: new ol.source.XYZ({ source: new ol.source.XYZ({
@@ -151,7 +151,7 @@ describe('ol.Map', function() {
layer.dispose(); layer.dispose();
}); });
it('can set up an animation loop', function() { it('can set up an animation loop', function(done) {
function quadInOut(t, b, c, d) { function quadInOut(t, b, c, d) {
if ((t /= d / 2) < 1) { if ((t /= d / 2) < 1) {
@@ -189,7 +189,7 @@ describe('ol.Map', function() {
} }
}; };
spyOn(o, 'callback').andCallThrough(); sinon.spy(o, 'callback');
var animationDelay = new goog.async.AnimationDelay(o.callback); var animationDelay = new goog.async.AnimationDelay(o.callback);
@@ -197,25 +197,24 @@ describe('ol.Map', function() {
// confirm that the center is somewhere between origin and destination // confirm that the center is somewhere between origin and destination
// after a short delay // after a short delay
waits(goog.async.AnimationDelay.TIMEOUT); setTimeout(function() {
runs(function() { expect(o.callback.called).to.be.ok();
expect(o.callback).toHaveBeenCalled();
var loc = map.getView().getCenter(); var loc = map.getView().getCenter();
expect(loc.x).not.toEqual(origin.x); expect(loc.x).not.to.eql(origin.x);
expect(loc.y).not.toEqual(origin.y); expect(loc.y).not.to.eql(origin.y);
if (new Date().getTime() - start < duration) { if (new Date().getTime() - start < duration) {
expect(loc.x).not.toEqual(destination.x); expect(loc.x).not.to.eql(destination.x);
expect(loc.y).not.toEqual(destination.y); expect(loc.y).not.to.eql(destination.y);
} }
}); }, goog.async.AnimationDelay.TIMEOUT);
// confirm that the map has reached the destination after the duration // confirm that the map has reached the destination after the duration
waits(duration); setTimeout(function() {
runs(function() {
var loc = map.getView().getCenter(); var loc = map.getView().getCenter();
expect(loc.x).toEqual(destination.x); expect(loc.x).to.eql(destination.x);
expect(loc.y).toEqual(destination.y); expect(loc.y).to.eql(destination.y);
}); done();
}, duration + goog.async.AnimationDelay.TIMEOUT);
}); });

View File

@@ -4,23 +4,23 @@ goog.provide('ol.test.math');
describe('ol.math.cosh', function() { describe('ol.math.cosh', function() {
it('returns the correct value at -Infinity', function() { it('returns the correct value at -Infinity', function() {
expect(ol.math.cosh(-Infinity)).toEqual(Infinity); expect(ol.math.cosh(-Infinity)).to.eql(Infinity);
}); });
it('returns the correct value at -1', function() { it('returns the correct value at -1', function() {
expect(ol.math.cosh(-1)).toRoughlyEqual(1.5430806348152437, 1e-9); expect(ol.math.cosh(-1)).to.roughlyEqual(1.5430806348152437, 1e-9);
}); });
it('returns the correct value at 0', function() { it('returns the correct value at 0', function() {
expect(ol.math.cosh(0)).toEqual(1); expect(ol.math.cosh(0)).to.eql(1);
}); });
it('returns the correct value at 1', function() { it('returns the correct value at 1', function() {
expect(ol.math.cosh(1)).toRoughlyEqual(1.5430806348152437, 1e-9); expect(ol.math.cosh(1)).to.roughlyEqual(1.5430806348152437, 1e-9);
}); });
it('returns the correct value at Infinity', function() { it('returns the correct value at Infinity', function() {
expect(ol.math.cosh(Infinity)).toEqual(Infinity); expect(ol.math.cosh(Infinity)).to.eql(Infinity);
}); });
}); });
@@ -29,15 +29,15 @@ describe('ol.math.cosh', function() {
describe('ol.math.coth', function() { describe('ol.math.coth', function() {
it('returns the correct value at -1', function() { it('returns the correct value at -1', function() {
expect(ol.math.coth(-1)).toRoughlyEqual(-1.3130352854993312, 1e-9); expect(ol.math.coth(-1)).to.roughlyEqual(-1.3130352854993312, 1e-9);
}); });
it('returns the correct value at 1', function() { it('returns the correct value at 1', function() {
expect(ol.math.coth(1)).toRoughlyEqual(1.3130352854993312, 1e-9); expect(ol.math.coth(1)).to.roughlyEqual(1.3130352854993312, 1e-9);
}); });
it('returns the correct value at Infinity', function() { it('returns the correct value at Infinity', function() {
expect(ol.math.coth(Infinity)).toEqual(1); expect(ol.math.coth(Infinity)).to.eql(1);
}); });
}); });
@@ -46,19 +46,19 @@ describe('ol.math.coth', function() {
describe('ol.math.csch', function() { describe('ol.math.csch', function() {
it('returns the correct value at -Infinity', function() { it('returns the correct value at -Infinity', function() {
expect(ol.math.csch(-Infinity)).toEqual(0); expect(ol.math.csch(-Infinity)).to.eql(0);
}); });
it('returns the correct value at -1', function() { it('returns the correct value at -1', function() {
expect(ol.math.csch(-1)).toRoughlyEqual(-0.85091812823932156, 1e-9); expect(ol.math.csch(-1)).to.roughlyEqual(-0.85091812823932156, 1e-9);
}); });
it('returns the correct value at 1', function() { it('returns the correct value at 1', function() {
expect(ol.math.csch(1)).toRoughlyEqual(0.85091812823932156, 1e-9); expect(ol.math.csch(1)).to.roughlyEqual(0.85091812823932156, 1e-9);
}); });
it('returns the correct value at Infinity', function() { it('returns the correct value at Infinity', function() {
expect(ol.math.csch(Infinity)).toEqual(0); expect(ol.math.csch(Infinity)).to.eql(0);
}); });
}); });
@@ -67,23 +67,23 @@ describe('ol.math.csch', function() {
describe('ol.math.sech', function() { describe('ol.math.sech', function() {
it('returns the correct value at -Infinity', function() { it('returns the correct value at -Infinity', function() {
expect(ol.math.sech(-Infinity)).toEqual(0); expect(ol.math.sech(-Infinity)).to.eql(0);
}); });
it('returns the correct value at -1', function() { it('returns the correct value at -1', function() {
expect(ol.math.sech(-1)).toRoughlyEqual(0.64805427366388535, 1e-9); expect(ol.math.sech(-1)).to.roughlyEqual(0.64805427366388535, 1e-9);
}); });
it('returns the correct value at 0', function() { it('returns the correct value at 0', function() {
expect(ol.math.sech(0)).toEqual(1); expect(ol.math.sech(0)).to.eql(1);
}); });
it('returns the correct value at 1', function() { it('returns the correct value at 1', function() {
expect(ol.math.sech(1)).toRoughlyEqual(0.64805427366388535, 1e-9); expect(ol.math.sech(1)).to.roughlyEqual(0.64805427366388535, 1e-9);
}); });
it('returns the correct value at Infinity', function() { it('returns the correct value at Infinity', function() {
expect(ol.math.sech(Infinity)).toEqual(0); expect(ol.math.sech(Infinity)).to.eql(0);
}); });
}); });
@@ -92,23 +92,23 @@ describe('ol.math.sech', function() {
describe('ol.math.sinh', function() { describe('ol.math.sinh', function() {
it('returns the correct value at -Infinity', function() { it('returns the correct value at -Infinity', function() {
expect(ol.math.sinh(-Infinity)).toEqual(-Infinity); expect(ol.math.sinh(-Infinity)).to.eql(-Infinity);
}); });
it('returns the correct value at -1', function() { it('returns the correct value at -1', function() {
expect(ol.math.sinh(-1)).toRoughlyEqual(-1.1752011936438014, 1e-9); expect(ol.math.sinh(-1)).to.roughlyEqual(-1.1752011936438014, 1e-9);
}); });
it('returns the correct value at 0', function() { it('returns the correct value at 0', function() {
expect(ol.math.sinh(0)).toEqual(0); expect(ol.math.sinh(0)).to.eql(0);
}); });
it('returns the correct value at 1', function() { it('returns the correct value at 1', function() {
expect(ol.math.sinh(1)).toRoughlyEqual(1.1752011936438014, 1e-9); expect(ol.math.sinh(1)).to.roughlyEqual(1.1752011936438014, 1e-9);
}); });
it('returns the correct value at Infinity', function() { it('returns the correct value at Infinity', function() {
expect(ol.math.cosh(Infinity)).toEqual(Infinity); expect(ol.math.cosh(Infinity)).to.eql(Infinity);
}); });
}); });
@@ -117,15 +117,15 @@ describe('ol.math.sinh', function() {
describe('ol.math.tanh', function() { describe('ol.math.tanh', function() {
it('returns the correct value at -1', function() { it('returns the correct value at -1', function() {
expect(ol.math.tanh(-1)).toRoughlyEqual(-0.76159415595576485, 1e-9); expect(ol.math.tanh(-1)).to.roughlyEqual(-0.76159415595576485, 1e-9);
}); });
it('returns the correct value at 0', function() { it('returns the correct value at 0', function() {
expect(ol.math.tanh(0)).toEqual(0); expect(ol.math.tanh(0)).to.eql(0);
}); });
it('returns the correct value at 1', function() { it('returns the correct value at 1', function() {
expect(ol.math.tanh(1)).toRoughlyEqual(0.76159415595576485, 1e-9); expect(ol.math.tanh(1)).to.roughlyEqual(0.76159415595576485, 1e-9);
}); });
}); });

View File

@@ -16,7 +16,7 @@ describe('ol.Object', function() {
}); });
it('returns undefined', function() { it('returns undefined', function() {
expect(v).toBeUndefined(); expect(v).to.be(undefined);
}); });
}); });
@@ -29,7 +29,7 @@ describe('ol.Object', function() {
}); });
it('returns expected value', function() { it('returns expected value', function() {
expect(v).toEqual(1); expect(v).to.eql(1);
}); });
}); });
}); });
@@ -38,13 +38,13 @@ describe('ol.Object', function() {
it('does not return values that are not explicitly set', function() { it('does not return values that are not explicitly set', function() {
var o = new ol.Object(); var o = new ol.Object();
expect(o.get('constructor')).toBeUndefined(); expect(o.get('constructor')).to.be(undefined);
expect(o.get('hasOwnProperty')).toBeUndefined(); expect(o.get('hasOwnProperty')).to.be(undefined);
expect(o.get('isPrototypeOf')).toBeUndefined(); expect(o.get('isPrototypeOf')).to.be(undefined);
expect(o.get('propertyIsEnumerable')).toBeUndefined(); expect(o.get('propertyIsEnumerable')).to.be(undefined);
expect(o.get('toLocaleString')).toBeUndefined(); expect(o.get('toLocaleString')).to.be(undefined);
expect(o.get('toString')).toBeUndefined(); expect(o.get('toString')).to.be(undefined);
expect(o.get('valueOf')).toBeUndefined(); expect(o.get('valueOf')).to.be(undefined);
}); });
}); });
@@ -54,14 +54,14 @@ describe('ol.Object', function() {
var o = new ol.Object(); var o = new ol.Object();
o.set('set', 'sat'); o.set('set', 'sat');
expect(o.get('set')).toBe('sat'); expect(o.get('set')).to.be('sat');
o.set('get', 'got'); o.set('get', 'got');
expect(o.get('get')).toBe('got'); expect(o.get('get')).to.be('got');
o.set('toString', 'string'); o.set('toString', 'string');
expect(o.get('toString')).toBe('string'); expect(o.get('toString')).to.be('string');
expect(typeof o.toString).toBe('function'); expect(typeof o.toString).to.be('function');
}); });
}); });
@@ -76,8 +76,8 @@ describe('ol.Object', function() {
}); });
var keys = o.getKeys(); var keys = o.getKeys();
expect(keys.length).toBe(4); expect(keys.length).to.be(4);
expect(keys.sort()).toEqual(['get', 'prop1', 'prop2', 'toString']); expect(keys.sort()).to.eql(['get', 'prop1', 'prop2', 'toString']);
}); });
}); });
@@ -89,11 +89,11 @@ describe('ol.Object', function() {
k1: 1, k1: 1,
k2: 2 k2: 2
}); });
expect(o.get('k1')).toEqual(1); expect(o.get('k1')).to.eql(1);
expect(o.get('k2')).toEqual(2); expect(o.get('k2')).to.eql(2);
var keys = o.getKeys().sort(); var keys = o.getKeys().sort();
expect(keys).toEqual(['k1', 'k2']); expect(keys).to.eql(['k1', 'k2']);
}); });
}); });
@@ -102,31 +102,31 @@ describe('ol.Object', function() {
var listener1, listener2, listener3; var listener1, listener2, listener3;
beforeEach(function() { beforeEach(function() {
listener1 = jasmine.createSpy(); listener1 = sinon.spy();
goog.events.listen(o, 'k_changed', listener1); goog.events.listen(o, 'k_changed', listener1);
listener2 = jasmine.createSpy(); listener2 = sinon.spy();
goog.events.listen(o, 'changed', listener2); goog.events.listen(o, 'changed', listener2);
var o2 = new ol.Object(); var o2 = new ol.Object();
o2.bindTo('k', o); o2.bindTo('k', o);
listener3 = jasmine.createSpy(); listener3 = sinon.spy();
goog.events.listen(o2, 'k_changed', listener3); goog.events.listen(o2, 'k_changed', listener3);
}); });
it('dispatches events', function() { it('dispatches events', function() {
o.notify('k'); o.notify('k');
expect(listener1).toHaveBeenCalled(); expect(listener1.called).to.be.ok();
}); });
it('dispatches generic change events to bound objects', function() { it('dispatches generic change events to bound objects', function() {
o.notify('k'); o.notify('k');
expect(listener2).toHaveBeenCalled(); expect(listener2.called).to.be.ok();
}); });
it('dispatches events to bound objects', function() { it('dispatches events to bound objects', function() {
o.notify('k'); o.notify('k');
expect(listener3).toHaveBeenCalled(); expect(listener3.called).to.be.ok();
}); });
}); });
@@ -135,47 +135,47 @@ describe('ol.Object', function() {
var listener1, o2, listener2, listener3; var listener1, o2, listener2, listener3;
beforeEach(function() { beforeEach(function() {
listener1 = jasmine.createSpy(); listener1 = sinon.spy();
goog.events.listen(o, 'k_changed', listener1); goog.events.listen(o, 'k_changed', listener1);
listener2 = jasmine.createSpy(); listener2 = sinon.spy();
goog.events.listen(o, 'changed', listener2); goog.events.listen(o, 'changed', listener2);
o2 = new ol.Object(); o2 = new ol.Object();
o2.bindTo('k', o); o2.bindTo('k', o);
listener3 = jasmine.createSpy(); listener3 = sinon.spy();
goog.events.listen(o2, 'k_changed', listener3); goog.events.listen(o2, 'k_changed', listener3);
}); });
it('dispatches events to object', function() { it('dispatches events to object', function() {
o.set('k', 1); o.set('k', 1);
expect(listener1).toHaveBeenCalled(); expect(listener1.called).to.be.ok();
expect(o.getKeys()).toEqual(['k']); expect(o.getKeys()).to.eql(['k']);
expect(o2.getKeys()).toEqual(['k']); expect(o2.getKeys()).to.eql(['k']);
}); });
it('dispatches generic change events to object', function() { it('dispatches generic change events to object', function() {
o.set('k', 1); o.set('k', 1);
expect(listener2).toHaveBeenCalled(); expect(listener2.called).to.be.ok();
}); });
it('dispatches events to bound object', function() { it('dispatches events to bound object', function() {
o.set('k', 1); o.set('k', 1);
expect(listener3).toHaveBeenCalled(); expect(listener3.called).to.be.ok();
}); });
it('dispatches events to object bound to', function() { it('dispatches events to object bound to', function() {
o2.set('k', 2); o2.set('k', 2);
expect(listener1).toHaveBeenCalled(); expect(listener1.called).to.be.ok();
expect(o.getKeys()).toEqual(['k']); expect(o.getKeys()).to.eql(['k']);
expect(o2.getKeys()).toEqual(['k']); expect(o2.getKeys()).to.eql(['k']);
}); });
it('dispatches generic change events to object bound to', function() { it('dispatches generic change events to object bound to', function() {
o2.set('k', 2); o2.set('k', 2);
expect(listener2).toHaveBeenCalled(); expect(listener2.called).to.be.ok();
}); });
}); });
@@ -192,11 +192,11 @@ describe('ol.Object', function() {
it('gets expected value', function() { it('gets expected value', function() {
o.set('k', 1); o.set('k', 1);
o2.bindTo('k', o); o2.bindTo('k', o);
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(1); expect(o2.get('k')).to.eql(1);
expect(o.getKeys()).toEqual(['k']); expect(o.getKeys()).to.eql(['k']);
expect(o2.getKeys()).toEqual(['k']); expect(o2.getKeys()).to.eql(['k']);
}); });
}); });
@@ -205,11 +205,11 @@ describe('ol.Object', function() {
it('gets expected value', function() { it('gets expected value', function() {
o2.bindTo('k', o); o2.bindTo('k', o);
o.set('k', 1); o.set('k', 1);
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(1); expect(o2.get('k')).to.eql(1);
expect(o.getKeys()).toEqual(['k']); expect(o.getKeys()).to.eql(['k']);
expect(o2.getKeys()).toEqual(['k']); expect(o2.getKeys()).to.eql(['k']);
}); });
}); });
@@ -219,8 +219,8 @@ describe('ol.Object', function() {
it('gets expected value', function() { it('gets expected value', function() {
o2.set('k', 1); o2.set('k', 1);
o2.bindTo('k', o); o2.bindTo('k', o);
expect(o.get('k')).toBeUndefined(); expect(o.get('k')).to.be(undefined);
expect(o2.get('k')).toBeUndefined(); expect(o2.get('k')).to.be(undefined);
}); });
}); });
@@ -229,8 +229,8 @@ describe('ol.Object', function() {
it('gets expected value', function() { it('gets expected value', function() {
o2.bindTo('k', o); o2.bindTo('k', o);
o2.set('k', 1); o2.set('k', 1);
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(1); expect(o2.get('k')).to.eql(1);
}); });
}); });
}); });
@@ -247,14 +247,14 @@ describe('ol.Object', function() {
it('makes changes to unbound object invisible to other object', function() { it('makes changes to unbound object invisible to other object', function() {
// initial state // initial state
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(1); expect(o2.get('k')).to.eql(1);
o2.unbind('k'); o2.unbind('k');
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(1); expect(o2.get('k')).to.eql(1);
o2.set('k', 2); o2.set('k', 2);
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(2); expect(o2.get('k')).to.eql(2);
}); });
}); });
@@ -269,14 +269,14 @@ describe('ol.Object', function() {
it('makes changes to unbound object invisible to other object', function() { it('makes changes to unbound object invisible to other object', function() {
// initial state // initial state
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(1); expect(o2.get('k')).to.eql(1);
o2.unbindAll(); o2.unbindAll();
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(1); expect(o2.get('k')).to.eql(1);
o2.set('k', 2); o2.set('k', 2);
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o2.get('k')).toEqual(2); expect(o2.get('k')).to.eql(2);
}); });
}); });
@@ -287,24 +287,24 @@ describe('ol.Object', function() {
o2 = new ol.Object(); o2 = new ol.Object();
o2.bindTo('k2', o, 'k1'); o2.bindTo('k2', o, 'k1');
listener1 = jasmine.createSpy(); listener1 = sinon.spy();
goog.events.listen(o, 'k1_changed', listener1); goog.events.listen(o, 'k1_changed', listener1);
listener2 = jasmine.createSpy(); listener2 = sinon.spy();
goog.events.listen(o2, 'k2_changed', listener2); goog.events.listen(o2, 'k2_changed', listener2);
}); });
it('sets the expected properties', function() { it('sets the expected properties', function() {
o.set('k1', 1); o.set('k1', 1);
expect(o.get('k1')).toEqual(1); expect(o.get('k1')).to.eql(1);
expect(o.get('k2')).toBeUndefined(); expect(o.get('k2')).to.be(undefined);
expect(o2.get('k2')).toEqual(1); expect(o2.get('k2')).to.eql(1);
expect(o2.get('k1')).toBeUndefined(); expect(o2.get('k1')).to.be(undefined);
expect(listener1).toHaveBeenCalled(); expect(listener1.called).to.be.ok();
expect(listener2).toHaveBeenCalled(); expect(listener2.called).to.be.ok();
expect(o.getKeys()).toEqual(['k1']); expect(o.getKeys()).to.eql(['k1']);
expect(o2.getKeys()).toEqual(['k2']); expect(o2.getKeys()).to.eql(['k2']);
}); });
}); });
@@ -320,26 +320,26 @@ describe('ol.Object', function() {
it('sets the expected properties', function() { it('sets the expected properties', function() {
o.set('k1', 1); o.set('k1', 1);
expect(o.get('k1')).toEqual(1); expect(o.get('k1')).to.eql(1);
expect(o2.get('k2')).toEqual(1); expect(o2.get('k2')).to.eql(1);
expect(o3.get('k3')).toEqual(1); expect(o3.get('k3')).to.eql(1);
expect(o.getKeys()).toEqual(['k1']); expect(o.getKeys()).to.eql(['k1']);
expect(o2.getKeys()).toEqual(['k2']); expect(o2.getKeys()).to.eql(['k2']);
expect(o3.getKeys()).toEqual(['k3']); expect(o3.getKeys()).to.eql(['k3']);
}); });
describe('backward', function() { describe('backward', function() {
it('sets the expected properties', function() { it('sets the expected properties', function() {
o3.set('k3', 1); o3.set('k3', 1);
expect(o.get('k1')).toEqual(1); expect(o.get('k1')).to.eql(1);
expect(o2.get('k2')).toEqual(1); expect(o2.get('k2')).to.eql(1);
expect(o3.get('k3')).toEqual(1); expect(o3.get('k3')).to.eql(1);
expect(o.getKeys()).toEqual(['k1']); expect(o.getKeys()).to.eql(['k1']);
expect(o2.getKeys()).toEqual(['k2']); expect(o2.getKeys()).to.eql(['k2']);
expect(o3.getKeys()).toEqual(['k3']); expect(o3.getKeys()).to.eql(['k3']);
}); });
}); });
}); });
@@ -353,7 +353,7 @@ describe('ol.Object', function() {
}); });
it('throws an error', function() { it('throws an error', function() {
expect(function() { o2.bindTo('k', o); }).toThrow(); expect(function() { o2.bindTo('k', o); }).to.throwException();
}); });
}); });
@@ -368,15 +368,15 @@ describe('ol.Object', function() {
o.set('k', 1); o.set('k', 1);
o2.set('k', 2); o2.set('k', 2);
o.bindTo('k', o2); o.bindTo('k', o2);
expect(o.get('k')).toEqual(2); expect(o.get('k')).to.eql(2);
expect(o2.get('k')).toEqual(2); expect(o2.get('k')).to.eql(2);
}); });
it('respects set order (undefined)', function() { it('respects set order (undefined)', function() {
o.set('k', 1); o.set('k', 1);
o.bindTo('k', o2); o.bindTo('k', o2);
expect(o.get('k')).toBeUndefined(); expect(o.get('k')).to.be(undefined);
expect(o2.get('k')).toBeUndefined(); expect(o2.get('k')).to.be(undefined);
}); });
}); });
@@ -385,16 +385,16 @@ describe('ol.Object', function() {
o.setX = function(x) { o.setX = function(x) {
this.set('x', x); this.set('x', x);
}; };
spyOn(o, 'setX').andCallThrough(); sinon.spy(o, 'setX');
}); });
describe('without bind', function() { describe('without bind', function() {
it('does not call the setter', function() { it('does not call the setter', function() {
o.set('x', 1); o.set('x', 1);
expect(o.get('x')).toEqual(1); expect(o.get('x')).to.eql(1);
expect(o.setX).not.toHaveBeenCalled(); expect(o.setX.called).to.not.be.ok();
expect(o.getKeys()).toEqual(['x']); expect(o.getKeys()).to.eql(['x']);
}); });
}); });
@@ -403,11 +403,11 @@ describe('ol.Object', function() {
var o2 = new ol.Object(); var o2 = new ol.Object();
o2.bindTo('x', o); o2.bindTo('x', o);
o2.set('x', 1); o2.set('x', 1);
expect(o.setX).toHaveBeenCalled(); expect(o.setX.called).to.be.ok();
expect(o.get('x')).toEqual(1); expect(o.get('x')).to.eql(1);
expect(o.getKeys()).toEqual(['x']); expect(o.getKeys()).to.eql(['x']);
expect(o2.getKeys()).toEqual(['x']); expect(o2.getKeys()).to.eql(['x']);
}); });
}); });
}); });
@@ -417,13 +417,13 @@ describe('ol.Object', function() {
o.getX = function() { o.getX = function() {
return 1; return 1;
}; };
spyOn(o, 'getX').andCallThrough(); sinon.spy(o, 'getX');
}); });
describe('without bind', function() { describe('without bind', function() {
it('does not call the getter', function() { it('does not call the getter', function() {
expect(o.get('x')).toBeUndefined(); expect(o.get('x')).to.be(undefined);
expect(o.getX).not.toHaveBeenCalled(); expect(o.getX.called).to.not.be.ok();
}); });
}); });
@@ -431,27 +431,27 @@ describe('ol.Object', function() {
it('does call the getter', function() { it('does call the getter', function() {
var o2 = new ol.Object(); var o2 = new ol.Object();
o2.bindTo('x', o); o2.bindTo('x', o);
expect(o2.get('x')).toEqual(1); expect(o2.get('x')).to.eql(1);
expect(o.getX).toHaveBeenCalled(); expect(o.getX.called).to.be.ok();
expect(o.getKeys()).toEqual([]); expect(o.getKeys()).to.eql([]);
expect(o2.getKeys()).toEqual(['x']); expect(o2.getKeys()).to.eql(['x']);
}); });
}); });
}); });
describe('bind self', function() { describe('bind self', function() {
it('throws an error', function() { it('throws an error', function() {
expect(function() { o.bindTo('k', o); }).toThrow(); expect(function() { o.bindTo('k', o); }).to.throwException();
}); });
}); });
describe('create with options', function() { describe('create with options', function() {
it('sets the property', function() { it('sets the property', function() {
var o = new ol.Object({k: 1}); var o = new ol.Object({k: 1});
expect(o.get('k')).toEqual(1); expect(o.get('k')).to.eql(1);
expect(o.getKeys()).toEqual(['k']); expect(o.getKeys()).to.eql(['k']);
}); });
}); });
@@ -459,18 +459,18 @@ describe('ol.Object', function() {
var listener1, listener2; var listener1, listener2;
beforeEach(function() { beforeEach(function() {
listener1 = jasmine.createSpy(); listener1 = sinon.spy();
goog.events.listen(o, 'k_changed', listener1); goog.events.listen(o, 'k_changed', listener1);
listener2 = jasmine.createSpy(); listener2 = sinon.spy();
goog.events.listen(o, 'K_changed', listener2); goog.events.listen(o, 'K_changed', listener2);
}); });
it('dispatches the expected event', function() { it('dispatches the expected event', function() {
o.set('K', 1); o.set('K', 1);
expect(listener1).toHaveBeenCalled(); expect(listener1.called).to.be.ok();
expect(listener2).not.toHaveBeenCalled(); expect(listener2.called).to.not.be.ok();
expect(o.getKeys()).toEqual(['K']); expect(o.getKeys()).to.eql(['K']);
}); });
}); });
}); });

View File

@@ -1,31 +1,31 @@
goog.provide('ol.test.parser.ogc.ExceptionReport'); goog.provide('ol.test.parser.ogc.ExceptionReport');
describe('ol.parser.ogc.exceptionreport', function() { describe('ol.parser.ogc.exceptionreport', function() {
var parser = new ol.parser.ogc.ExceptionReport(); var parser = new ol.parser.ogc.ExceptionReport();
describe('test read exception', function() { describe('test read exception', function() {
it('OCG WMS 1.3.0 exceptions', function() { it('OCG WMS 1.3.0 exceptions', function(done) {
var result, exceptions; var result, exceptions;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/exceptionreport/wms1_3_0.xml'; var url = 'spec/ol/parser/ogc/xml/exceptionreport/wms1_3_0.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
result = parser.read(xhr.getResponseXml()); result = parser.read(xhr.getResponseXml());
exceptions = result.exceptionReport.exceptions; exceptions = result.exceptionReport.exceptions;
});
}); });
waitsFor(function() { waitsFor(function() {
return (result !== undefined); return (result !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(exceptions.length).to.be(4);
expect(exceptions.length).toBe(4);
var str = 'Plain text message about an error.'; var str = 'Plain text message about an error.';
expect(goog.string.trim(exceptions[0].text)).toBe(str); expect(goog.string.trim(exceptions[0].text)).to.be(str);
expect(exceptions[1].code).toBe('InvalidUpdateSequence'); expect(exceptions[1].code).to.be('InvalidUpdateSequence');
str = ' Another error message, this one with a service exception ' + str = ' Another error message, this one with a service exception ' +
'code supplied. '; 'code supplied. ';
expect(exceptions[1].text).toBe(str); expect(exceptions[1].text).to.be(str);
str = 'Error in module <foo.c>, line 42A message that includes angle ' + str = 'Error in module <foo.c>, line 42A message that includes angle ' +
'brackets in text must be enclosed in a Character Data Section as' + 'brackets in text must be enclosed in a Character Data Section as' +
' in this example. All XML-like markup is ignored except for this' + ' in this example. All XML-like markup is ignored except for this' +
@@ -37,55 +37,56 @@ describe('ol.parser.ogc.exceptionreport', function() {
'application-specific software may choose to process it.' + 'application-specific software may choose to process it.' +
'</Explanation>'; '</Explanation>';
expect(goog.string.trim(exceptions[3].text), str); expect(goog.string.trim(exceptions[3].text), str);
done();
}); });
}); });
it('test read exception OWSCommon 1.0.0', function() { it('test read exception OWSCommon 1.0.0', function(done) {
var result, report, exception; var result, report, exception;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_0_0.xml'; var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_0_0.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
result = parser.read(xhr.getResponseXml()); result = parser.read(xhr.getResponseXml());
report = result.exceptionReport; report = result.exceptionReport;
exception = report.exceptions[0]; exception = report.exceptions[0];
});
}); });
waitsFor(function() { waitsFor(function() {
return (result !== undefined); return (result !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(report.version).to.eql('1.0.0');
expect(report.version).toEqual('1.0.0'); expect(report.language).to.eql('en');
expect(report.language).toEqual('en'); expect(exception.code).to.eql('InvalidParameterValue');
expect(exception.code).toEqual('InvalidParameterValue'); expect(exception.locator).to.eql('foo');
expect(exception.locator).toEqual('foo');
var msg = 'Update error: Error occured updating features'; var msg = 'Update error: Error occured updating features';
expect(exception.texts[0]).toEqual(msg); expect(exception.texts[0]).to.eql(msg);
msg = 'Second exception line'; msg = 'Second exception line';
expect(exception.texts[1]).toEqual(msg); expect(exception.texts[1]).to.eql(msg);
done();
}); });
}); });
it('test read exception OWSCommon 1.1.0', function() { it('test read exception OWSCommon 1.1.0', function(done) {
var result, report, exception; var result, report, exception;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_1_0.xml'; var url = 'spec/ol/parser/ogc/xml/exceptionreport/ows1_1_0.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
result = parser.read(xhr.getResponseXml()); result = parser.read(xhr.getResponseXml());
report = result.exceptionReport; report = result.exceptionReport;
exception = report.exceptions[0]; exception = report.exceptions[0];
});
}); });
waitsFor(function() { waitsFor(function() {
return (result !== undefined); return (result !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(report.version).to.eql('1.1.0');
expect(report.version).toEqual('1.1.0'); expect(report.language).to.eql('en');
expect(report.language).toEqual('en'); expect(exception.code).to.eql('InvalidParameterValue');
expect(exception.code).toEqual('InvalidParameterValue'); expect(exception.locator).to.eql('foo');
expect(exception.locator).toEqual('foo');
var msg = 'Update error: Error occured updating features'; var msg = 'Update error: Error occured updating features';
expect(exception.texts[0]).toEqual(msg); expect(exception.texts[0]).to.eql(msg);
expect(exception.texts[1]).toEqual('Second exception line'); expect(exception.texts[1]).to.eql('Second exception line');
done();
}); });
}); });
}); });

View File

@@ -8,19 +8,19 @@ describe('ol.parser.ogc.versioned', function() {
describe('test constructor', function() { describe('test constructor', function() {
var parser = new ol.parser.ogc.Versioned({version: '1.0.0'}); var parser = new ol.parser.ogc.Versioned({version: '1.0.0'});
it('new OpenLayers.Format.XML.VersionedOGC returns object', function() { it('new OpenLayers.Format.XML.VersionedOGC returns object', function() {
expect(parser instanceof ol.parser.ogc.Versioned).toBeTruthy(); expect(parser instanceof ol.parser.ogc.Versioned).to.be.ok();
}); });
it('constructor sets version correctly', function() { it('constructor sets version correctly', function() {
expect(parser.version).toEqual('1.0.0'); expect(parser.version).to.eql('1.0.0');
}); });
it('defaultVersion should be null if not specified', function() { it('defaultVersion should be null if not specified', function() {
expect(parser.defaultVersion).toBeNull(); expect(parser.defaultVersion).to.be(null);
}); });
it('format has a read function', function() { it('format has a read function', function() {
expect(typeof(parser.read)).toEqual('function'); expect(typeof(parser.read)).to.eql('function');
}); });
it('format has a write function', function() { it('format has a write function', function() {
expect(typeof(parser.write)).toEqual('function'); expect(typeof(parser.write)).to.eql('function');
}); });
}); });
}); });

View File

@@ -10,34 +10,34 @@ describe('test WMSCapabilities', function() {
it('Version taken from document', function() { it('Version taken from document', function() {
var parser = new ol.parser.ogc.WMSCapabilities(); var parser = new ol.parser.ogc.WMSCapabilities();
var data = parser.read(snippet); var data = parser.read(snippet);
expect(data.version).toEqual('1.3.0'); expect(data.version).to.eql('1.3.0');
}); });
it('Version taken from parser takes preference', function() { it('Version taken from parser takes preference', function() {
var parser = new ol.parser.ogc.WMSCapabilities({version: '1.1.0'}); var parser = new ol.parser.ogc.WMSCapabilities({version: '1.1.0'});
var data = parser.read(snippet); var data = parser.read(snippet);
expect(data.version).toEqual('1.1.0'); expect(data.version).to.eql('1.1.0');
}); });
it('If nothing else is set, defaultVersion should be returned', function() { it('If nothing else is set, defaultVersion should be returned', function() {
var parser = new ol.parser.ogc.WMSCapabilities({defaultVersion: '1.1.1'}); var parser = new ol.parser.ogc.WMSCapabilities({defaultVersion: '1.1.1'});
var data = parser.read(snippet2); var data = parser.read(snippet2);
expect(data.version).toEqual('1.1.1'); expect(data.version).to.eql('1.1.1');
}); });
var parser = new ol.parser.ogc.WMSCapabilities({defaultVersion: '1.1.1'}); var parser = new ol.parser.ogc.WMSCapabilities({defaultVersion: '1.1.1'});
it('Version from options returned', function() { it('Version from options returned', function() {
var version = parser.getVersion(null, {version: '1.3.0'}); var version = parser.getVersion(null, {version: '1.3.0'});
expect(version).toEqual('1.3.0'); expect(version).to.eql('1.3.0');
}); });
var msg = 'defaultVersion returned if no version specified in options ' + var msg = 'defaultVersion returned if no version specified in options ' +
'and no version on the format'; 'and no version on the format';
it(msg, function() { it(msg, function() {
var version = parser.getVersion(null); var version = parser.getVersion(null);
expect(version).toEqual('1.1.1'); expect(version).to.eql('1.1.1');
}); });
msg = 'version returned of the Format if no version specified in options'; msg = 'version returned of the Format if no version specified in options';
it(msg, function() { it(msg, function() {
parser.version = '1.1.0'; parser.version = '1.1.0';
var version = parser.getVersion(null); var version = parser.getVersion(null);
expect(version).toEqual('1.1.0'); expect(version).to.eql('1.1.0');
}); });
}); });
}); });

View File

@@ -11,30 +11,30 @@ describe('ol.parser.ogc.wmscapabilities_v1_0_0', function() {
var parser = new ol.parser.ogc.WMSCapabilities(); var parser = new ol.parser.ogc.WMSCapabilities();
describe('test read', function() { describe('test read', function() {
it('Test read', function() { it('Test read', function(done) {
var obj; var obj;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_0_0.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_0_0.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(obj.service.keywords.length).to.eql(2);
expect(obj.service.keywords.length).toEqual(2); expect(obj.service.keywords[0]['value']).to.eql('BGDI');
expect(obj.service.keywords[0]['value']).toEqual('BGDI'); expect(obj.service.href).to.eql('https://wms.geo.admin.ch/?');
expect(obj.service.href).toEqual('https://wms.geo.admin.ch/?');
var url = 'https://wms.geo.admin.ch/?'; var url = 'https://wms.geo.admin.ch/?';
var getmap = obj.capability.request.getmap; var getmap = obj.capability.request.getmap;
expect(getmap.get.href).toEqual(url); expect(getmap.get.href).to.eql(url);
expect(getmap.post.href).toEqual(url); expect(getmap.post.href).to.eql(url);
expect(getmap.formats.length).toEqual(4); expect(getmap.formats.length).to.eql(4);
expect(getmap.formats[0]).toEqual('GIF'); expect(getmap.formats[0]).to.eql('GIF');
expect(obj.capability.layers[64].keywords.length).toEqual(2); expect(obj.capability.layers[64].keywords.length).to.eql(2);
expect(obj.capability.layers[64].keywords[0].value).toEqual('Geometer'); expect(obj.capability.layers[64].keywords[0].value).to.eql('Geometer');
done();
}); });
}); });
}); });

View File

@@ -5,306 +5,306 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1', function() {
var parser = new ol.parser.ogc.WMSCapabilities(); var parser = new ol.parser.ogc.WMSCapabilities();
describe('test read exception', function() { describe('test read exception', function() {
it('Error reported correctly', function() { it('Error reported correctly', function(done) {
var obj; var obj;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' + var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' +
'exceptionsample.xml'; 'exceptionsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(!!obj.error).to.be.ok();
expect(!!obj.error).toBeTruthy(); done();
}); });
}); });
}); });
describe('test read', function() { describe('test read', function() {
it('Test read', function() { it('Test read', function(done) {
var obj, capability, getmap, describelayer, getfeatureinfo, layer; var obj, capability, getmap, describelayer, getfeatureinfo, layer;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
capability = obj.capability; capability = obj.capability;
getmap = capability.request.getmap; getmap = capability.request.getmap;
describelayer = capability.request.describelayer; describelayer = capability.request.describelayer;
getfeatureinfo = capability.request.getfeatureinfo; getfeatureinfo = capability.request.getfeatureinfo;
layer = capability.layers[2]; layer = capability.layers[2];
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(capability).to.be.ok();
expect(capability).toBeTruthy(); expect(getmap.formats.length).to.eql(28);
expect(getmap.formats.length).toEqual(28);
var get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&'; var get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
expect(getmap.get.href).toEqual(get); expect(getmap.get.href).to.eql(get);
expect(getmap.post).toBeUndefined(); expect(getmap.post).to.be(undefined);
get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&'; get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
expect(describelayer.get.href).toEqual(get); expect(describelayer.get.href).to.eql(get);
expect(describelayer.post).toBeUndefined(); expect(describelayer.post).to.be(undefined);
get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&'; get = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
expect(getfeatureinfo.get.href).toEqual(get); expect(getfeatureinfo.get.href).to.eql(get);
var post = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&'; var post = 'http://publicus.opengeo.org:80/geoserver/wms?SERVICE=WMS&';
expect(getfeatureinfo.post.href).toEqual(post); expect(getfeatureinfo.post.href).to.eql(post);
expect(capability.layers).toBeTruthy(); expect(capability.layers).to.be.ok();
expect(capability.layers.length).toEqual(22); expect(capability.layers.length).to.eql(22);
var infoFormats = var infoFormats =
['text/plain', 'text/html', 'application/vnd.ogc.gml']; ['text/plain', 'text/html', 'application/vnd.ogc.gml'];
expect(layer.infoFormats).toEqual(infoFormats); expect(layer.infoFormats).to.eql(infoFormats);
expect(layer.name).toEqual('tiger:tiger_roads'); expect(layer.name).to.eql('tiger:tiger_roads');
expect(layer.prefix).toEqual('tiger'); expect(layer.prefix).to.eql('tiger');
expect(layer.title).toEqual('Manhattan (NY) roads'); expect(layer.title).to.eql('Manhattan (NY) roads');
var abstr = 'Highly simplified road layout of Manhattan in New York..'; var abstr = 'Highly simplified road layout of Manhattan in New York..';
expect(layer['abstract']).toEqual(abstr); expect(layer['abstract']).to.eql(abstr);
var bbox = [-74.08769307536667, 40.660618924633326, var bbox = [-74.08769307536667, 40.660618924633326,
-73.84653192463333, 40.90178007536667]; -73.84653192463333, 40.90178007536667];
expect(layer.llbbox).toEqual(bbox); expect(layer.llbbox).to.eql(bbox);
expect(layer.styles.length).toEqual(1); expect(layer.styles.length).to.eql(1);
expect(layer.styles[0].name).toEqual('tiger_roads'); expect(layer.styles[0].name).to.eql('tiger_roads');
var legend = 'http://publicus.opengeo.org:80/geoserver/wms/' + var legend = 'http://publicus.opengeo.org:80/geoserver/wms/' +
'GetLegendGraphic?VERSION=1.0.0&FORMAT=image/png&WIDTH=20&' + 'GetLegendGraphic?VERSION=1.0.0&FORMAT=image/png&WIDTH=20&' +
'HEIGHT=20&LAYER=tiger:tiger_roads'; 'HEIGHT=20&LAYER=tiger:tiger_roads';
expect(layer.styles[0].legend.href).toEqual(legend); expect(layer.styles[0].legend.href).to.eql(legend);
expect(layer.styles[0].legend.format).toEqual('image/png'); expect(layer.styles[0].legend.format).to.eql('image/png');
expect(layer.queryable).toBeTruthy(); expect(layer.queryable).to.be.ok();
done();
}); });
}); });
}); });
describe('test layers', function() { describe('test layers', function() {
it('Test layers', function() { it('Test layers', function(done) {
var obj, capability, layers = {}, rootlayer, identifiers, authorities; var obj, capability, layers = {}, rootlayer, identifiers, authorities;
var featurelist; var featurelist;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
capability = obj.capability; capability = obj.capability;
for (var i = 0, len = capability.layers.length; i < len; i++) { for (var i = 0, len = capability.layers.length; i < len; i++) {
if ('name' in capability.layers[i]) { if ('name' in capability.layers[i]) {
layers[capability.layers[i].name] = capability.layers[i]; layers[capability.layers[i].name] = capability.layers[i];
}
} }
rootlayer = capability.layers[capability.layers.length - 1]; }
identifiers = layers['ROADS_RIVERS'].identifiers; rootlayer = capability.layers[capability.layers.length - 1];
authorities = layers['ROADS_RIVERS'].authorityURLs; identifiers = layers['ROADS_RIVERS'].identifiers;
featurelist = layers['ROADS_RIVERS'].featureListURL; authorities = layers['ROADS_RIVERS'].authorityURLs;
}); featurelist = layers['ROADS_RIVERS'].featureListURL;
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(rootlayer.srs).to.eql({'EPSG:4326': true});
expect(rootlayer.srs).toEqual({'EPSG:4326': true});
var srs = {'EPSG:4326': true, 'EPSG:26986': true}; var srs = {'EPSG:4326': true, 'EPSG:26986': true};
expect(layers['ROADS_RIVERS'].srs).toEqual(srs); expect(layers['ROADS_RIVERS'].srs).to.eql(srs);
expect(layers['Temperature'].srs).toEqual({'EPSG:4326': true}); expect(layers['Temperature'].srs).to.eql({'EPSG:4326': true});
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986']; var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).toEqual({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
bbox = layers['ROADS_RIVERS'].bbox['EPSG:4326']; bbox = layers['ROADS_RIVERS'].bbox['EPSG:4326'];
expect(bbox.bbox).toEqual([-71.63, 41.75, -70.78, 42.90]); expect(bbox.bbox).to.eql([-71.63, 41.75, -70.78, 42.90]);
expect(bbox.res).toEqual({x: 0.01, y: 0.01}); expect(bbox.res).to.eql({x: 0.01, y: 0.01});
bbox = layers['ROADS_1M'].bbox['EPSG:26986']; bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).toEqual({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
expect(identifiers).toBeTruthy(); expect(identifiers).to.be.ok();
expect('DIF_ID' in identifiers).toBeTruthy(); expect('DIF_ID' in identifiers).to.be.ok();
expect(identifiers['DIF_ID']).toEqual('123456'); expect(identifiers['DIF_ID']).to.eql('123456');
expect('DIF_ID' in authorities).toBeTruthy(); expect('DIF_ID' in authorities).to.be.ok();
var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html'; var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html';
expect(authorities['DIF_ID']).toEqual(url); expect(authorities['DIF_ID']).to.eql(url);
expect(featurelist).toBeTruthy(); expect(featurelist).to.be.ok();
expect(featurelist.format).toEqual('application/vnd.ogc.se_xml'); expect(featurelist.format).to.eql('application/vnd.ogc.se_xml');
url = 'http://www.university.edu/data/roads_rivers.gml'; url = 'http://www.university.edu/data/roads_rivers.gml';
expect(featurelist.href).toEqual(url); expect(featurelist.href).to.eql(url);
expect(layers['Pressure'].queryable).toBeTruthy(); expect(layers['Pressure'].queryable).to.be.ok();
expect(layers['ozone_image'].queryable).toBeFalsy(); expect(layers['ozone_image'].queryable).to.not.be();
expect(layers['population'].cascaded).toEqual(1); expect(layers['population'].cascaded).to.eql(1);
expect(layers['ozone_image'].fixedWidth).toEqual(512); expect(layers['ozone_image'].fixedWidth).to.eql(512);
expect(layers['ozone_image'].fixedHeight).toEqual(256); expect(layers['ozone_image'].fixedHeight).to.eql(256);
expect(layers['ozone_image'].opaque).toBeTruthy(); expect(layers['ozone_image'].opaque).to.be.ok();
expect(layers['ozone_image'].noSubsets).toBeTruthy(); expect(layers['ozone_image'].noSubsets).to.be.ok();
done();
}); });
}); });
}); });
describe('test dimensions', function() { describe('test dimensions', function() {
it('Test dimensions', function() { it('Test dimensions', function(done) {
var obj, capability, layers = {}, time, elevation; var obj, capability, layers = {}, time, elevation;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
capability = obj.capability; capability = obj.capability;
for (var i = 0, len = capability.layers.length; i < len; i++) { for (var i = 0, len = capability.layers.length; i < len; i++) {
if ('name' in capability.layers[i]) { if ('name' in capability.layers[i]) {
layers[capability.layers[i].name] = capability.layers[i]; layers[capability.layers[i].name] = capability.layers[i];
}
} }
time = layers['Clouds'].dimensions.time; }
elevation = layers['Pressure'].dimensions.elevation; time = layers['Clouds'].dimensions.time;
}); elevation = layers['Pressure'].dimensions.elevation;
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(time['default']).to.eql('2000-08-22');
expect(time['default']).toEqual('2000-08-22'); expect(time.values.length).to.eql(1);
expect(time.values.length).toEqual(1); expect(time.values[0]).to.eql('1999-01-01/2000-08-22/P1D');
expect(time.values[0]).toEqual('1999-01-01/2000-08-22/P1D'); expect(elevation.units).to.eql('EPSG:5030');
expect(elevation.units).toEqual('EPSG:5030'); expect(elevation['default']).to.eql('0');
expect(elevation['default']).toEqual('0'); expect(elevation.nearestVal).to.be.ok();
expect(elevation.nearestVal).toBeTruthy(); expect(elevation.multipleVal).to.not.be();
expect(elevation.multipleVal).toBeFalsy(); expect(elevation.values).to.eql(
expect(elevation.values).toEqual(
['0', '1000', '3000', '5000', '10000']); ['0', '1000', '3000', '5000', '10000']);
done();
}); });
}); });
}); });
describe('test contact info', function() { describe('test contact info', function() {
it('Test contact info', function() { it('Test contact info', function(done) {
var obj, service, contactinfo, personPrimary, addr; var obj, service, contactinfo, personPrimary, addr;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' + var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/' +
'ogcsample.xml'; 'ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
service = obj.service; service = obj.service;
contactinfo = service.contactInformation; contactinfo = service.contactInformation;
personPrimary = contactinfo.personPrimary; personPrimary = contactinfo.personPrimary;
addr = contactinfo.contactAddress; addr = contactinfo.contactAddress;
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(contactinfo).to.be.ok();
expect(contactinfo).toBeTruthy(); expect(personPrimary).to.be.ok();
expect(personPrimary).toBeTruthy(); expect(personPrimary.person).to.eql('Jeff deLaBeaujardiere');
expect(personPrimary.person).toEqual('Jeff deLaBeaujardiere'); expect(personPrimary.organization).to.eql('NASA');
expect(personPrimary.organization).toEqual('NASA'); expect(contactinfo.position).to.eql('Computer Scientist');
expect(contactinfo.position).toEqual('Computer Scientist'); expect(addr).to.be.ok();
expect(addr).toBeTruthy(); expect(addr.type).to.eql('postal');
expect(addr.type).toEqual('postal');
var address = 'NASA Goddard Space Flight Center, Code 933'; var address = 'NASA Goddard Space Flight Center, Code 933';
expect(addr.address).toEqual(address); expect(addr.address).to.eql(address);
expect(addr.city).toEqual('Greenbelt'); expect(addr.city).to.eql('Greenbelt');
expect(addr.stateOrProvince).toEqual('MD'); expect(addr.stateOrProvince).to.eql('MD');
expect(addr.postcode).toEqual('20771'); expect(addr.postcode).to.eql('20771');
expect(addr.country).toEqual('USA'); expect(addr.country).to.eql('USA');
expect(contactinfo.phone).toEqual('+1 301 286-1569'); expect(contactinfo.phone).to.eql('+1 301 286-1569');
expect(contactinfo.fax).toEqual('+1 301 286-1777'); expect(contactinfo.fax).to.eql('+1 301 286-1777');
expect(contactinfo.email).toEqual('delabeau@iniki.gsfc.nasa.gov'); expect(contactinfo.email).to.eql('delabeau@iniki.gsfc.nasa.gov');
done();
}); });
}); });
}); });
describe('Test fees and constraints', function() { describe('Test fees and constraints', function() {
it('Test fees and constraints', function() { it('Test fees and constraints', function(done) {
var obj, service; var obj, service;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
service = obj.service; service = obj.service;
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect('fees' in service).to.not.be();
expect('fees' in service).toBeFalsy(); expect('accessConstraints' in service).to.not.be();
expect('accessConstraints' in service).toBeFalsy(); done();
}); });
}); });
}); });
describe('Test requests', function() { describe('Test requests', function() {
it('Test requests', function() { it('Test requests', function(done) {
var obj, request, exception, userSymbols; var obj, request, exception, userSymbols;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/gssample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
request = obj.capability.request; request = obj.capability.request;
exception = obj.capability.exception; exception = obj.capability.exception;
userSymbols = obj.capability.userSymbols; userSymbols = obj.capability.userSymbols;
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(request).to.be.ok();
expect(request).toBeTruthy(); expect('getmap' in request).to.be.ok();
expect('getmap' in request).toBeTruthy(); expect('getfeatureinfo' in request).to.be.ok();
expect('getfeatureinfo' in request).toBeTruthy();
var formats = ['text/plain', 'text/html', 'application/vnd.ogc.gml']; var formats = ['text/plain', 'text/html', 'application/vnd.ogc.gml'];
expect(request.getfeatureinfo.formats).toEqual(formats); expect(request.getfeatureinfo.formats).to.eql(formats);
expect('describelayer' in request).toBeTruthy(); expect('describelayer' in request).to.be.ok();
expect('getlegendgraphic' in request).toBeTruthy(); expect('getlegendgraphic' in request).to.be.ok();
expect(exception).toBeTruthy(); expect(exception).to.be.ok();
expect(exception.formats).toEqual(['application/vnd.ogc.se_xml']); expect(exception.formats).to.eql(['application/vnd.ogc.se_xml']);
expect(userSymbols).toBeTruthy(); expect(userSymbols).to.be.ok();
expect(userSymbols.supportSLD).toBeTruthy(); expect(userSymbols.supportSLD).to.be.ok();
expect(userSymbols.userLayer).toBeTruthy(); expect(userSymbols.userLayer).to.be.ok();
expect(userSymbols.userStyle).toBeTruthy(); expect(userSymbols.userStyle).to.be.ok();
expect(userSymbols.remoteWFS).toBeTruthy(); expect(userSymbols.remoteWFS).to.be.ok();
done();
}); });
}); });
}); });
describe('test ogc', function() { describe('test ogc', function() {
it('Test ogc', function() { it('Test ogc', function(done) {
var obj, capability, attribution, keywords, metadataURLs; var obj, capability, attribution, keywords, metadataURLs;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1/ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
capability = obj.capability; capability = obj.capability;
attribution = capability.layers[2].attribution; attribution = capability.layers[2].attribution;
keywords = capability.layers[0].keywords; keywords = capability.layers[0].keywords;
metadataURLs = capability.layers[0].metadataURLs; metadataURLs = capability.layers[0].metadataURLs;
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(attribution.title).to.eql('State College University');
expect(attribution.title).toEqual('State College University'); expect(attribution.href).to.eql('http://www.university.edu/');
expect(attribution.href).toEqual('http://www.university.edu/');
var url = 'http://www.university.edu/icons/logo.gif'; var url = 'http://www.university.edu/icons/logo.gif';
expect(attribution.logo.href).toEqual(url); expect(attribution.logo.href).to.eql(url);
expect(attribution.logo.format).toEqual('image/gif'); expect(attribution.logo.format).to.eql('image/gif');
expect(attribution.logo.width).toEqual('100'); expect(attribution.logo.width).to.eql('100');
expect(attribution.logo.height).toEqual('100'); expect(attribution.logo.height).to.eql('100');
expect(keywords.length).toEqual(3); expect(keywords.length).to.eql(3);
expect(keywords[0].value).toEqual('road'); expect(keywords[0].value).to.eql('road');
expect(metadataURLs.length).toEqual(2); expect(metadataURLs.length).to.eql(2);
expect(metadataURLs[0].type).toEqual('FGDC'); expect(metadataURLs[0].type).to.eql('FGDC');
expect(metadataURLs[0].format).toEqual('text/plain'); expect(metadataURLs[0].format).to.eql('text/plain');
var href = 'http://www.university.edu/metadata/roads.txt'; var href = 'http://www.university.edu/metadata/roads.txt';
expect(metadataURLs[0].href).toEqual(href); expect(metadataURLs[0].href).to.eql(href);
expect(Math.round(capability.layers[0].minScale)).toEqual(250000); expect(Math.round(capability.layers[0].minScale)).to.eql(250000);
expect(Math.round(capability.layers[0].maxScale)).toEqual(1000); expect(Math.round(capability.layers[0].maxScale)).to.eql(1000);
expect(capability.layers[1].minScale).toBeUndefined(); expect(capability.layers[1].minScale).to.be(undefined);
expect(capability.layers[1].maxScale).toBeUndefined(); expect(capability.layers[1].maxScale).to.be(undefined);
done();
}); });
}); });
}); });

View File

@@ -8,30 +8,29 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1_wmsc', function() {
}); });
describe('test read', function() { describe('test read', function() {
it('Test read', function() { it('Test read', function(done) {
var obj, tilesets, tileset; var obj, tilesets, tileset;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/wmsc.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/wmsc.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
tilesets = obj.capability.vendorSpecific.tileSets; tilesets = obj.capability.vendorSpecific.tileSets;
tileset = tilesets[0]; tileset = tilesets[0];
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(tilesets.length).to.eql(2);
expect(tilesets.length).toEqual(2);
var bbox = [-13697515.466796875, 5165920.118906248, var bbox = [-13697515.466796875, 5165920.118906248,
-13619243.94984375, 5244191.635859374]; -13619243.94984375, 5244191.635859374];
expect(tileset.bbox['EPSG:900913'].bbox).toEqual(bbox); expect(tileset.bbox['EPSG:900913'].bbox).to.eql(bbox);
expect(tileset.format).toEqual('image/png'); expect(tileset.format).to.eql('image/png');
expect(tileset.height).toEqual(256); expect(tileset.height).to.eql(256);
expect(tileset.width).toEqual(256); expect(tileset.width).to.eql(256);
expect(tileset.layers).toEqual('medford:hydro'); expect(tileset.layers).to.eql('medford:hydro');
expect(tileset.srs['EPSG:900913']).toBeTruthy(); expect(tileset.srs['EPSG:900913']).to.be.ok();
var resolutions = [156543.03390625, 78271.516953125, 39135.7584765625, var resolutions = [156543.03390625, 78271.516953125, 39135.7584765625,
19567.87923828125, 9783.939619140625, 4891.9698095703125, 19567.87923828125, 9783.939619140625, 4891.9698095703125,
2445.9849047851562, 1222.9924523925781, 611.4962261962891, 2445.9849047851562, 1222.9924523925781, 611.4962261962891,
@@ -41,28 +40,29 @@ describe('ol.parser.ogc.wmscapabilities_v1_1_1_wmsc', function() {
0.5971642833948135, 0.29858214169740677, 0.14929107084870338, 0.5971642833948135, 0.29858214169740677, 0.14929107084870338,
0.07464553542435169, 0.037322767712175846, 0.018661383856087923, 0.07464553542435169, 0.037322767712175846, 0.018661383856087923,
0.009330691928043961, 0.004665345964021981]; 0.009330691928043961, 0.004665345964021981];
expect(tileset.resolutions).toEqual(resolutions); expect(tileset.resolutions).to.eql(resolutions);
expect(tileset.styles).toEqual(''); expect(tileset.styles).to.eql('');
done();
}); });
}); });
}); });
describe('test fallback', function() { describe('test fallback', function() {
it('Test fallback', function() { it('Test fallback', function(done) {
var obj; var obj;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/' + var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_1_1_WMSC/' +
'fallback.xml'; 'fallback.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(obj.capability.layers.length).to.eql(2);
expect(obj.capability.layers.length).toEqual(2); done();
}); });
}); });
}); });

View File

@@ -5,148 +5,148 @@ describe('ol.parser.ogc.wmscapabilities_v1_3_0', function() {
var parser = new ol.parser.ogc.WMSCapabilities(); var parser = new ol.parser.ogc.WMSCapabilities();
describe('test read exception', function() { describe('test read exception', function() {
it('Error reported correctly', function() { it('Error reported correctly', function(done) {
var result; var result;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/' + var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/' +
'exceptionsample.xml'; 'exceptionsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
result = parser.read(xhr.getResponseXml()); result = parser.read(xhr.getResponseXml());
});
}); });
waitsFor(function() { waitsFor(function() {
return (result !== undefined); return (result !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(!!result.error).to.be(true);
expect(!!result.error).toBe(true); done();
}); });
}); });
}); });
describe('test read', function() { describe('test read', function() {
it('Test read', function() { it('Test read', function(done) {
var obj, capability, layers = {}, rootlayer, identifiers, authorities; var obj, capability, layers = {}, rootlayer, identifiers, authorities;
var featurelist, time, elevation, service, contactinfo, personPrimary, var featurelist, time, elevation, service, contactinfo, personPrimary,
addr, request, exception, attribution, keywords, metadataURLs; addr, request, exception, attribution, keywords, metadataURLs;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml'; var url = 'spec/ol/parser/ogc/xml/wmscapabilities_v1_3_0/ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
capability = obj.capability; capability = obj.capability;
for (var i = 0, len = capability.layers.length; i < len; i++) { for (var i = 0, len = capability.layers.length; i < len; i++) {
if ('name' in capability.layers[i]) { if ('name' in capability.layers[i]) {
layers[capability.layers[i].name] = capability.layers[i]; layers[capability.layers[i].name] = capability.layers[i];
}
} }
rootlayer = capability.layers[capability.layers.length - 1]; }
identifiers = layers['ROADS_RIVERS'].identifiers; rootlayer = capability.layers[capability.layers.length - 1];
authorities = layers['ROADS_RIVERS'].authorityURLs; identifiers = layers['ROADS_RIVERS'].identifiers;
featurelist = layers['ROADS_RIVERS'].featureListURL; authorities = layers['ROADS_RIVERS'].authorityURLs;
time = layers['Clouds'].dimensions.time; featurelist = layers['ROADS_RIVERS'].featureListURL;
elevation = layers['Pressure'].dimensions.elevation; time = layers['Clouds'].dimensions.time;
service = obj.service; elevation = layers['Pressure'].dimensions.elevation;
contactinfo = service.contactInformation; service = obj.service;
personPrimary = contactinfo.personPrimary; contactinfo = service.contactInformation;
addr = contactinfo.contactAddress; personPrimary = contactinfo.personPrimary;
request = obj.capability.request; addr = contactinfo.contactAddress;
exception = obj.capability.exception; request = obj.capability.request;
attribution = capability.layers[2].attribution; exception = obj.capability.exception;
keywords = capability.layers[0].keywords; attribution = capability.layers[2].attribution;
metadataURLs = capability.layers[0].metadataURLs; keywords = capability.layers[0].keywords;
}); metadataURLs = capability.layers[0].metadataURLs;
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(rootlayer.srs).to.eql({'CRS:84': true});
expect(rootlayer.srs).toEqual({'CRS:84': true});
var srs = {'CRS:84': true, 'EPSG:26986': true}; var srs = {'CRS:84': true, 'EPSG:26986': true};
expect(layers['ROADS_RIVERS'].srs).toEqual(srs); expect(layers['ROADS_RIVERS'].srs).to.eql(srs);
expect(layers['Temperature'].srs).toEqual({'CRS:84': true}); expect(layers['Temperature'].srs).to.eql({'CRS:84': true});
var infoFormats = ['text/xml', 'text/plain', 'text/html']; var infoFormats = ['text/xml', 'text/plain', 'text/html'];
expect(layers['Temperature'].infoFormats).toEqual(infoFormats); expect(layers['Temperature'].infoFormats).to.eql(infoFormats);
var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986']; var bbox = layers['ROADS_RIVERS'].bbox['EPSG:26986'];
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).toEqual({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
bbox = layers['ROADS_RIVERS'].bbox['CRS:84']; bbox = layers['ROADS_RIVERS'].bbox['CRS:84'];
expect(bbox.bbox).toEqual([-71.63, 41.75, -70.78, 42.90]); expect(bbox.bbox).to.eql([-71.63, 41.75, -70.78, 42.90]);
expect(bbox.res).toEqual({x: 0.01, y: 0.01}); expect(bbox.res).to.eql({x: 0.01, y: 0.01});
bbox = layers['ROADS_1M'].bbox['EPSG:26986']; bbox = layers['ROADS_1M'].bbox['EPSG:26986'];
expect(bbox.bbox).toEqual([189000, 834000, 285000, 962000]); expect(bbox.bbox).to.eql([189000, 834000, 285000, 962000]);
expect(bbox.res).toEqual({x: 1, y: 1}); expect(bbox.res).to.eql({x: 1, y: 1});
expect(identifiers).toBeTruthy(); expect(identifiers).to.be.ok();
expect('DIF_ID' in identifiers).toBeTruthy(); expect('DIF_ID' in identifiers).to.be.ok();
expect(identifiers['DIF_ID']).toEqual('123456'); expect(identifiers['DIF_ID']).to.eql('123456');
expect('DIF_ID' in authorities).toBeTruthy(); expect('DIF_ID' in authorities).to.be.ok();
var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html'; var url = 'http://gcmd.gsfc.nasa.gov/difguide/whatisadif.html';
expect(authorities['DIF_ID']).toEqual(url); expect(authorities['DIF_ID']).to.eql(url);
expect(featurelist).toBeTruthy(); expect(featurelist).to.be.ok();
expect(featurelist.format).toEqual('XML'); expect(featurelist.format).to.eql('XML');
url = 'http://www.university.edu/data/roads_rivers.gml'; url = 'http://www.university.edu/data/roads_rivers.gml';
expect(featurelist.href).toEqual(url); expect(featurelist.href).to.eql(url);
expect(layers['Pressure'].queryable).toBeTruthy(); expect(layers['Pressure'].queryable).to.be.ok();
expect(layers['ozone_image'].queryable).toBeFalsy(); expect(layers['ozone_image'].queryable).to.not.be();
expect(layers['population'].cascaded).toEqual(1); expect(layers['population'].cascaded).to.eql(1);
expect(layers['ozone_image'].fixedWidth).toEqual(512); expect(layers['ozone_image'].fixedWidth).to.eql(512);
expect(layers['ozone_image'].fixedHeight).toEqual(256); expect(layers['ozone_image'].fixedHeight).to.eql(256);
expect(layers['ozone_image'].opaque).toBeTruthy(); expect(layers['ozone_image'].opaque).to.be.ok();
expect(layers['ozone_image'].noSubsets).toBeTruthy(); expect(layers['ozone_image'].noSubsets).to.be.ok();
expect(time['default']).toEqual('2000-08-22'); expect(time['default']).to.eql('2000-08-22');
expect(time.values.length).toEqual(1); expect(time.values.length).to.eql(1);
expect(time.values[0]).toEqual('1999-01-01/2000-08-22/P1D'); expect(time.values[0]).to.eql('1999-01-01/2000-08-22/P1D');
expect(elevation.units).toEqual('CRS:88'); expect(elevation.units).to.eql('CRS:88');
expect(elevation['default']).toEqual('0'); expect(elevation['default']).to.eql('0');
expect(elevation.nearestVal).toBeTruthy(); expect(elevation.nearestVal).to.be.ok();
expect(elevation.multipleVal).toBeFalsy(); expect(elevation.multipleVal).to.not.be();
expect(elevation.values).toEqual( expect(elevation.values).to.eql(
['0', '1000', '3000', '5000', '10000']); ['0', '1000', '3000', '5000', '10000']);
expect(contactinfo).toBeTruthy(); expect(contactinfo).to.be.ok();
expect(personPrimary).toBeTruthy(); expect(personPrimary).to.be.ok();
expect(personPrimary.person).toEqual('Jeff Smith'); expect(personPrimary.person).to.eql('Jeff Smith');
expect(personPrimary.organization).toEqual('NASA'); expect(personPrimary.organization).to.eql('NASA');
expect(contactinfo.position).toEqual('Computer Scientist'); expect(contactinfo.position).to.eql('Computer Scientist');
expect(addr).toBeTruthy(); expect(addr).to.be.ok();
expect(addr.type).toEqual('postal'); expect(addr.type).to.eql('postal');
expect(addr.address).toEqual('NASA Goddard Space Flight Center'); expect(addr.address).to.eql('NASA Goddard Space Flight Center');
expect(addr.city).toEqual('Greenbelt'); expect(addr.city).to.eql('Greenbelt');
expect(addr.stateOrProvince).toEqual('MD'); expect(addr.stateOrProvince).to.eql('MD');
expect(addr.postcode).toEqual('20771'); expect(addr.postcode).to.eql('20771');
expect(addr.country).toEqual('USA'); expect(addr.country).to.eql('USA');
expect(contactinfo.phone).toEqual('+1 301 555-1212'); expect(contactinfo.phone).to.eql('+1 301 555-1212');
expect(contactinfo.email).toEqual('user@host.com'); expect(contactinfo.email).to.eql('user@host.com');
expect('fees' in service).toBeFalsy(); expect('fees' in service).to.not.be();
expect('accessConstraints' in service).toBeFalsy(); expect('accessConstraints' in service).to.not.be();
expect(request).toBeTruthy(); expect(request).to.be.ok();
expect('getmap' in request).toBeTruthy(); expect('getmap' in request).to.be.ok();
expect('getfeatureinfo' in request).toBeTruthy(); expect('getfeatureinfo' in request).to.be.ok();
var formats = ['text/xml', 'text/plain', 'text/html']; var formats = ['text/xml', 'text/plain', 'text/html'];
expect(request.getfeatureinfo.formats).toEqual(formats); expect(request.getfeatureinfo.formats).to.eql(formats);
expect(exception).toBeTruthy(); expect(exception).to.be.ok();
formats = ['XML', 'INIMAGE', 'BLANK']; formats = ['XML', 'INIMAGE', 'BLANK'];
expect(exception.formats).toEqual(formats); expect(exception.formats).to.eql(formats);
expect(attribution.title).toEqual('State College University'); expect(attribution.title).to.eql('State College University');
expect(attribution.href).toEqual('http://www.university.edu/'); expect(attribution.href).to.eql('http://www.university.edu/');
url = 'http://www.university.edu/icons/logo.gif'; url = 'http://www.university.edu/icons/logo.gif';
expect(attribution.logo.href).toEqual(url); expect(attribution.logo.href).to.eql(url);
expect(attribution.logo.format).toEqual('image/gif'); expect(attribution.logo.format).to.eql('image/gif');
expect(attribution.logo.width).toEqual('100'); expect(attribution.logo.width).to.eql('100');
expect(attribution.logo.height).toEqual('100'); expect(attribution.logo.height).to.eql('100');
expect(keywords.length).toEqual(3); expect(keywords.length).to.eql(3);
expect(keywords[0].value).toEqual('road'); expect(keywords[0].value).to.eql('road');
expect(metadataURLs.length).toEqual(2); expect(metadataURLs.length).to.eql(2);
expect(metadataURLs[0].type).toEqual('FGDC:1998'); expect(metadataURLs[0].type).to.eql('FGDC:1998');
expect(metadataURLs[0].format).toEqual('text/plain'); expect(metadataURLs[0].format).to.eql('text/plain');
url = 'http://www.university.edu/metadata/roads.txt'; url = 'http://www.university.edu/metadata/roads.txt';
expect(metadataURLs[0].href).toEqual(url); expect(metadataURLs[0].href).to.eql(url);
var minScale = 250000; var minScale = 250000;
expect(capability.layers[0].minScale).toEqual(minScale.toPrecision(16)); expect(capability.layers[0].minScale).to.eql(minScale.toPrecision(16));
var maxScale = 1000; var maxScale = 1000;
expect(capability.layers[0].maxScale).toEqual(maxScale.toPrecision(16)); expect(capability.layers[0].maxScale).to.eql(maxScale.toPrecision(16));
expect(obj.service.layerLimit).toEqual(16); expect(obj.service.layerLimit).to.eql(16);
expect(obj.service.maxHeight).toEqual(2048); expect(obj.service.maxHeight).to.eql(2048);
expect(obj.service.maxWidth).toEqual(2048); expect(obj.service.maxWidth).to.eql(2048);
done();
}); });
}); });
}); });

View File

@@ -5,173 +5,173 @@ describe('ol.parser.ogc.wmtscapabilities_v1_0_0', function() {
var parser = new ol.parser.ogc.WMTSCapabilities(); var parser = new ol.parser.ogc.WMTSCapabilities();
describe('test ows', function() { describe('test ows', function() {
it('Test ows', function() { it('Test ows', function(done) {
var obj, serviceIdentification, serviceProvider, operationsMetadata, var obj, serviceIdentification, serviceProvider, operationsMetadata,
contactInfo; contactInfo;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' + var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' +
'ogcsample.xml'; 'ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
serviceIdentification = obj.serviceIdentification; serviceIdentification = obj.serviceIdentification;
serviceProvider = obj.serviceProvider; serviceProvider = obj.serviceProvider;
operationsMetadata = obj.operationsMetadata; operationsMetadata = obj.operationsMetadata;
contactInfo = serviceProvider.serviceContact.contactInfo; contactInfo = serviceProvider.serviceContact.contactInfo;
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(serviceIdentification.title).to.eql('Web Map Tile Service');
expect(serviceIdentification.title).toEqual('Web Map Tile Service'); expect(serviceIdentification.serviceTypeVersion).to.eql('1.0.0');
expect(serviceIdentification.serviceTypeVersion).toEqual('1.0.0'); expect(serviceIdentification.serviceType.value).to.eql('OGC WMTS');
expect(serviceIdentification.serviceType.value).toEqual('OGC WMTS'); expect(serviceProvider.providerName).to.eql('MiraMon');
expect(serviceProvider.providerName).toEqual('MiraMon');
var url = 'http://www.creaf.uab.es/miramon'; var url = 'http://www.creaf.uab.es/miramon';
expect(serviceProvider.providerSite).toEqual(url); expect(serviceProvider.providerSite).to.eql(url);
var name = 'Joan Maso Pau'; var name = 'Joan Maso Pau';
expect(serviceProvider.serviceContact.individualName).toEqual(name); expect(serviceProvider.serviceContact.individualName).to.eql(name);
var position = 'Senior Software Engineer'; var position = 'Senior Software Engineer';
expect(serviceProvider.serviceContact.positionName).toEqual(position); expect(serviceProvider.serviceContact.positionName).to.eql(position);
expect(contactInfo.address.administrativeArea).toEqual('Barcelona'); expect(contactInfo.address.administrativeArea).to.eql('Barcelona');
expect(contactInfo.address.city).toEqual('Bellaterra'); expect(contactInfo.address.city).to.eql('Bellaterra');
expect(contactInfo.address.country).toEqual('Spain'); expect(contactInfo.address.country).to.eql('Spain');
expect(contactInfo.address.deliveryPoint).toEqual('Fac Ciencies UAB'); expect(contactInfo.address.deliveryPoint).to.eql('Fac Ciencies UAB');
var email = 'joan.maso@uab.es'; var email = 'joan.maso@uab.es';
expect(contactInfo.address.electronicMailAddress).toEqual(email); expect(contactInfo.address.electronicMailAddress).to.eql(email);
expect(contactInfo.address.postalCode).toEqual('08193'); expect(contactInfo.address.postalCode).to.eql('08193');
expect(contactInfo.phone.voice).toEqual('+34 93 581 1312'); expect(contactInfo.phone.voice).to.eql('+34 93 581 1312');
var dcp = operationsMetadata.GetCapabilities.dcp; var dcp = operationsMetadata.GetCapabilities.dcp;
url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?'; url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
expect(dcp.http.get[0].url).toEqual(url); expect(dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetCapabilities.dcp; dcp = operationsMetadata.GetCapabilities.dcp;
expect(dcp.http.get[0].constraints.GetEncoding.allowedValues).toEqual( expect(dcp.http.get[0].constraints.GetEncoding.allowedValues).to.eql(
{'KVP': true}); {'KVP': true});
url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?'; url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
dcp = operationsMetadata.GetFeatureInfo.dcp; dcp = operationsMetadata.GetFeatureInfo.dcp;
expect(dcp.http.get[0].url).toEqual(url); expect(dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetFeatureInfo.dcp; dcp = operationsMetadata.GetFeatureInfo.dcp;
expect(dcp.http.get[0].constraints).toBeUndefined(); expect(dcp.http.get[0].constraints).to.be(undefined);
url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?'; url = 'http://www.miramon.uab.es/cgi-bin/MiraMon5_0.cgi?';
expect(operationsMetadata.GetTile.dcp.http.get[0].url).toEqual(url); expect(operationsMetadata.GetTile.dcp.http.get[0].url).to.eql(url);
dcp = operationsMetadata.GetTile.dcp; dcp = operationsMetadata.GetTile.dcp;
expect(dcp.http.get[0].constraints).toBeUndefined(); expect(dcp.http.get[0].constraints).to.be(undefined);
done();
}); });
}); });
}); });
describe('test layers', function() { describe('test layers', function() {
it('Test layers', function() { it('Test layers', function(done) {
var obj, contents, layer, wgs84Bbox, dimensions; var obj, contents, layer, wgs84Bbox, dimensions;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' + var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' +
'ogcsample.xml'; 'ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
contents = obj.contents; contents = obj.contents;
layer = contents.layers[0]; layer = contents.layers[0];
wgs84Bbox = layer.bounds; wgs84Bbox = layer.bounds;
dimensions = layer.dimensions; dimensions = layer.dimensions;
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(contents.layers.length).to.eql(1);
expect(contents.layers.length).toEqual(1); expect(layer['abstract']).to.eql('Coastline/shorelines (BA010)');
expect(layer['abstract']).toEqual('Coastline/shorelines (BA010)'); expect(layer.identifier).to.eql('coastlines');
expect(layer.identifier).toEqual('coastlines'); expect(layer.title).to.eql('Coastlines');
expect(layer.title).toEqual('Coastlines'); expect(layer.formats.length).to.eql(2);
expect(layer.formats.length).toEqual(2); expect(layer.formats[0]).to.eql('image/png');
expect(layer.formats[0]).toEqual('image/png'); expect(layer.formats[1]).to.eql('image/gif');
expect(layer.formats[1]).toEqual('image/gif'); expect(layer.styles.length).to.eql(2);
expect(layer.styles.length).toEqual(2); expect(layer.styles[0].identifier).to.eql('DarkBlue');
expect(layer.styles[0].identifier).toEqual('DarkBlue'); expect(layer.styles[0].isDefault).to.be.ok();
expect(layer.styles[0].isDefault).toBeTruthy(); expect(layer.styles[0].title).to.eql('Dark Blue');
expect(layer.styles[0].title).toEqual('Dark Blue');
var url = 'http://www.miramon.uab.es/wmts/Coastlines/' + var url = 'http://www.miramon.uab.es/wmts/Coastlines/' +
'coastlines_darkBlue.png'; 'coastlines_darkBlue.png';
expect(layer.styles[0].legend.href).toEqual(url); expect(layer.styles[0].legend.href).to.eql(url);
expect(layer.styles[0].legend.format).toEqual('image/png'); expect(layer.styles[0].legend.format).to.eql('image/png');
expect(layer.styles[1].identifier).toEqual('thickAndRed'); expect(layer.styles[1].identifier).to.eql('thickAndRed');
expect(!layer.styles[1].isDefault).toBeTruthy(); expect(!layer.styles[1].isDefault).to.be.ok();
expect(layer.styles[1].title).toEqual('Thick And Red'); expect(layer.styles[1].title).to.eql('Thick And Red');
expect(layer.styles[1].legend).toBeUndefined(); expect(layer.styles[1].legend).to.be(undefined);
expect(layer.tileMatrixSetLinks.length).toEqual(1); expect(layer.tileMatrixSetLinks.length).to.eql(1);
expect(layer.tileMatrixSetLinks[0].tileMatrixSet).toEqual('BigWorld'); expect(layer.tileMatrixSetLinks[0].tileMatrixSet).to.eql('BigWorld');
expect(wgs84Bbox instanceof ol.Extent).toBeTruthy(); expect(wgs84Bbox instanceof ol.Extent).to.be.ok();
expect(wgs84Bbox.minX).toEqual(-180.0); expect(wgs84Bbox.minX).to.eql(-180.0);
expect(wgs84Bbox.maxX).toEqual(180.0); expect(wgs84Bbox.maxX).to.eql(180.0);
expect(wgs84Bbox.minY).toEqual(-90.0); expect(wgs84Bbox.minY).to.eql(-90.0);
expect(wgs84Bbox.maxY).toEqual(90.0); expect(wgs84Bbox.maxY).to.eql(90.0);
expect(layer.resourceUrls.hasOwnProperty('tile')).toBeTruthy(); expect(layer.resourceUrls.hasOwnProperty('tile')).to.be.ok();
var format = 'image/png'; var format = 'image/png';
expect(layer.resourceUrls.tile.hasOwnProperty(format)).toBeTruthy(); expect(layer.resourceUrls.tile.hasOwnProperty(format)).to.be.ok();
expect(layer.resourceUrls.tile[format].length).toEqual(2); expect(layer.resourceUrls.tile[format].length).to.eql(2);
var tpl = 'http://a.example.com/wmts/coastlines/{TileMatrix}/' + var tpl = 'http://a.example.com/wmts/coastlines/{TileMatrix}/' +
'{TileRow}/{TileCol}.png'; '{TileRow}/{TileCol}.png';
expect(layer.resourceUrls.tile[format][0]).toEqual(tpl); expect(layer.resourceUrls.tile[format][0]).to.eql(tpl);
tpl = 'http://b.example.com/wmts/coastlines/{TileMatrix}/' + tpl = 'http://b.example.com/wmts/coastlines/{TileMatrix}/' +
'{TileRow}/{TileCol}.png'; '{TileRow}/{TileCol}.png';
expect(layer.resourceUrls.tile[format][1]).toEqual(tpl); expect(layer.resourceUrls.tile[format][1]).to.eql(tpl);
expect(layer.resourceUrls.hasOwnProperty('FeatureInfo')).toBeTruthy(); expect(layer.resourceUrls.hasOwnProperty('FeatureInfo')).to.be.ok();
format = 'application/gml+xml; version=3.1'; format = 'application/gml+xml; version=3.1';
expect(layer.resourceUrls.FeatureInfo.hasOwnProperty(format)) expect(layer.resourceUrls.FeatureInfo.hasOwnProperty(format))
.toBeTruthy(); .to.be.ok();
expect(layer.resourceUrls.FeatureInfo[format].length).toEqual(1); expect(layer.resourceUrls.FeatureInfo[format].length).to.eql(1);
tpl = 'http://www.example.com/wmts/coastlines/{TileMatrixSet}/' + tpl = 'http://www.example.com/wmts/coastlines/{TileMatrixSet}/' +
'{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml'; '{TileMatrix}/{TileRow}/{TileCol}/{J}/{I}.xml';
expect(layer.resourceUrls.FeatureInfo[format][0]).toEqual(tpl); expect(layer.resourceUrls.FeatureInfo[format][0]).to.eql(tpl);
expect(dimensions.length).toEqual(1); expect(dimensions.length).to.eql(1);
expect(dimensions[0].title).toEqual('Time'); expect(dimensions[0].title).to.eql('Time');
expect(dimensions[0]['abstract']).toEqual('Monthly datasets'); expect(dimensions[0]['abstract']).to.eql('Monthly datasets');
expect(dimensions[0].identifier).toEqual('TIME'); expect(dimensions[0].identifier).to.eql('TIME');
expect(dimensions[0]['default']).toEqual('default'); expect(dimensions[0]['default']).to.eql('default');
expect(dimensions[0].values.length).toEqual(3); expect(dimensions[0].values.length).to.eql(3);
expect(dimensions[0].values[0]).toEqual('2007-05'); expect(dimensions[0].values[0]).to.eql('2007-05');
expect(dimensions[0].values[1]).toEqual('2007-06'); expect(dimensions[0].values[1]).to.eql('2007-06');
expect(dimensions[0].values[1]).toEqual('2007-06'); expect(dimensions[0].values[1]).to.eql('2007-06');
expect(dimensions[0].values[2]).toEqual('2007-07'); expect(dimensions[0].values[2]).to.eql('2007-07');
done();
}); });
}); });
}); });
describe('test tileMatrixSets', function() { describe('test tileMatrixSets', function() {
it('Test tileMatrixSets', function() { it('Test tileMatrixSets', function(done) {
var obj, tileMatrixSets, bigWorld; var obj, tileMatrixSets, bigWorld;
runs(function() {
var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' + var url = 'spec/ol/parser/ogc/xml/wmtscapabilities_v1_0_0/' +
'ogcsample.xml'; 'ogcsample.xml';
goog.net.XhrIo.send(url, function(e) { goog.net.XhrIo.send(url, function(e) {
var xhr = e.target; var xhr = e.target;
obj = parser.read(xhr.getResponseXml()); obj = parser.read(xhr.getResponseXml());
tileMatrixSets = obj.contents.tileMatrixSets; tileMatrixSets = obj.contents.tileMatrixSets;
bigWorld = tileMatrixSets['BigWorld']; bigWorld = tileMatrixSets['BigWorld'];
});
}); });
waitsFor(function() { waitsFor(function() {
return (obj !== undefined); return (obj !== undefined);
}, 'XHR timeout', 1000); }, 'XHR timeout', 1000, function() {
runs(function() { expect(bigWorld).to.not.be(undefined);
expect(bigWorld).toBeDefined(); expect(bigWorld.identifier).to.eql('BigWorld');
expect(bigWorld.identifier).toEqual('BigWorld'); expect(bigWorld.matrixIds.length).to.eql(2);
expect(bigWorld.matrixIds.length).toEqual(2); expect(bigWorld.matrixIds[0].identifier).to.eql('1e6');
expect(bigWorld.matrixIds[0].identifier).toEqual('1e6'); expect(bigWorld.matrixIds[0].matrixHeight).to.eql(50000);
expect(bigWorld.matrixIds[0].matrixHeight).toEqual(50000); expect(bigWorld.matrixIds[0].matrixWidth).to.eql(60000);
expect(bigWorld.matrixIds[0].matrixWidth).toEqual(60000); expect(bigWorld.matrixIds[0].scaleDenominator).to.eql(1000000);
expect(bigWorld.matrixIds[0].scaleDenominator).toEqual(1000000); expect(bigWorld.matrixIds[0].tileWidth).to.eql(256);
expect(bigWorld.matrixIds[0].tileWidth).toEqual(256); expect(bigWorld.matrixIds[0].tileHeight).to.eql(256);
expect(bigWorld.matrixIds[0].tileHeight).toEqual(256); expect(bigWorld.matrixIds[0].topLeftCorner.x).to.eql(-180);
expect(bigWorld.matrixIds[0].topLeftCorner.x).toEqual(-180); expect(bigWorld.matrixIds[0].topLeftCorner.y).to.eql(84);
expect(bigWorld.matrixIds[0].topLeftCorner.y).toEqual(84); expect(bigWorld.matrixIds[1].identifier).to.eql('2.5e6');
expect(bigWorld.matrixIds[1].identifier).toEqual('2.5e6'); expect(bigWorld.matrixIds[1].matrixHeight).to.eql(7000);
expect(bigWorld.matrixIds[1].matrixHeight).toEqual(7000); expect(bigWorld.matrixIds[1].matrixWidth).to.eql(9000);
expect(bigWorld.matrixIds[1].matrixWidth).toEqual(9000); expect(bigWorld.matrixIds[1].scaleDenominator).to.eql(2500000);
expect(bigWorld.matrixIds[1].scaleDenominator).toEqual(2500000); expect(bigWorld.matrixIds[1].tileWidth).to.eql(256);
expect(bigWorld.matrixIds[1].tileWidth).toEqual(256); expect(bigWorld.matrixIds[1].tileHeight).to.eql(256);
expect(bigWorld.matrixIds[1].tileHeight).toEqual(256); expect(bigWorld.matrixIds[1].topLeftCorner.x).to.eql(-180);
expect(bigWorld.matrixIds[1].topLeftCorner.x).toEqual(-180); expect(bigWorld.matrixIds[1].topLeftCorner.y).to.eql(84);
expect(bigWorld.matrixIds[1].topLeftCorner.y).toEqual(84); done();
}); });
}); });
}); });

View File

@@ -34,7 +34,7 @@ describe('ol.parser.polyline', function() {
var encodeFlatCoordinates = ol.parser.polyline.encodeFlatCoordinates; var encodeFlatCoordinates = ol.parser.polyline.encodeFlatCoordinates;
// from the "Encoded Polyline Algorithm Format" page at Google // from the "Encoded Polyline Algorithm Format" page at Google
expect(encodeFlatCoordinates(flatPoints)).toEqual(encodedFlatPoints); expect(encodeFlatCoordinates(flatPoints)).to.eql(encodedFlatPoints);
}); });
}); });
@@ -43,7 +43,7 @@ describe('ol.parser.polyline', function() {
var decodeFlatCoordinates = ol.parser.polyline.decodeFlatCoordinates; var decodeFlatCoordinates = ol.parser.polyline.decodeFlatCoordinates;
// from the "Encoded Polyline Algorithm Format" page at Google // from the "Encoded Polyline Algorithm Format" page at Google
expect(decodeFlatCoordinates(encodedFlatPoints)).toEqual(flatPoints); expect(decodeFlatCoordinates(encodedFlatPoints)).to.eql(flatPoints);
}); });
}); });
@@ -53,7 +53,7 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var encodeDeltas = ol.parser.polyline.encodeDeltas; var encodeDeltas = ol.parser.polyline.encodeDeltas;
expect(encodeDeltas(flatPoints, 2)).toEqual(encodedFlatPoints); expect(encodeDeltas(flatPoints, 2)).to.eql(encodedFlatPoints);
}); });
}); });
@@ -61,7 +61,7 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var decodeDeltas = ol.parser.polyline.decodeDeltas; var decodeDeltas = ol.parser.polyline.decodeDeltas;
expect(decodeDeltas(encodedFlatPoints, 2)).toEqual(flatPoints); expect(decodeDeltas(encodedFlatPoints, 2)).to.eql(flatPoints);
}); });
}); });
@@ -71,12 +71,12 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var encodeFloats = ol.parser.polyline.encodeFloats; var encodeFloats = ol.parser.polyline.encodeFloats;
expect(encodeFloats(smallFloats)).toEqual(encodedFloats); expect(encodeFloats(smallFloats)).to.eql(encodedFloats);
resetTestingData(); resetTestingData();
expect(encodeFloats(smallFloats, 1e5)).toEqual(encodedFloats); expect(encodeFloats(smallFloats, 1e5)).to.eql(encodedFloats);
expect(encodeFloats(floats, 1e2)).toEqual(encodedFloats); expect(encodeFloats(floats, 1e2)).to.eql(encodedFloats);
}); });
}); });
@@ -84,9 +84,9 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var decodeFloats = ol.parser.polyline.decodeFloats; var decodeFloats = ol.parser.polyline.decodeFloats;
expect(decodeFloats(encodedFloats)).toEqual(smallFloats); expect(decodeFloats(encodedFloats)).to.eql(smallFloats);
expect(decodeFloats(encodedFloats, 1e5)).toEqual(smallFloats); expect(decodeFloats(encodedFloats, 1e5)).to.eql(smallFloats);
expect(decodeFloats(encodedFloats, 1e2)).toEqual(floats); expect(decodeFloats(encodedFloats, 1e2)).to.eql(floats);
}); });
}); });
@@ -97,7 +97,7 @@ describe('ol.parser.polyline', function() {
var encodeSignedIntegers = ol.parser.polyline.encodeSignedIntegers; var encodeSignedIntegers = ol.parser.polyline.encodeSignedIntegers;
expect(encodeSignedIntegers( expect(encodeSignedIntegers(
signedIntegers)).toEqual(encodedSignedIntegers); signedIntegers)).to.eql(encodedSignedIntegers);
}); });
}); });
@@ -106,7 +106,7 @@ describe('ol.parser.polyline', function() {
var decodeSignedIntegers = ol.parser.polyline.decodeSignedIntegers; var decodeSignedIntegers = ol.parser.polyline.decodeSignedIntegers;
expect(decodeSignedIntegers( expect(decodeSignedIntegers(
encodedSignedIntegers)).toEqual(signedIntegers); encodedSignedIntegers)).to.eql(signedIntegers);
}); });
}); });
@@ -117,7 +117,7 @@ describe('ol.parser.polyline', function() {
var encodeUnsignedIntegers = ol.parser.polyline.encodeUnsignedIntegers; var encodeUnsignedIntegers = ol.parser.polyline.encodeUnsignedIntegers;
expect(encodeUnsignedIntegers( expect(encodeUnsignedIntegers(
unsignedIntegers)).toEqual(encodedUnsignedIntegers); unsignedIntegers)).to.eql(encodedUnsignedIntegers);
}); });
}); });
@@ -126,7 +126,7 @@ describe('ol.parser.polyline', function() {
var decodeUnsignedIntegers = ol.parser.polyline.decodeUnsignedIntegers; var decodeUnsignedIntegers = ol.parser.polyline.decodeUnsignedIntegers;
expect(decodeUnsignedIntegers( expect(decodeUnsignedIntegers(
encodedUnsignedIntegers)).toEqual(unsignedIntegers); encodedUnsignedIntegers)).to.eql(unsignedIntegers);
}); });
}); });
@@ -136,22 +136,22 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var encodeFloat = ol.parser.polyline.encodeFloat; var encodeFloat = ol.parser.polyline.encodeFloat;
expect(encodeFloat(0.00000)).toEqual('?'); expect(encodeFloat(0.00000)).to.eql('?');
expect(encodeFloat(-0.00001)).toEqual('@'); expect(encodeFloat(-0.00001)).to.eql('@');
expect(encodeFloat(0.00001)).toEqual('A'); expect(encodeFloat(0.00001)).to.eql('A');
expect(encodeFloat(-0.00002)).toEqual('B'); expect(encodeFloat(-0.00002)).to.eql('B');
expect(encodeFloat(0.00002)).toEqual('C'); expect(encodeFloat(0.00002)).to.eql('C');
expect(encodeFloat(0.00015)).toEqual(']'); expect(encodeFloat(0.00015)).to.eql(']');
expect(encodeFloat(-0.00016)).toEqual('^'); expect(encodeFloat(-0.00016)).to.eql('^');
expect(encodeFloat(-0.1, 10)).toEqual('@'); expect(encodeFloat(-0.1, 10)).to.eql('@');
expect(encodeFloat(0.1, 10)).toEqual('A'); expect(encodeFloat(0.1, 10)).to.eql('A');
expect(encodeFloat(16 * 32 / 1e5)).toEqual('__@'); expect(encodeFloat(16 * 32 / 1e5)).to.eql('__@');
expect(encodeFloat(16 * 32 * 32 / 1e5)).toEqual('___@'); expect(encodeFloat(16 * 32 * 32 / 1e5)).to.eql('___@');
// from the "Encoded Polyline Algorithm Format" page at Google // from the "Encoded Polyline Algorithm Format" page at Google
expect(encodeFloat(-179.9832104)).toEqual('`~oia@'); expect(encodeFloat(-179.9832104)).to.eql('`~oia@');
}); });
}); });
@@ -159,22 +159,22 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var decodeFloat = ol.parser.polyline.decodeFloat; var decodeFloat = ol.parser.polyline.decodeFloat;
expect(decodeFloat('?')).toEqual(0.00000); expect(decodeFloat('?')).to.eql(0.00000);
expect(decodeFloat('@')).toEqual(-0.00001); expect(decodeFloat('@')).to.eql(-0.00001);
expect(decodeFloat('A')).toEqual(0.00001); expect(decodeFloat('A')).to.eql(0.00001);
expect(decodeFloat('B')).toEqual(-0.00002); expect(decodeFloat('B')).to.eql(-0.00002);
expect(decodeFloat('C')).toEqual(0.00002); expect(decodeFloat('C')).to.eql(0.00002);
expect(decodeFloat(']')).toEqual(0.00015); expect(decodeFloat(']')).to.eql(0.00015);
expect(decodeFloat('^')).toEqual(-0.00016); expect(decodeFloat('^')).to.eql(-0.00016);
expect(decodeFloat('@', 10)).toEqual(-0.1); expect(decodeFloat('@', 10)).to.eql(-0.1);
expect(decodeFloat('A', 10)).toEqual(0.1); expect(decodeFloat('A', 10)).to.eql(0.1);
expect(decodeFloat('__@')).toEqual(16 * 32 / 1e5); expect(decodeFloat('__@')).to.eql(16 * 32 / 1e5);
expect(decodeFloat('___@')).toEqual(16 * 32 * 32 / 1e5); expect(decodeFloat('___@')).to.eql(16 * 32 * 32 / 1e5);
// from the "Encoded Polyline Algorithm Format" page at Google // from the "Encoded Polyline Algorithm Format" page at Google
expect(decodeFloat('`~oia@')).toEqual(-179.98321); expect(decodeFloat('`~oia@')).to.eql(-179.98321);
}); });
}); });
@@ -184,17 +184,17 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var encodeSignedInteger = ol.parser.polyline.encodeSignedInteger; var encodeSignedInteger = ol.parser.polyline.encodeSignedInteger;
expect(encodeSignedInteger(0)).toEqual('?'); expect(encodeSignedInteger(0)).to.eql('?');
expect(encodeSignedInteger(-1)).toEqual('@'); expect(encodeSignedInteger(-1)).to.eql('@');
expect(encodeSignedInteger(1)).toEqual('A'); expect(encodeSignedInteger(1)).to.eql('A');
expect(encodeSignedInteger(-2)).toEqual('B'); expect(encodeSignedInteger(-2)).to.eql('B');
expect(encodeSignedInteger(2)).toEqual('C'); expect(encodeSignedInteger(2)).to.eql('C');
expect(encodeSignedInteger(15)).toEqual(']'); expect(encodeSignedInteger(15)).to.eql(']');
expect(encodeSignedInteger(-16)).toEqual('^'); expect(encodeSignedInteger(-16)).to.eql('^');
expect(encodeSignedInteger(16)).toEqual('_@'); expect(encodeSignedInteger(16)).to.eql('_@');
expect(encodeSignedInteger(16 * 32)).toEqual('__@'); expect(encodeSignedInteger(16 * 32)).to.eql('__@');
expect(encodeSignedInteger(16 * 32 * 32)).toEqual('___@'); expect(encodeSignedInteger(16 * 32 * 32)).to.eql('___@');
}); });
}); });
@@ -202,17 +202,17 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var decodeSignedInteger = ol.parser.polyline.decodeSignedInteger; var decodeSignedInteger = ol.parser.polyline.decodeSignedInteger;
expect(decodeSignedInteger('?')).toEqual(0); expect(decodeSignedInteger('?')).to.eql(0);
expect(decodeSignedInteger('@')).toEqual(-1); expect(decodeSignedInteger('@')).to.eql(-1);
expect(decodeSignedInteger('A')).toEqual(1); expect(decodeSignedInteger('A')).to.eql(1);
expect(decodeSignedInteger('B')).toEqual(-2); expect(decodeSignedInteger('B')).to.eql(-2);
expect(decodeSignedInteger('C')).toEqual(2); expect(decodeSignedInteger('C')).to.eql(2);
expect(decodeSignedInteger(']')).toEqual(15); expect(decodeSignedInteger(']')).to.eql(15);
expect(decodeSignedInteger('^')).toEqual(-16); expect(decodeSignedInteger('^')).to.eql(-16);
expect(decodeSignedInteger('_@')).toEqual(16); expect(decodeSignedInteger('_@')).to.eql(16);
expect(decodeSignedInteger('__@')).toEqual(16 * 32); expect(decodeSignedInteger('__@')).to.eql(16 * 32);
expect(decodeSignedInteger('___@')).toEqual(16 * 32 * 32); expect(decodeSignedInteger('___@')).to.eql(16 * 32 * 32);
}); });
}); });
@@ -222,19 +222,19 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var encodeUnsignedInteger = ol.parser.polyline.encodeUnsignedInteger; var encodeUnsignedInteger = ol.parser.polyline.encodeUnsignedInteger;
expect(encodeUnsignedInteger(0)).toEqual('?'); expect(encodeUnsignedInteger(0)).to.eql('?');
expect(encodeUnsignedInteger(1)).toEqual('@'); expect(encodeUnsignedInteger(1)).to.eql('@');
expect(encodeUnsignedInteger(2)).toEqual('A'); expect(encodeUnsignedInteger(2)).to.eql('A');
expect(encodeUnsignedInteger(30)).toEqual(']'); expect(encodeUnsignedInteger(30)).to.eql(']');
expect(encodeUnsignedInteger(31)).toEqual('^'); expect(encodeUnsignedInteger(31)).to.eql('^');
expect(encodeUnsignedInteger(32)).toEqual('_@'); expect(encodeUnsignedInteger(32)).to.eql('_@');
expect(encodeUnsignedInteger(32 * 32)).toEqual('__@'); expect(encodeUnsignedInteger(32 * 32)).to.eql('__@');
expect(encodeUnsignedInteger(5 * 32 * 32)).toEqual('__D'); expect(encodeUnsignedInteger(5 * 32 * 32)).to.eql('__D');
expect(encodeUnsignedInteger(32 * 32 * 32)).toEqual('___@'); expect(encodeUnsignedInteger(32 * 32 * 32)).to.eql('___@');
// from the "Encoded Polyline Algorithm Format" page at Google // from the "Encoded Polyline Algorithm Format" page at Google
expect(encodeUnsignedInteger(174)).toEqual('mD'); expect(encodeUnsignedInteger(174)).to.eql('mD');
}); });
}); });
@@ -242,19 +242,19 @@ describe('ol.parser.polyline', function() {
it('returns expected value', function() { it('returns expected value', function() {
var decodeUnsignedInteger = ol.parser.polyline.decodeUnsignedInteger; var decodeUnsignedInteger = ol.parser.polyline.decodeUnsignedInteger;
expect(decodeUnsignedInteger('?')).toEqual(0); expect(decodeUnsignedInteger('?')).to.eql(0);
expect(decodeUnsignedInteger('@')).toEqual(1); expect(decodeUnsignedInteger('@')).to.eql(1);
expect(decodeUnsignedInteger('A')).toEqual(2); expect(decodeUnsignedInteger('A')).to.eql(2);
expect(decodeUnsignedInteger(']')).toEqual(30); expect(decodeUnsignedInteger(']')).to.eql(30);
expect(decodeUnsignedInteger('^')).toEqual(31); expect(decodeUnsignedInteger('^')).to.eql(31);
expect(decodeUnsignedInteger('_@')).toEqual(32); expect(decodeUnsignedInteger('_@')).to.eql(32);
expect(decodeUnsignedInteger('__@')).toEqual(32 * 32); expect(decodeUnsignedInteger('__@')).to.eql(32 * 32);
expect(decodeUnsignedInteger('__D')).toEqual(5 * 32 * 32); expect(decodeUnsignedInteger('__D')).to.eql(5 * 32 * 32);
expect(decodeUnsignedInteger('___@')).toEqual(32 * 32 * 32); expect(decodeUnsignedInteger('___@')).to.eql(32 * 32 * 32);
// from the "Encoded Polyline Algorithm Format" page at Google // from the "Encoded Polyline Algorithm Format" page at Google
expect(decodeUnsignedInteger('mD')).toEqual(174); expect(decodeUnsignedInteger('mD')).to.eql(174);
}); });
}); });
}); });

View File

@@ -11,7 +11,7 @@ describe('ol.projection.EPSG3857', function() {
var resolution = 19.11; var resolution = 19.11;
var point = new ol.Coordinate(0, 0); var point = new ol.Coordinate(0, 0);
expect(epsg3857.getPointResolution(resolution, point)). expect(epsg3857.getPointResolution(resolution, point)).
toRoughlyEqual(19.11, 1e-1); to.roughlyEqual(19.11, 1e-1);
}); });
it('returns the correct point scale at the latitude of Toronto', it('returns the correct point scale at the latitude of Toronto',
@@ -23,7 +23,7 @@ describe('ol.projection.EPSG3857', function() {
var point = ol.projection.transform( var point = ol.projection.transform(
new ol.Coordinate(0, 43.65), epsg4326, epsg3857); new ol.Coordinate(0, 43.65), epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)). expect(epsg3857.getPointResolution(resolution, point)).
toRoughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9); to.roughlyEqual(19.11 * Math.cos(Math.PI * 43.65 / 180), 1e-9);
}); });
it('returns the correct point scale at various latitudes', function() { it('returns the correct point scale at various latitudes', function() {
@@ -36,7 +36,7 @@ describe('ol.projection.EPSG3857', function() {
var point = ol.projection.transform( var point = ol.projection.transform(
new ol.Coordinate(0, latitude), epsg4326, epsg3857); new ol.Coordinate(0, latitude), epsg4326, epsg3857);
expect(epsg3857.getPointResolution(resolution, point)). expect(epsg3857.getPointResolution(resolution, point)).
toRoughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9); to.roughlyEqual(19.11 * Math.cos(Math.PI * latitude / 180), 1e-9);
} }
}); });

View File

@@ -3,11 +3,11 @@ goog.provide('ol.test.Projection');
describe('ol.projection', function() { describe('ol.projection', function() {
beforeEach(function() { beforeEach(function() {
spyOn(ol.projection, 'addTransform').andCallThrough(); sinon.spy(ol.projection, 'addTransform');
}); });
afterEach(function() { afterEach(function() {
var argsForCall = ol.projection.addTransform.argsForCall; var argsForCall = ol.projection.addTransform.args;
for (var i = 0, ii = argsForCall.length; i < ii; ++i) { for (var i = 0, ii = argsForCall.length; i < ii; ++i) {
try { try {
ol.projection.removeTransform.apply( ol.projection.removeTransform.apply(
@@ -21,6 +21,7 @@ describe('ol.projection', function() {
} }
} }
} }
ol.projection.addTransform.restore();
}); });
describe('projection equivalence', function() { describe('projection equivalence', function() {
@@ -29,7 +30,7 @@ describe('ol.projection', function() {
var projections = goog.array.map(codes, ol.projection.get); var projections = goog.array.map(codes, ol.projection.get);
goog.array.forEach(projections, function(source) { goog.array.forEach(projections, function(source) {
goog.array.forEach(projections, function(destination) { goog.array.forEach(projections, function(destination) {
expect(ol.projection.equivalent(source, destination)).toBeTruthy(); expect(ol.projection.equivalent(source, destination)).to.be.ok();
}); });
}); });
} }
@@ -61,9 +62,9 @@ describe('ol.projection', function() {
var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject); var sourcePoint = new ol.Coordinate(uniqueObject, uniqueObject);
var destinationPoint = ol.projection.transform( var destinationPoint = ol.projection.transform(
sourcePoint, epsg4326, epsg4326); sourcePoint, epsg4326, epsg4326);
expect(sourcePoint === destinationPoint).toBeFalsy(); expect(sourcePoint === destinationPoint).to.not.be();
expect(destinationPoint.x === sourcePoint.x).toBeTruthy(); expect(destinationPoint.x === sourcePoint.x).to.be.ok();
expect(destinationPoint.y === sourcePoint.y).toBeTruthy(); expect(destinationPoint.y === sourcePoint.y).to.be.ok();
}); });
}); });
@@ -72,9 +73,9 @@ describe('ol.projection', function() {
it('returns expected value', function() { it('returns expected value', function() {
var point = ol.projection.transform( var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857'); new ol.Coordinate(0, 0), 'EPSG:4326', 'EPSG:3857');
expect(point).not.toBeUndefined(); expect(point).not.to.be(undefined);
expect(point).not.toBeNull(); expect(point).not.to.be(null);
expect(point.y).toRoughlyEqual(0, 1e-9); expect(point.y).to.roughlyEqual(0, 1e-9);
}); });
}); });
@@ -83,10 +84,10 @@ describe('ol.projection', function() {
it('returns expected value', function() { it('returns expected value', function() {
var point = ol.projection.transform( var point = ol.projection.transform(
new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326'); new ol.Coordinate(0, 0), 'EPSG:3857', 'EPSG:4326');
expect(point).not.toBeUndefined(); expect(point).not.to.be(undefined);
expect(point).not.toBeNull(); expect(point).not.to.be(null);
expect(point.x).toEqual(0); expect(point.x).to.eql(0);
expect(point.y).toEqual(0); expect(point.y).to.eql(0);
}); });
}); });
@@ -98,10 +99,10 @@ describe('ol.projection', function() {
new ol.Coordinate(-5.625, 52.4827802220782), new ol.Coordinate(-5.625, 52.4827802220782),
'EPSG:4326', 'EPSG:4326',
'EPSG:900913'); 'EPSG:900913');
expect(point).not.toBeUndefined(); expect(point).not.to.be(undefined);
expect(point).not.toBeNull(); expect(point).not.to.be(null);
expect(point.x).toRoughlyEqual(-626172.13571216376, 1e-9); expect(point.x).to.roughlyEqual(-626172.13571216376, 1e-9);
expect(point.y).toRoughlyEqual(6887893.4928337997, 1e-8); expect(point.y).to.roughlyEqual(6887893.4928337997, 1e-8);
}); });
}); });
@@ -113,10 +114,10 @@ describe('ol.projection', function() {
new ol.Coordinate(-626172.13571216376, 6887893.4928337997), new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
'EPSG:900913', 'EPSG:900913',
'EPSG:4326'); 'EPSG:4326');
expect(point).not.toBeUndefined(); expect(point).not.to.be(undefined);
expect(point).not.toBeNull(); expect(point).not.to.be(null);
expect(point.x).toRoughlyEqual(-5.625, 1e-9); expect(point.x).to.roughlyEqual(-5.625, 1e-9);
expect(point.y).toRoughlyEqual(52.4827802220782, 1e-9); expect(point.y).to.roughlyEqual(52.4827802220782, 1e-9);
}); });
}); });
@@ -127,8 +128,8 @@ describe('ol.projection', function() {
new ol.Coordinate(-626172.13571216376, 6887893.4928337997), new ol.Coordinate(-626172.13571216376, 6887893.4928337997),
'GOOGLE', 'GOOGLE',
'WGS84'); 'WGS84');
expect(point.x).toRoughlyEqual(-5.625, 1e-9); expect(point.x).to.roughlyEqual(-5.625, 1e-9);
expect(point.y).toRoughlyEqual(52.4827802220782, 1e-9); expect(point.y).to.roughlyEqual(52.4827802220782, 1e-9);
}); });
it('allows new Proj4js projections to be defined', function() { it('allows new Proj4js projections to be defined', function() {
@@ -140,8 +141,8 @@ describe('ol.projection', function() {
new ol.Coordinate(7.439583333333333, 46.95240555555556), new ol.Coordinate(7.439583333333333, 46.95240555555556),
'EPSG:4326', 'EPSG:4326',
'EPSG:21781'); 'EPSG:21781');
expect(point.x).toRoughlyEqual(600072.300, 1); expect(point.x).to.roughlyEqual(600072.300, 1);
expect(point.y).toRoughlyEqual(200146.976, 1); expect(point.y).to.roughlyEqual(200146.976, 1);
}); });
it('caches the new Proj4js projections given their srsCode', function() { it('caches the new Proj4js projections given their srsCode', function() {
@@ -153,17 +154,17 @@ describe('ol.projection', function() {
var srsCode = 'EPSG:21781'; var srsCode = 'EPSG:21781';
var proj = ol.projection.get(code); var proj = ol.projection.get(code);
expect(ol.projection.proj4jsProjections_.hasOwnProperty(code)) expect(ol.projection.proj4jsProjections_.hasOwnProperty(code))
.toBeTruthy(); .to.be.ok();
expect(ol.projection.proj4jsProjections_.hasOwnProperty(srsCode)) expect(ol.projection.proj4jsProjections_.hasOwnProperty(srsCode))
.toBeTruthy(); .to.be.ok();
var proj2 = ol.projection.get(srsCode); var proj2 = ol.projection.get(srsCode);
expect(proj2).toBe(proj); expect(proj2).to.be(proj);
}); });
it('numerically estimates point scale at the equator', function() { it('numerically estimates point scale at the equator', function() {
var googleProjection = ol.projection.get('GOOGLE'); var googleProjection = ol.projection.get('GOOGLE');
expect(googleProjection.getPointResolution(1, new ol.Coordinate(0, 0))). expect(googleProjection.getPointResolution(1, new ol.Coordinate(0, 0))).
toRoughlyEqual(1, 1e-1); to.roughlyEqual(1, 1e-1);
}); });
it('numerically estimates point scale at various latitudes', function() { it('numerically estimates point scale at various latitudes', function() {
@@ -172,7 +173,7 @@ describe('ol.projection', function() {
var point, y; var point, y;
for (y = -20; y <= 20; ++y) { for (y = -20; y <= 20; ++y) {
point = new ol.Coordinate(0, 1000000 * y); point = new ol.Coordinate(0, 1000000 * y);
expect(googleProjection.getPointResolution(1, point)).toRoughlyEqual( expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
epsg3857Projection.getPointResolution(1, point), 1e-1); epsg3857Projection.getPointResolution(1, point), 1e-1);
} }
}); });
@@ -184,7 +185,7 @@ describe('ol.projection', function() {
for (x = -20; x <= 20; ++x) { for (x = -20; x <= 20; ++x) {
for (y = -20; y <= 20; ++y) { for (y = -20; y <= 20; ++y) {
point = new ol.Coordinate(1000000 * x, 1000000 * y); point = new ol.Coordinate(1000000 * x, 1000000 * y);
expect(googleProjection.getPointResolution(1, point)).toRoughlyEqual( expect(googleProjection.getPointResolution(1, point)).to.roughlyEqual(
epsg3857Projection.getPointResolution(1, point), 1e-1); epsg3857Projection.getPointResolution(1, point), 1e-1);
} }
} }
@@ -199,24 +200,24 @@ describe('ol.projection', function() {
it('returns a transform function', function() { it('returns a transform function', function() {
var transform = ol.projection.getTransformFromProjections(sm, gg); var transform = ol.projection.getTransformFromProjections(sm, gg);
expect(typeof transform).toBe('function'); expect(typeof transform).to.be('function');
var output = transform([-12000000, 5000000]); var output = transform([-12000000, 5000000]);
expect(output[0]).toRoughlyEqual(-107.79783409434258, 1e-9); expect(output[0]).to.roughlyEqual(-107.79783409434258, 1e-9);
expect(output[1]).toRoughlyEqual(40.91627447067577, 1e-9); expect(output[1]).to.roughlyEqual(40.91627447067577, 1e-9);
}); });
it('works for longer arrays', function() { it('works for longer arrays', function() {
var transform = ol.projection.getTransformFromProjections(sm, gg); var transform = ol.projection.getTransformFromProjections(sm, gg);
expect(typeof transform).toBe('function'); expect(typeof transform).to.be('function');
var output = transform([-12000000, 5000000, -12000000, 5000000]); var output = transform([-12000000, 5000000, -12000000, 5000000]);
expect(output[0]).toRoughlyEqual(-107.79783409434258, 1e-9); expect(output[0]).to.roughlyEqual(-107.79783409434258, 1e-9);
expect(output[1]).toRoughlyEqual(40.91627447067577, 1e-9); expect(output[1]).to.roughlyEqual(40.91627447067577, 1e-9);
expect(output[2]).toRoughlyEqual(-107.79783409434258, 1e-9); expect(output[2]).to.roughlyEqual(-107.79783409434258, 1e-9);
expect(output[3]).toRoughlyEqual(40.91627447067577, 1e-9); expect(output[3]).to.roughlyEqual(40.91627447067577, 1e-9);
}); });
}); });
@@ -225,23 +226,23 @@ describe('ol.projection', function() {
it('returns a function', function() { it('returns a function', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function'); expect(typeof transform).to.be('function');
}); });
it('returns a transform function', function() { it('returns a transform function', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function'); expect(typeof transform).to.be('function');
var output = transform([-626172.13571216376, 6887893.4928337997]); var output = transform([-626172.13571216376, 6887893.4928337997]);
expect(output[0]).toRoughlyEqual(-5.625, 1e-9); expect(output[0]).to.roughlyEqual(-5.625, 1e-9);
expect(output[1]).toRoughlyEqual(52.4827802220782, 1e-9); expect(output[1]).to.roughlyEqual(52.4827802220782, 1e-9);
}); });
it('works for longer arrays of coordinate values', function() { it('works for longer arrays of coordinate values', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function'); expect(typeof transform).to.be('function');
var output = transform([ var output = transform([
-626172.13571216376, 6887893.4928337997, -626172.13571216376, 6887893.4928337997,
@@ -249,12 +250,12 @@ describe('ol.projection', function() {
-626172.13571216376, 6887893.4928337997 -626172.13571216376, 6887893.4928337997
]); ]);
expect(output[0]).toRoughlyEqual(-5.625, 1e-9); expect(output[0]).to.roughlyEqual(-5.625, 1e-9);
expect(output[1]).toRoughlyEqual(52.4827802220782, 1e-9); expect(output[1]).to.roughlyEqual(52.4827802220782, 1e-9);
expect(output[2]).toRoughlyEqual(-107.79783409434258, 1e-9); expect(output[2]).to.roughlyEqual(-107.79783409434258, 1e-9);
expect(output[3]).toRoughlyEqual(40.91627447067577, 1e-9); expect(output[3]).to.roughlyEqual(40.91627447067577, 1e-9);
expect(output[4]).toRoughlyEqual(-5.625, 1e-9); expect(output[4]).to.roughlyEqual(-5.625, 1e-9);
expect(output[5]).toRoughlyEqual(52.4827802220782, 1e-9); expect(output[5]).to.roughlyEqual(52.4827802220782, 1e-9);
}); });
it('accepts an optional destination array', function() { it('accepts an optional destination array', function() {
@@ -263,17 +264,17 @@ describe('ol.projection', function() {
var output = []; var output = [];
var got = transform(input, output); var got = transform(input, output);
expect(got).toBe(output); expect(got).to.be(output);
expect(output[0]).toRoughlyEqual(-107.79783409434258, 1e-9); expect(output[0]).to.roughlyEqual(-107.79783409434258, 1e-9);
expect(output[1]).toRoughlyEqual(40.91627447067577, 1e-9); expect(output[1]).to.roughlyEqual(40.91627447067577, 1e-9);
expect(input).toEqual([-12000000, 5000000]); expect(input).to.eql([-12000000, 5000000]);
}); });
it('accepts a dimension', function() { it('accepts a dimension', function() {
var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326'); var transform = ol.projection.getTransform('GOOGLE', 'EPSG:4326');
expect(typeof transform).toBe('function'); expect(typeof transform).to.be('function');
var dimension = 3; var dimension = 3;
var output = transform([ var output = transform([
@@ -282,15 +283,15 @@ describe('ol.projection', function() {
-626172.13571216376, 6887893.4928337997, 300 -626172.13571216376, 6887893.4928337997, 300
], undefined, dimension); ], undefined, dimension);
expect(output[0]).toRoughlyEqual(-5.625, 1e-9); expect(output[0]).to.roughlyEqual(-5.625, 1e-9);
expect(output[1]).toRoughlyEqual(52.4827802220782, 1e-9); expect(output[1]).to.roughlyEqual(52.4827802220782, 1e-9);
expect(output[2]).toBe(100); expect(output[2]).to.be(100);
expect(output[3]).toRoughlyEqual(-107.79783409434258, 1e-9); expect(output[3]).to.roughlyEqual(-107.79783409434258, 1e-9);
expect(output[4]).toRoughlyEqual(40.91627447067577, 1e-9); expect(output[4]).to.roughlyEqual(40.91627447067577, 1e-9);
expect(output[5]).toBe(200); expect(output[5]).to.be(200);
expect(output[6]).toRoughlyEqual(-5.625, 1e-9); expect(output[6]).to.roughlyEqual(-5.625, 1e-9);
expect(output[7]).toRoughlyEqual(52.4827802220782, 1e-9); expect(output[7]).to.roughlyEqual(52.4827802220782, 1e-9);
expect(output[8]).toBe(300); expect(output[8]).to.be(300);
}); });
}); });
@@ -312,13 +313,13 @@ describe('ol.projection', function() {
}); });
var transform = function(input, output, dimension) {return input}; var transform = function(input, output, dimension) {return input};
ol.projection.addTransform(foo, bar, transform); ol.projection.addTransform(foo, bar, transform);
expect(ol.projection.transforms_).not.toBeUndefined(); expect(ol.projection.transforms_).not.to.be(undefined);
expect(ol.projection.transforms_.foo).not.toBeUndefined(); expect(ol.projection.transforms_.foo).not.to.be(undefined);
expect(ol.projection.transforms_.foo.bar).toBe(transform); expect(ol.projection.transforms_.foo.bar).to.be(transform);
var removed = ol.projection.removeTransform(foo, bar); var removed = ol.projection.removeTransform(foo, bar);
expect(removed).toBe(transform); expect(removed).to.be(transform);
expect(ol.projection.transforms_.foo).toBeUndefined(); expect(ol.projection.transforms_.foo).to.be(undefined);
}); });
}); });
@@ -327,7 +328,7 @@ describe('ol.projection', function() {
it('returns value in meters', function() { it('returns value in meters', function() {
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.projection.get('EPSG:4326');
expect(epsg4326.getMetersPerUnit()).toEqual(111194.87428468118); expect(epsg4326.getMetersPerUnit()).to.eql(111194.87428468118);
}); });
}); });
@@ -345,10 +346,10 @@ describe('ol.projection', function() {
code: 'EPSG:21781', code: 'EPSG:21781',
extent: extent extent: extent
}); });
expect(epsg21781.getCode()).toEqual('EPSG:21781'); expect(epsg21781.getCode()).to.eql('EPSG:21781');
expect(epsg21781.getExtent()).toBe(extent); expect(epsg21781.getExtent()).to.be(extent);
expect(epsg21781.getUnits()).toBe(ol.ProjectionUnits.METERS); expect(epsg21781.getUnits()).to.be(ol.ProjectionUnits.METERS);
expect(epsg21781.isGlobal()).toBeFalsy(); expect(epsg21781.isGlobal()).to.not.be();
}); });
}); });

View File

@@ -6,8 +6,8 @@ describe('ol.Rectangle', function() {
it('returns the expected center', function() { it('returns the expected center', function() {
var rectangle = new ol.Rectangle(1, 2, 3, 4); var rectangle = new ol.Rectangle(1, 2, 3, 4);
var center = rectangle.getCenter(); var center = rectangle.getCenter();
expect(center.x).toEqual(2); expect(center.x).to.eql(2);
expect(center.y).toEqual(3); expect(center.y).to.eql(3);
}); });
}); });
@@ -17,41 +17,39 @@ describe('ol.Rectangle', function() {
beforeEach(function() { beforeEach(function() {
rectangle1 = new ol.Rectangle(50, 50, 100, 100); rectangle1 = new ol.Rectangle(50, 50, 100, 100);
this.addMatchers({ expect.Assertion.prototype.intersectWith = function(other) {
toIntersects: function(other) { return this.obj.intersects(other);
return this.actual.intersects(other); };
}
});
}); });
it('returns the expected value', function() { it('returns the expected value', function() {
expect(rectangle1).toIntersects(rectangle1); expect(rectangle1).to.intersectWith(rectangle1);
expect(rectangle1).toIntersects(new ol.Rectangle(20, 20, 80, 80)); expect(rectangle1).to.intersectWith(new ol.Rectangle(20, 20, 80, 80));
expect(rectangle1).toIntersects(new ol.Rectangle(20, 50, 80, 100)); expect(rectangle1).to.intersectWith(new ol.Rectangle(20, 50, 80, 100));
expect(rectangle1).toIntersects(new ol.Rectangle(20, 80, 80, 120)); expect(rectangle1).to.intersectWith(new ol.Rectangle(20, 80, 80, 120));
expect(rectangle1).toIntersects(new ol.Rectangle(50, 20, 100, 80)); expect(rectangle1).to.intersectWith(new ol.Rectangle(50, 20, 100, 80));
expect(rectangle1).toIntersects(new ol.Rectangle(50, 80, 100, 120)); expect(rectangle1).to.intersectWith(new ol.Rectangle(50, 80, 100, 120));
expect(rectangle1).toIntersects(new ol.Rectangle(80, 20, 120, 80)); expect(rectangle1).to.intersectWith(new ol.Rectangle(80, 20, 120, 80));
expect(rectangle1).toIntersects(new ol.Rectangle(80, 50, 120, 100)); expect(rectangle1).to.intersectWith(new ol.Rectangle(80, 50, 120, 100));
expect(rectangle1).toIntersects(new ol.Rectangle(80, 80, 120, 120)); expect(rectangle1).to.intersectWith(new ol.Rectangle(80, 80, 120, 120));
expect(rectangle1).toIntersects(new ol.Rectangle(20, 20, 120, 120)); expect(rectangle1).to.intersectWith(new ol.Rectangle(20, 20, 120, 120));
expect(rectangle1).toIntersects(new ol.Rectangle(70, 70, 80, 80)); expect(rectangle1).to.intersectWith(new ol.Rectangle(70, 70, 80, 80));
expect(rectangle1).not.toIntersects(new ol.Rectangle(10, 10, 30, 30)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(10, 10, 30, 30));
expect(rectangle1).not.toIntersects(new ol.Rectangle(30, 10, 70, 30)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(30, 10, 70, 30));
expect(rectangle1).not.toIntersects(new ol.Rectangle(50, 10, 100, 30)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(50, 10, 100, 30));
expect(rectangle1).not.toIntersects(new ol.Rectangle(80, 10, 120, 30)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(80, 10, 120, 30));
expect(rectangle1).not.toIntersects(new ol.Rectangle(120, 10, 140, 30)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(120, 10, 140, 30));
expect(rectangle1).not.toIntersects(new ol.Rectangle(10, 30, 30, 70)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(10, 30, 30, 70));
expect(rectangle1).not.toIntersects(new ol.Rectangle(120, 30, 140, 70)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(120, 30, 140, 70));
expect(rectangle1).not.toIntersects(new ol.Rectangle(10, 50, 30, 100)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(10, 50, 30, 100));
expect(rectangle1).not.toIntersects(new ol.Rectangle(120, 50, 140, 100)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(120, 50, 140, 100));
expect(rectangle1).not.toIntersects(new ol.Rectangle(10, 80, 30, 120)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(10, 80, 30, 120));
expect(rectangle1).not.toIntersects(new ol.Rectangle(120, 80, 140, 120)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(120, 80, 140, 120));
expect(rectangle1).not.toIntersects(new ol.Rectangle(10, 120, 30, 140)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(10, 120, 30, 140));
expect(rectangle1).not.toIntersects(new ol.Rectangle(30, 120, 70, 140)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(30, 120, 70, 140));
expect(rectangle1).not.toIntersects(new ol.Rectangle(50, 120, 100, 140)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(50, 120, 100, 140));
expect(rectangle1).not.toIntersects(new ol.Rectangle(80, 120, 120, 140)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(80, 120, 120, 140));
expect(rectangle1).not.toIntersects(new ol.Rectangle(120, 120, 140, 140)); expect(rectangle1).to.not.intersectWith(new ol.Rectangle(120, 120, 140, 140));
}); });
}); });
@@ -59,8 +57,8 @@ describe('ol.Rectangle', function() {
it('returns the expected size', function() { it('returns the expected size', function() {
var rectangle = new ol.Rectangle(0, 1, 2, 4); var rectangle = new ol.Rectangle(0, 1, 2, 4);
var size = rectangle.getSize(); var size = rectangle.getSize();
expect(size.width).toEqual(2); expect(size.width).to.eql(2);
expect(size.height).toEqual(3); expect(size.height).to.eql(3);
}); });
}); });
@@ -70,31 +68,31 @@ describe('ol.Rectangle', function() {
var coordinate; var coordinate;
coordinate = rectangle.normalize(new ol.Coordinate(1, 2)); coordinate = rectangle.normalize(new ol.Coordinate(1, 2));
expect(coordinate.x).toEqual(0.5); expect(coordinate.x).to.eql(0.5);
expect(coordinate.y).toEqual(0.5); expect(coordinate.y).to.eql(0.5);
coordinate = rectangle.normalize(new ol.Coordinate(0, 3)); coordinate = rectangle.normalize(new ol.Coordinate(0, 3));
expect(coordinate.x).toEqual(0); expect(coordinate.x).to.eql(0);
expect(coordinate.y).toEqual(1); expect(coordinate.y).to.eql(1);
coordinate = rectangle.normalize(new ol.Coordinate(2, 1)); coordinate = rectangle.normalize(new ol.Coordinate(2, 1));
expect(coordinate.x).toEqual(1); expect(coordinate.x).to.eql(1);
expect(coordinate.y).toEqual(0); expect(coordinate.y).to.eql(0);
coordinate = rectangle.normalize(new ol.Coordinate(0, 0)); coordinate = rectangle.normalize(new ol.Coordinate(0, 0));
expect(coordinate.x).toEqual(0); expect(coordinate.x).to.eql(0);
expect(coordinate.y).toEqual(-0.5); expect(coordinate.y).to.eql(-0.5);
coordinate = rectangle.normalize(new ol.Coordinate(-1, 1)); coordinate = rectangle.normalize(new ol.Coordinate(-1, 1));
expect(coordinate.x).toEqual(-0.5); expect(coordinate.x).to.eql(-0.5);
expect(coordinate.y).toEqual(0); expect(coordinate.y).to.eql(0);
}); });
}); });
describe('toString', function() { describe('toString', function() {
it('returns the expected string', function() { it('returns the expected string', function() {
var rectangle = new ol.Rectangle(0, 1, 2, 3); var rectangle = new ol.Rectangle(0, 1, 2, 3);
expect(rectangle.toString()).toEqual('(0, 1, 2, 3)'); expect(rectangle.toString()).to.eql('(0, 1, 2, 3)');
}); });
}); });
@@ -102,10 +100,10 @@ describe('ol.Rectangle', function() {
it('scales the extent from its center', function() { it('scales the extent from its center', function() {
var rectangle = new ol.Rectangle(1, 1, 3, 3); var rectangle = new ol.Rectangle(1, 1, 3, 3);
rectangle.scaleFromCenter(2); rectangle.scaleFromCenter(2);
expect(rectangle.minX).toEqual(0); expect(rectangle.minX).to.eql(0);
expect(rectangle.minY).toEqual(0); expect(rectangle.minY).to.eql(0);
expect(rectangle.maxX).toEqual(4); expect(rectangle.maxX).to.eql(4);
expect(rectangle.maxY).toEqual(4); expect(rectangle.maxY).to.eql(4);
}); });
}); });

View File

@@ -50,28 +50,28 @@ describe('ol.renderer.webgl.ImageLayer', function() {
input = goog.vec.Vec4.createFromValues(-1, -1, 0, 1); input = goog.vec.Vec4.createFromValues(-1, -1, 0, 1);
goog.vec.Mat4.multVec4(matrix, input, output); goog.vec.Mat4.multVec4(matrix, input, output);
expect(output[0]).toEqual(-3); expect(output[0]).to.eql(-3);
expect(output[1]).toEqual(-3); expect(output[1]).to.eql(-3);
input = goog.vec.Vec4.createFromValues(1, -1, 0, 1); input = goog.vec.Vec4.createFromValues(1, -1, 0, 1);
goog.vec.Mat4.multVec4(matrix, input, output); goog.vec.Mat4.multVec4(matrix, input, output);
expect(output[0]).toEqual(1); expect(output[0]).to.eql(1);
expect(output[1]).toEqual(-3); expect(output[1]).to.eql(-3);
input = goog.vec.Vec4.createFromValues(-1, 1, 0, 1); input = goog.vec.Vec4.createFromValues(-1, 1, 0, 1);
goog.vec.Mat4.multVec4(matrix, input, output); goog.vec.Mat4.multVec4(matrix, input, output);
expect(output[0]).toEqual(-3); expect(output[0]).to.eql(-3);
expect(output[1]).toEqual(3); expect(output[1]).to.eql(3);
input = goog.vec.Vec4.createFromValues(1, 1, 0, 1); input = goog.vec.Vec4.createFromValues(1, 1, 0, 1);
goog.vec.Mat4.multVec4(matrix, input, output); goog.vec.Mat4.multVec4(matrix, input, output);
expect(output[0]).toEqual(1); expect(output[0]).to.eql(1);
expect(output[1]).toEqual(3); expect(output[1]).to.eql(3);
input = goog.vec.Vec4.createFromValues(0, 0, 0, 1); input = goog.vec.Vec4.createFromValues(0, 0, 0, 1);
goog.vec.Mat4.multVec4(matrix, input, output); goog.vec.Mat4.multVec4(matrix, input, output);
expect(output[0]).toEqual(-1); expect(output[0]).to.eql(-1);
expect(output[1]).toEqual(0); expect(output[1]).to.eql(0);
}); });
}); });
}); });

View File

@@ -13,28 +13,28 @@ describe('ol.ResolutionConstraint', function() {
describe('delta 0', function() { describe('delta 0', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1000, 0)).toEqual(1000); expect(resolutionConstraint(1000, 0)).to.eql(1000);
expect(resolutionConstraint(500, 0)).toEqual(500); expect(resolutionConstraint(500, 0)).to.eql(500);
expect(resolutionConstraint(250, 0)).toEqual(250); expect(resolutionConstraint(250, 0)).to.eql(250);
expect(resolutionConstraint(100, 0)).toEqual(100); expect(resolutionConstraint(100, 0)).to.eql(100);
}); });
}); });
describe('zoom in', function() { describe('zoom in', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1000, 1)).toEqual(500); expect(resolutionConstraint(1000, 1)).to.eql(500);
expect(resolutionConstraint(500, 1)).toEqual(250); expect(resolutionConstraint(500, 1)).to.eql(250);
expect(resolutionConstraint(250, 1)).toEqual(100); expect(resolutionConstraint(250, 1)).to.eql(100);
expect(resolutionConstraint(100, 1)).toEqual(100); expect(resolutionConstraint(100, 1)).to.eql(100);
}); });
}); });
describe('zoom out', function() { describe('zoom out', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1000, -1)).toEqual(1000); expect(resolutionConstraint(1000, -1)).to.eql(1000);
expect(resolutionConstraint(500, -1)).toEqual(1000); expect(resolutionConstraint(500, -1)).to.eql(1000);
expect(resolutionConstraint(250, -1)).toEqual(500); expect(resolutionConstraint(250, -1)).to.eql(500);
expect(resolutionConstraint(100, -1)).toEqual(250); expect(resolutionConstraint(100, -1)).to.eql(250);
}); });
}); });
}); });
@@ -51,40 +51,40 @@ describe('ol.ResolutionConstraint', function() {
describe('delta 0', function() { describe('delta 0', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1050, 0)).toEqual(1000); expect(resolutionConstraint(1050, 0)).to.eql(1000);
expect(resolutionConstraint(950, 0)).toEqual(1000); expect(resolutionConstraint(950, 0)).to.eql(1000);
expect(resolutionConstraint(550, 0)).toEqual(500); expect(resolutionConstraint(550, 0)).to.eql(500);
expect(resolutionConstraint(400, 0)).toEqual(500); expect(resolutionConstraint(400, 0)).to.eql(500);
expect(resolutionConstraint(300, 0)).toEqual(250); expect(resolutionConstraint(300, 0)).to.eql(250);
expect(resolutionConstraint(200, 0)).toEqual(250); expect(resolutionConstraint(200, 0)).to.eql(250);
expect(resolutionConstraint(150, 0)).toEqual(100); expect(resolutionConstraint(150, 0)).to.eql(100);
expect(resolutionConstraint(50, 0)).toEqual(100); expect(resolutionConstraint(50, 0)).to.eql(100);
}); });
}); });
describe('zoom in', function() { describe('zoom in', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1050, 1)).toEqual(500); expect(resolutionConstraint(1050, 1)).to.eql(500);
expect(resolutionConstraint(950, 1)).toEqual(500); expect(resolutionConstraint(950, 1)).to.eql(500);
expect(resolutionConstraint(550, 1)).toEqual(250); expect(resolutionConstraint(550, 1)).to.eql(250);
expect(resolutionConstraint(450, 1)).toEqual(250); expect(resolutionConstraint(450, 1)).to.eql(250);
expect(resolutionConstraint(300, 1)).toEqual(100); expect(resolutionConstraint(300, 1)).to.eql(100);
expect(resolutionConstraint(200, 1)).toEqual(100); expect(resolutionConstraint(200, 1)).to.eql(100);
expect(resolutionConstraint(150, 1)).toEqual(100); expect(resolutionConstraint(150, 1)).to.eql(100);
expect(resolutionConstraint(50, 1)).toEqual(100); expect(resolutionConstraint(50, 1)).to.eql(100);
}); });
}); });
describe('zoom out', function() { describe('zoom out', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1050, -1)).toEqual(1000); expect(resolutionConstraint(1050, -1)).to.eql(1000);
expect(resolutionConstraint(950, -1)).toEqual(1000); expect(resolutionConstraint(950, -1)).to.eql(1000);
expect(resolutionConstraint(550, -1)).toEqual(1000); expect(resolutionConstraint(550, -1)).to.eql(1000);
expect(resolutionConstraint(450, -1)).toEqual(1000); expect(resolutionConstraint(450, -1)).to.eql(1000);
expect(resolutionConstraint(300, -1)).toEqual(500); expect(resolutionConstraint(300, -1)).to.eql(500);
expect(resolutionConstraint(200, -1)).toEqual(500); expect(resolutionConstraint(200, -1)).to.eql(500);
expect(resolutionConstraint(150, -1)).toEqual(250); expect(resolutionConstraint(150, -1)).to.eql(250);
expect(resolutionConstraint(50, -1)).toEqual(250); expect(resolutionConstraint(50, -1)).to.eql(250);
}); });
}); });
}); });
@@ -100,49 +100,49 @@ describe('ol.ResolutionConstraint', function() {
describe('delta 0', function() { describe('delta 0', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1024, 0)).toEqual(1024); expect(resolutionConstraint(1024, 0)).to.eql(1024);
expect(resolutionConstraint(512, 0)).toEqual(512); expect(resolutionConstraint(512, 0)).to.eql(512);
expect(resolutionConstraint(256, 0)).toEqual(256); expect(resolutionConstraint(256, 0)).to.eql(256);
expect(resolutionConstraint(128, 0)).toEqual(128); expect(resolutionConstraint(128, 0)).to.eql(128);
expect(resolutionConstraint(64, 0)).toEqual(64); expect(resolutionConstraint(64, 0)).to.eql(64);
expect(resolutionConstraint(32, 0)).toEqual(32); expect(resolutionConstraint(32, 0)).to.eql(32);
expect(resolutionConstraint(16, 0)).toEqual(16); expect(resolutionConstraint(16, 0)).to.eql(16);
expect(resolutionConstraint(8, 0)).toEqual(8); expect(resolutionConstraint(8, 0)).to.eql(8);
expect(resolutionConstraint(4, 0)).toEqual(4); expect(resolutionConstraint(4, 0)).to.eql(4);
expect(resolutionConstraint(2, 0)).toEqual(2); expect(resolutionConstraint(2, 0)).to.eql(2);
expect(resolutionConstraint(1, 0)).toEqual(1); expect(resolutionConstraint(1, 0)).to.eql(1);
}); });
}); });
describe('zoom in', function() { describe('zoom in', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1024, 1)).toEqual(512); expect(resolutionConstraint(1024, 1)).to.eql(512);
expect(resolutionConstraint(512, 1)).toEqual(256); expect(resolutionConstraint(512, 1)).to.eql(256);
expect(resolutionConstraint(256, 1)).toEqual(128); expect(resolutionConstraint(256, 1)).to.eql(128);
expect(resolutionConstraint(128, 1)).toEqual(64); expect(resolutionConstraint(128, 1)).to.eql(64);
expect(resolutionConstraint(64, 1)).toEqual(32); expect(resolutionConstraint(64, 1)).to.eql(32);
expect(resolutionConstraint(32, 1)).toEqual(16); expect(resolutionConstraint(32, 1)).to.eql(16);
expect(resolutionConstraint(16, 1)).toEqual(8); expect(resolutionConstraint(16, 1)).to.eql(8);
expect(resolutionConstraint(8, 1)).toEqual(4); expect(resolutionConstraint(8, 1)).to.eql(4);
expect(resolutionConstraint(4, 1)).toEqual(2); expect(resolutionConstraint(4, 1)).to.eql(2);
expect(resolutionConstraint(2, 1)).toEqual(1); expect(resolutionConstraint(2, 1)).to.eql(1);
expect(resolutionConstraint(1, 1)).toEqual(1); expect(resolutionConstraint(1, 1)).to.eql(1);
}); });
}); });
describe('zoom out', function() { describe('zoom out', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1024, -1)).toEqual(1024); expect(resolutionConstraint(1024, -1)).to.eql(1024);
expect(resolutionConstraint(512, -1)).toEqual(1024); expect(resolutionConstraint(512, -1)).to.eql(1024);
expect(resolutionConstraint(256, -1)).toEqual(512); expect(resolutionConstraint(256, -1)).to.eql(512);
expect(resolutionConstraint(128, -1)).toEqual(256); expect(resolutionConstraint(128, -1)).to.eql(256);
expect(resolutionConstraint(64, -1)).toEqual(128); expect(resolutionConstraint(64, -1)).to.eql(128);
expect(resolutionConstraint(32, -1)).toEqual(64); expect(resolutionConstraint(32, -1)).to.eql(64);
expect(resolutionConstraint(16, -1)).toEqual(32); expect(resolutionConstraint(16, -1)).to.eql(32);
expect(resolutionConstraint(8, -1)).toEqual(16); expect(resolutionConstraint(8, -1)).to.eql(16);
expect(resolutionConstraint(4, -1)).toEqual(8); expect(resolutionConstraint(4, -1)).to.eql(8);
expect(resolutionConstraint(2, -1)).toEqual(4); expect(resolutionConstraint(2, -1)).to.eql(4);
expect(resolutionConstraint(1, -1)).toEqual(2); expect(resolutionConstraint(1, -1)).to.eql(2);
}); });
}); });
}); });
@@ -158,28 +158,28 @@ describe('ol.ResolutionConstraint', function() {
describe('delta 0', function() { describe('delta 0', function() {
it('returns expected resolution value', function() { it('returns expected resolution value', function() {
expect(resolutionConstraint(1050, 0)).toEqual(1024); expect(resolutionConstraint(1050, 0)).to.eql(1024);
expect(resolutionConstraint(9050, 0)).toEqual(1024); expect(resolutionConstraint(9050, 0)).to.eql(1024);
expect(resolutionConstraint(550, 0)).toEqual(512); expect(resolutionConstraint(550, 0)).to.eql(512);
expect(resolutionConstraint(450, 0)).toEqual(512); expect(resolutionConstraint(450, 0)).to.eql(512);
expect(resolutionConstraint(300, 0)).toEqual(256); expect(resolutionConstraint(300, 0)).to.eql(256);
expect(resolutionConstraint(250, 0)).toEqual(256); expect(resolutionConstraint(250, 0)).to.eql(256);
expect(resolutionConstraint(150, 0)).toEqual(128); expect(resolutionConstraint(150, 0)).to.eql(128);
expect(resolutionConstraint(100, 0)).toEqual(128); expect(resolutionConstraint(100, 0)).to.eql(128);
expect(resolutionConstraint(75, 0)).toEqual(64); expect(resolutionConstraint(75, 0)).to.eql(64);
expect(resolutionConstraint(50, 0)).toEqual(64); expect(resolutionConstraint(50, 0)).to.eql(64);
expect(resolutionConstraint(40, 0)).toEqual(32); expect(resolutionConstraint(40, 0)).to.eql(32);
expect(resolutionConstraint(30, 0)).toEqual(32); expect(resolutionConstraint(30, 0)).to.eql(32);
expect(resolutionConstraint(20, 0)).toEqual(16); expect(resolutionConstraint(20, 0)).to.eql(16);
expect(resolutionConstraint(12, 0)).toEqual(16); expect(resolutionConstraint(12, 0)).to.eql(16);
expect(resolutionConstraint(9, 0)).toEqual(8); expect(resolutionConstraint(9, 0)).to.eql(8);
expect(resolutionConstraint(7, 0)).toEqual(8); expect(resolutionConstraint(7, 0)).to.eql(8);
expect(resolutionConstraint(5, 0)).toEqual(4); expect(resolutionConstraint(5, 0)).to.eql(4);
expect(resolutionConstraint(3.5, 0)).toEqual(4); expect(resolutionConstraint(3.5, 0)).to.eql(4);
expect(resolutionConstraint(2.1, 0)).toEqual(2); expect(resolutionConstraint(2.1, 0)).to.eql(2);
expect(resolutionConstraint(1.9, 0)).toEqual(2); expect(resolutionConstraint(1.9, 0)).to.eql(2);
expect(resolutionConstraint(1.1, 0)).toEqual(1); expect(resolutionConstraint(1.1, 0)).to.eql(1);
expect(resolutionConstraint(0.9, 0)).toEqual(1); expect(resolutionConstraint(0.9, 0)).to.eql(1);
}); });
}); });
}); });

View File

@@ -7,27 +7,27 @@ describe('ol.RotationConstraint', function() {
it('returns expected rotation value', function() { it('returns expected rotation value', function() {
var rotationConstraint = ol.RotationConstraint.createSnapToZero(0.3); var rotationConstraint = ol.RotationConstraint.createSnapToZero(0.3);
expect(rotationConstraint(0.1, 0)).toEqual(0); expect(rotationConstraint(0.1, 0)).to.eql(0);
expect(rotationConstraint(0.2, 0)).toEqual(0); expect(rotationConstraint(0.2, 0)).to.eql(0);
expect(rotationConstraint(0.3, 0)).toEqual(0); expect(rotationConstraint(0.3, 0)).to.eql(0);
expect(rotationConstraint(0.4, 0)).toEqual(0.4); expect(rotationConstraint(0.4, 0)).to.eql(0.4);
expect(rotationConstraint(-0.1, 0)).toEqual(0); expect(rotationConstraint(-0.1, 0)).to.eql(0);
expect(rotationConstraint(-0.2, 0)).toEqual(0); expect(rotationConstraint(-0.2, 0)).to.eql(0);
expect(rotationConstraint(-0.3, 0)).toEqual(0); expect(rotationConstraint(-0.3, 0)).to.eql(0);
expect(rotationConstraint(-0.4, 0)).toEqual(-0.4); expect(rotationConstraint(-0.4, 0)).to.eql(-0.4);
expect(rotationConstraint(1, -0.9)).toEqual(0); expect(rotationConstraint(1, -0.9)).to.eql(0);
expect(rotationConstraint(1, -0.8)).toEqual(0); expect(rotationConstraint(1, -0.8)).to.eql(0);
// floating-point arithmetic // floating-point arithmetic
expect(rotationConstraint(1, -0.7)).not.toEqual(0); expect(rotationConstraint(1, -0.7)).not.to.eql(0);
expect(rotationConstraint(1, -0.6)).toEqual(0.4); expect(rotationConstraint(1, -0.6)).to.eql(0.4);
expect(rotationConstraint(-1, 0.9)).toEqual(0); expect(rotationConstraint(-1, 0.9)).to.eql(0);
expect(rotationConstraint(-1, 0.8)).toEqual(0); expect(rotationConstraint(-1, 0.8)).to.eql(0);
// floating-point arithmetic // floating-point arithmetic
expect(rotationConstraint(-1, 0.7)).not.toEqual(0); expect(rotationConstraint(-1, 0.7)).not.to.eql(0);
expect(rotationConstraint(-1, 0.6)).toEqual(-0.4); expect(rotationConstraint(-1, 0.6)).to.eql(-0.4);
}); });
}); });

View File

@@ -7,8 +7,8 @@ describe('ol.source.TileSource', function() {
var source = new ol.source.TileSource({ var source = new ol.source.TileSource({
projection: ol.projection.get('EPSG:4326') projection: ol.projection.get('EPSG:4326')
}); });
expect(source).toBeA(ol.source.Source); expect(source).to.be.a(ol.source.Source);
expect(source).toBeA(ol.source.TileSource); expect(source).to.be.a(ol.source.TileSource);
}); });
}); });
@@ -30,7 +30,7 @@ describe('ol.source.TileSource', function() {
source.findLoadedTiles(loadedTilesByZ, getTileIfLoaded, 3, range); source.findLoadedTiles(loadedTilesByZ, getTileIfLoaded, 3, range);
var keys = goog.object.getKeys(loadedTilesByZ); var keys = goog.object.getKeys(loadedTilesByZ);
expect(keys.length).toBe(0); expect(keys.length).to.be(0);
}); });
it('adds loaded tiles to the lookup (z: 0)', function() { it('adds loaded tiles to the lookup (z: 0)', function() {
@@ -51,10 +51,10 @@ describe('ol.source.TileSource', function() {
} }
source.findLoadedTiles(loadedTilesByZ, getTileIfLoaded, 0, range); source.findLoadedTiles(loadedTilesByZ, getTileIfLoaded, 0, range);
var keys = goog.object.getKeys(loadedTilesByZ); var keys = goog.object.getKeys(loadedTilesByZ);
expect(keys.length).toBe(1); expect(keys.length).to.be(1);
var tile = loadedTilesByZ['0']['0/0/0']; var tile = loadedTilesByZ['0']['0/0/0'];
expect(tile).toBeA(ol.Tile); expect(tile).to.be.a(ol.Tile);
expect(tile.state).toBe(ol.TileState.LOADED); expect(tile.state).to.be(ol.TileState.LOADED);
}); });
it('adds loaded tiles to the lookup (z: 1)', function() { it('adds loaded tiles to the lookup (z: 1)', function() {
@@ -75,10 +75,10 @@ describe('ol.source.TileSource', function() {
} }
source.findLoadedTiles(loadedTilesByZ, getTileIfLoaded, 1, range); source.findLoadedTiles(loadedTilesByZ, getTileIfLoaded, 1, range);
var keys = goog.object.getKeys(loadedTilesByZ); var keys = goog.object.getKeys(loadedTilesByZ);
expect(keys.length).toBe(1); expect(keys.length).to.be(1);
var tile = loadedTilesByZ['1']['1/0/0']; var tile = loadedTilesByZ['1']['1/0/0'];
expect(tile).toBeA(ol.Tile); expect(tile).to.be.a(ol.Tile);
expect(tile.state).toBe(ol.TileState.LOADED); expect(tile.state).to.be(ol.TileState.LOADED);
}); });
it('returns true when all tiles are already loaded', function() { it('returns true when all tiles are already loaded', function() {
@@ -100,7 +100,7 @@ describe('ol.source.TileSource', function() {
} }
var loaded = source.findLoadedTiles( var loaded = source.findLoadedTiles(
loadedTilesByZ, getTileIfLoaded, 1, range); loadedTilesByZ, getTileIfLoaded, 1, range);
expect(loaded).toBe(true); expect(loaded).to.be(true);
}); });
it('returns true when all tiles are already loaded (part 2)', function() { it('returns true when all tiles are already loaded (part 2)', function() {
@@ -126,7 +126,7 @@ describe('ol.source.TileSource', function() {
} }
var loaded = source.findLoadedTiles( var loaded = source.findLoadedTiles(
loadedTilesByZ, getTileIfLoaded, 1, range); loadedTilesByZ, getTileIfLoaded, 1, range);
expect(loaded).toBe(true); expect(loaded).to.be(true);
}); });
it('returns false when all tiles are already loaded', function() { it('returns false when all tiles are already loaded', function() {
@@ -149,7 +149,7 @@ describe('ol.source.TileSource', function() {
} }
var loaded = source.findLoadedTiles( var loaded = source.findLoadedTiles(
loadedTilesByZ, getTileIfLoaded, 1, range); loadedTilesByZ, getTileIfLoaded, 1, range);
expect(loaded).toBe(false); expect(loaded).to.be(false);
}); });
it('returns false when all tiles are already loaded (part 2)', function() { it('returns false when all tiles are already loaded (part 2)', function() {
@@ -174,7 +174,7 @@ describe('ol.source.TileSource', function() {
} }
var loaded = source.findLoadedTiles( var loaded = source.findLoadedTiles(
loadedTilesByZ, getTileIfLoaded, 1, range); loadedTilesByZ, getTileIfLoaded, 1, range);
expect(loaded).toBe(false); expect(loaded).to.be(false);
}); });
}); });
@@ -231,8 +231,8 @@ describe('ol.test.source.MockTileSource', function() {
describe('constructor', function() { describe('constructor', function() {
it('creates a tile source', function() { it('creates a tile source', function() {
var source = new ol.test.source.MockTileSource({}); var source = new ol.test.source.MockTileSource({});
expect(source).toBeA(ol.source.TileSource); expect(source).to.be.a(ol.source.TileSource);
expect(source).toBeA(ol.test.source.MockTileSource); expect(source).to.be.a(ol.test.source.MockTileSource);
}); });
}); });
@@ -246,18 +246,18 @@ describe('ol.test.source.MockTileSource', function() {
// check a loaded tile // check a loaded tile
tile = source.getTile(new ol.TileCoord(0, 0, 0)); tile = source.getTile(new ol.TileCoord(0, 0, 0));
expect(tile).toBeA(ol.Tile); expect(tile).to.be.a(ol.Tile);
expect(tile.state).toBe(ol.TileState.LOADED); expect(tile.state).to.be(ol.TileState.LOADED);
// check a tile that is not loaded // check a tile that is not loaded
tile = source.getTile(new ol.TileCoord(1, 0, -1)); tile = source.getTile(new ol.TileCoord(1, 0, -1));
expect(tile).toBeA(ol.Tile); expect(tile).to.be.a(ol.Tile);
expect(tile.state).toBe(ol.TileState.IDLE); expect(tile.state).to.be(ol.TileState.IDLE);
// check another loaded tile // check another loaded tile
tile = source.getTile(new ol.TileCoord(1, 0, 0)); tile = source.getTile(new ol.TileCoord(1, 0, 0));
expect(tile).toBeA(ol.Tile); expect(tile).to.be.a(ol.Tile);
expect(tile.state).toBe(ol.TileState.LOADED); expect(tile.state).to.be(ol.TileState.LOADED);
}); });
}); });

View File

@@ -20,44 +20,44 @@ describe('ol.source.XYZ', function() {
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 0)); tileGrid.getTileCoordForCoordAndZ(coordinate, 0));
expect(tileUrl).toEqual('0/0/0'); expect(tileUrl).to.eql('0/0/0');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 1)); tileGrid.getTileCoordForCoordAndZ(coordinate, 1));
expect(tileUrl).toEqual('1/1/0'); expect(tileUrl).to.eql('1/1/0');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 2)); tileGrid.getTileCoordForCoordAndZ(coordinate, 2));
expect(tileUrl).toEqual('2/2/1'); expect(tileUrl).to.eql('2/2/1');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 3)); tileGrid.getTileCoordForCoordAndZ(coordinate, 3));
expect(tileUrl).toEqual('3/4/2'); expect(tileUrl).to.eql('3/4/2');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 4)); tileGrid.getTileCoordForCoordAndZ(coordinate, 4));
expect(tileUrl).toEqual('4/8/5'); expect(tileUrl).to.eql('4/8/5');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 5)); tileGrid.getTileCoordForCoordAndZ(coordinate, 5));
expect(tileUrl).toEqual('5/16/11'); expect(tileUrl).to.eql('5/16/11');
tileUrl = xyzTileSource.tileUrlFunction( tileUrl = xyzTileSource.tileUrlFunction(
tileGrid.getTileCoordForCoordAndZ(coordinate, 6)); tileGrid.getTileCoordForCoordAndZ(coordinate, 6));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).to.eql('6/33/22');
}); });
describe('wrap x', function() { describe('wrap x', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
var tileUrl = xyzTileSource.tileUrlFunction( var tileUrl = xyzTileSource.tileUrlFunction(
new ol.TileCoord(6, -31, -23)); new ol.TileCoord(6, -31, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, -23)); tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 97, -23)); tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 97, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).to.eql('6/33/22');
}); });
}); });
@@ -65,13 +65,13 @@ describe('ol.source.XYZ', function() {
it('returns the expected URL', function() { it('returns the expected URL', function() {
var tileUrl = xyzTileSource.tileUrlFunction( var tileUrl = xyzTileSource.tileUrlFunction(
new ol.TileCoord(6, 33, -87)); new ol.TileCoord(6, 33, -87));
expect(tileUrl).toBeUndefined(); expect(tileUrl).to.be(undefined);
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, -23)); tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, -23));
expect(tileUrl).toEqual('6/33/22'); expect(tileUrl).to.eql('6/33/22');
tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, 41)); tileUrl = xyzTileSource.tileUrlFunction(new ol.TileCoord(6, 33, 41));
expect(tileUrl).toBeUndefined(); expect(tileUrl).to.be(undefined);
}); });
}); });
}); });
@@ -90,38 +90,38 @@ describe('ol.source.XYZ', function() {
return false; return false;
}); });
expect(zs.length).toEqual(5); expect(zs.length).to.eql(5);
expect(tileRanges.length).toEqual(5); expect(tileRanges.length).to.eql(5);
expect(zs[0]).toEqual(4); expect(zs[0]).to.eql(4);
expect(tileRanges[0].minX).toEqual(5); expect(tileRanges[0].minX).to.eql(5);
expect(tileRanges[0].minY).toEqual(10); expect(tileRanges[0].minY).to.eql(10);
expect(tileRanges[0].maxX).toEqual(5); expect(tileRanges[0].maxX).to.eql(5);
expect(tileRanges[0].maxY).toEqual(10); expect(tileRanges[0].maxY).to.eql(10);
expect(zs[1]).toEqual(3); expect(zs[1]).to.eql(3);
expect(tileRanges[1].minX).toEqual(2); expect(tileRanges[1].minX).to.eql(2);
expect(tileRanges[1].minY).toEqual(5); expect(tileRanges[1].minY).to.eql(5);
expect(tileRanges[1].maxX).toEqual(2); expect(tileRanges[1].maxX).to.eql(2);
expect(tileRanges[1].maxY).toEqual(5); expect(tileRanges[1].maxY).to.eql(5);
expect(zs[2]).toEqual(2); expect(zs[2]).to.eql(2);
expect(tileRanges[2].minX).toEqual(1); expect(tileRanges[2].minX).to.eql(1);
expect(tileRanges[2].minY).toEqual(2); expect(tileRanges[2].minY).to.eql(2);
expect(tileRanges[2].maxX).toEqual(1); expect(tileRanges[2].maxX).to.eql(1);
expect(tileRanges[2].maxY).toEqual(2); expect(tileRanges[2].maxY).to.eql(2);
expect(zs[3]).toEqual(1); expect(zs[3]).to.eql(1);
expect(tileRanges[3].minX).toEqual(0); expect(tileRanges[3].minX).to.eql(0);
expect(tileRanges[3].minY).toEqual(1); expect(tileRanges[3].minY).to.eql(1);
expect(tileRanges[3].maxX).toEqual(0); expect(tileRanges[3].maxX).to.eql(0);
expect(tileRanges[3].maxY).toEqual(1); expect(tileRanges[3].maxY).to.eql(1);
expect(zs[4]).toEqual(0); expect(zs[4]).to.eql(0);
expect(tileRanges[4].minX).toEqual(0); expect(tileRanges[4].minX).to.eql(0);
expect(tileRanges[4].minY).toEqual(0); expect(tileRanges[4].minY).to.eql(0);
expect(tileRanges[4].maxX).toEqual(0); expect(tileRanges[4].maxX).to.eql(0);
expect(tileRanges[4].maxY).toEqual(0); expect(tileRanges[4].maxY).to.eql(0);
}); });
}); });

View File

@@ -468,7 +468,7 @@ describe('ol.Sphere', function() {
var e, i; var e, i;
for (i = 0; i < expected.length; ++i) { for (i = 0; i < expected.length; ++i) {
e = expected[i]; e = expected[i];
expect(sphere.cosineDistance(e.c1, e.c2)).toRoughlyEqual( expect(sphere.cosineDistance(e.c1, e.c2)).to.roughlyEqual(
e.cosineDistance, 1e-9); e.cosineDistance, 1e-9);
} }
}); });
@@ -481,7 +481,7 @@ describe('ol.Sphere', function() {
var e, i; var e, i;
for (i = 0; i < expected.length; ++i) { for (i = 0; i < expected.length; ++i) {
e = expected[i]; e = expected[i];
expect(sphere.equirectangularDistance(e.c1, e.c2)).toRoughlyEqual( expect(sphere.equirectangularDistance(e.c1, e.c2)).to.roughlyEqual(
e.equirectangularDistance, 1e-9); e.equirectangularDistance, 1e-9);
} }
}); });
@@ -494,7 +494,7 @@ describe('ol.Sphere', function() {
var e, i; var e, i;
for (i = 0; i < expected.length; ++i) { for (i = 0; i < expected.length; ++i) {
e = expected[i]; e = expected[i];
expect(sphere.finalBearing(e.c1, e.c2)).toRoughlyEqual( expect(sphere.finalBearing(e.c1, e.c2)).to.roughlyEqual(
e.finalBearing, 1e-9); e.finalBearing, 1e-9);
} }
}); });
@@ -507,7 +507,7 @@ describe('ol.Sphere', function() {
var e, i; var e, i;
for (i = 0; i < expected.length; ++i) { for (i = 0; i < expected.length; ++i) {
e = expected[i]; e = expected[i];
expect(sphere.haversineDistance(e.c1, e.c2)).toRoughlyEqual( expect(sphere.haversineDistance(e.c1, e.c2)).to.roughlyEqual(
e.haversineDistance, 1e-9); e.haversineDistance, 1e-9);
} }
}); });
@@ -520,7 +520,7 @@ describe('ol.Sphere', function() {
var e, i; var e, i;
for (i = 0; i < expected.length; ++i) { for (i = 0; i < expected.length; ++i) {
e = expected[i]; e = expected[i];
expect(sphere.initialBearing(e.c1, e.c2)).toRoughlyEqual( expect(sphere.initialBearing(e.c1, e.c2)).to.roughlyEqual(
e.initialBearing, 1e-9); e.initialBearing, 1e-9);
} }
}); });
@@ -536,9 +536,9 @@ describe('ol.Sphere', function() {
midpoint = sphere.midpoint(e.c1, e.c2); midpoint = sphere.midpoint(e.c1, e.c2);
// Test modulo 360 to avoid unnecessary expensive modulo operations // Test modulo 360 to avoid unnecessary expensive modulo operations
// in our implementation. // in our implementation.
expect(goog.math.modulo(midpoint.x, 360)).toRoughlyEqual( expect(goog.math.modulo(midpoint.x, 360)).to.roughlyEqual(
goog.math.modulo(e.midpoint.x, 360), 1e-9); goog.math.modulo(e.midpoint.x, 360), 1e-9);
expect(midpoint.y).toRoughlyEqual(e.midpoint.y, 1e-9); expect(midpoint.y).to.roughlyEqual(e.midpoint.y, 1e-9);
} }
}); });

View File

@@ -5,18 +5,18 @@ describe('ol.TileCoord', function() {
describe('create', function() { describe('create', function() {
it('sets x y z properties as expected', function() { it('sets x y z properties as expected', function() {
var tc = new ol.TileCoord(1, 2, 3); var tc = new ol.TileCoord(1, 2, 3);
expect(tc.z).toEqual(1); expect(tc.z).to.eql(1);
expect(tc.x).toEqual(2); expect(tc.x).to.eql(2);
expect(tc.y).toEqual(3); expect(tc.y).to.eql(3);
}); });
}); });
describe('create from quad key', function() { describe('create from quad key', function() {
it('sets x y z properties as expected', function() { it('sets x y z properties as expected', function() {
var tc = ol.TileCoord.createFromQuadKey('213'); var tc = ol.TileCoord.createFromQuadKey('213');
expect(tc.z).toEqual(3); expect(tc.z).to.eql(3);
expect(tc.x).toEqual(3); expect(tc.x).to.eql(3);
expect(tc.y).toEqual(5); expect(tc.y).to.eql(5);
}); });
}); });
@@ -24,9 +24,9 @@ describe('ol.TileCoord', function() {
it('sets x y z properties as expected', function() { it('sets x y z properties as expected', function() {
var str = '1/2/3'; var str = '1/2/3';
var tc = ol.TileCoord.createFromString(str); var tc = ol.TileCoord.createFromString(str);
expect(tc.z).toEqual(1); expect(tc.z).to.eql(1);
expect(tc.x).toEqual(2); expect(tc.x).to.eql(2);
expect(tc.y).toEqual(3); expect(tc.y).to.eql(3);
}); });
}); });
@@ -34,7 +34,7 @@ describe('ol.TileCoord', function() {
it('returns expected string', function() { it('returns expected string', function() {
var tc = new ol.TileCoord(3, 3, 5); var tc = new ol.TileCoord(3, 3, 5);
var s = tc.quadKey(); var s = tc.quadKey();
expect(s).toEqual('213'); expect(s).to.eql('213');
}); });
}); });
@@ -42,7 +42,7 @@ describe('ol.TileCoord', function() {
it('produces different hashes for different tile coords', function() { it('produces different hashes for different tile coords', function() {
var tc1 = new ol.TileCoord(3, 2, 1); var tc1 = new ol.TileCoord(3, 2, 1);
var tc2 = new ol.TileCoord(3, 1, 1); var tc2 = new ol.TileCoord(3, 1, 1);
expect(tc1.hash()).not.toEqual(tc2.hash()); expect(tc1.hash()).not.to.eql(tc2.hash());
}); });
}); });
}); });

View File

@@ -24,7 +24,7 @@ describe('ol.tilegrid.TileGrid', function() {
origin: origin, origin: origin,
tileSize: tileSize tileSize: tileSize
}); });
}).not.toThrow(); }).not.to.throwException();
}); });
}); });
@@ -37,7 +37,7 @@ describe('ol.tilegrid.TileGrid', function() {
origin: origin, origin: origin,
tileSize: tileSize tileSize: tileSize
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -51,7 +51,7 @@ describe('ol.tilegrid.TileGrid', function() {
origin: origin, origin: origin,
tileSize: tileSize tileSize: tileSize
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -64,7 +64,7 @@ describe('ol.tilegrid.TileGrid', function() {
origins: [origin, origin, origin, origin], origins: [origin, origin, origin, origin],
tileSize: tileSize tileSize: tileSize
}); });
}).not.toThrow(); }).not.to.throwException();
}); });
}); });
@@ -78,7 +78,7 @@ describe('ol.tilegrid.TileGrid', function() {
origin: origin, origin: origin,
tileSize: tileSize tileSize: tileSize
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -91,7 +91,7 @@ describe('ol.tilegrid.TileGrid', function() {
origins: [origin, origin, origin], origins: [origin, origin, origin],
tileSize: tileSize tileSize: tileSize
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -104,7 +104,7 @@ describe('ol.tilegrid.TileGrid', function() {
origins: [origin, origin, origin, origin, origin], origins: [origin, origin, origin, origin, origin],
tileSize: tileSize tileSize: tileSize
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -117,7 +117,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileSizes: [tileSize, tileSize, tileSize, tileSize], tileSizes: [tileSize, tileSize, tileSize, tileSize],
origin: origin origin: origin
}); });
}).not.toThrow(); }).not.to.throwException();
}); });
}); });
@@ -131,7 +131,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileSize: tileSize, tileSize: tileSize,
origin: origin origin: origin
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -144,7 +144,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileSizes: [tileSize, tileSize, tileSize], tileSizes: [tileSize, tileSize, tileSize],
origin: origin origin: origin
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -157,7 +157,7 @@ describe('ol.tilegrid.TileGrid', function() {
tileSizes: [tileSize, tileSize, tileSize, tileSize, tileSize], tileSizes: [tileSize, tileSize, tileSize, tileSize, tileSize],
origin: origin origin: origin
}); });
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -166,28 +166,28 @@ describe('ol.tilegrid.TileGrid', function() {
it('allows easier creation of a tile grid', function() { it('allows easier creation of a tile grid', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection); var grid = ol.tilegrid.createForProjection(projection);
expect(grid).toBeA(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
var resolutions = grid.getResolutions(); var resolutions = grid.getResolutions();
expect(resolutions.length).toBe(ol.DEFAULT_MAX_ZOOM + 1); expect(resolutions.length).to.be(ol.DEFAULT_MAX_ZOOM + 1);
}); });
it('accepts a number of zoom levels', function() { it('accepts a number of zoom levels', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection, 18); var grid = ol.tilegrid.createForProjection(projection, 18);
expect(grid).toBeA(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
var resolutions = grid.getResolutions(); var resolutions = grid.getResolutions();
expect(resolutions.length).toBe(19); expect(resolutions.length).to.be(19);
}); });
it('accepts a big number of zoom levels', function() { it('accepts a big number of zoom levels', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.createForProjection(projection, 23); var grid = ol.tilegrid.createForProjection(projection, 23);
expect(grid).toBeA(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
var resolutions = grid.getResolutions(); var resolutions = grid.getResolutions();
expect(resolutions.length).toBe(24); expect(resolutions.length).to.be(24);
}); });
}); });
@@ -197,11 +197,11 @@ describe('ol.tilegrid.TileGrid', function() {
it('gets the default tile grid for a projection', function() { it('gets the default tile grid for a projection', function() {
var projection = ol.projection.get('EPSG:3857'); var projection = ol.projection.get('EPSG:3857');
var grid = ol.tilegrid.getForProjection(projection); var grid = ol.tilegrid.getForProjection(projection);
expect(grid).toBeA(ol.tilegrid.TileGrid); expect(grid).to.be.a(ol.tilegrid.TileGrid);
var resolutions = grid.getResolutions(); var resolutions = grid.getResolutions();
expect(resolutions.length).toBe(ol.DEFAULT_MAX_ZOOM + 1); expect(resolutions.length).to.be(ol.DEFAULT_MAX_ZOOM + 1);
expect(grid.getTileSize().toString()).toBe('(256 x 256)'); expect(grid.getTileSize().toString()).to.be('(256 x 256)');
}); });
it('stores the default tile grid on a projection', function() { it('stores the default tile grid on a projection', function() {
@@ -209,7 +209,7 @@ describe('ol.tilegrid.TileGrid', function() {
var grid = ol.tilegrid.getForProjection(projection); var grid = ol.tilegrid.getForProjection(projection);
var gridAgain = ol.tilegrid.getForProjection(projection); var gridAgain = ol.tilegrid.getForProjection(projection);
expect(grid).toBe(gridAgain); expect(grid).to.be(gridAgain);
}); });
}); });
@@ -229,27 +229,27 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 0), 3); new ol.Coordinate(0, 0), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 100000), 3); new ol.Coordinate(0, 100000), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(10); expect(tileCoord.y).to.eql(10);
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 0), 3); new ol.Coordinate(100000, 0), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(10); expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 100000), 3); new ol.Coordinate(100000, 100000), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(10); expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).toEqual(10); expect(tileCoord.y).to.eql(10);
}); });
}); });
@@ -266,27 +266,27 @@ describe('ol.tilegrid.TileGrid', function() {
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 0), 3); new ol.Coordinate(0, 0), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(-10); expect(tileCoord.y).to.eql(-10);
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(0, 100000), 3); new ol.Coordinate(0, 100000), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 0), 3); new ol.Coordinate(100000, 0), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(10); expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).toEqual(-10); expect(tileCoord.y).to.eql(-10);
tileCoord = tileGrid.getTileCoordForCoordAndZ( tileCoord = tileGrid.getTileCoordForCoordAndZ(
new ol.Coordinate(100000, 100000), 3); new ol.Coordinate(100000, 100000), 3);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(10); expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
}); });
}); });
}); });
@@ -308,73 +308,73 @@ describe('ol.tilegrid.TileGrid', function() {
coordinate = new ol.Coordinate(0, 0); coordinate = new ol.Coordinate(0, 0);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
// gets one tile northwest of the origin // gets one tile northwest of the origin
coordinate = new ol.Coordinate(-1280, 1280); coordinate = new ol.Coordinate(-1280, 1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(-1); expect(tileCoord.x).to.eql(-1);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
// gets one tile northeast of the origin // gets one tile northeast of the origin
coordinate = new ol.Coordinate(1280, 1280); coordinate = new ol.Coordinate(1280, 1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
// gets one tile southeast of the origin // gets one tile southeast of the origin
coordinate = new ol.Coordinate(1280, -1280); coordinate = new ol.Coordinate(1280, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(-1); expect(tileCoord.y).to.eql(-1);
// gets one tile southwest of the origin // gets one tile southwest of the origin
coordinate = new ol.Coordinate(-1280, -1280); coordinate = new ol.Coordinate(-1280, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(-1); expect(tileCoord.x).to.eql(-1);
expect(tileCoord.y).toEqual(-1); expect(tileCoord.y).to.eql(-1);
// gets the tile to the east when on the edge // gets the tile to the east when on the edge
coordinate = new ol.Coordinate(2560, -1280); coordinate = new ol.Coordinate(2560, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(1); expect(tileCoord.x).to.eql(1);
expect(tileCoord.y).toEqual(-1); expect(tileCoord.y).to.eql(-1);
// gets the tile to the north when on the edge // gets the tile to the north when on the edge
coordinate = new ol.Coordinate(1280, -2560); coordinate = new ol.Coordinate(1280, -2560);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(-1); expect(tileCoord.y).to.eql(-1);
// pixels are top aligned to the origin // pixels are top aligned to the origin
coordinate = new ol.Coordinate(1280, -2559.999); coordinate = new ol.Coordinate(1280, -2559.999);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(-1); expect(tileCoord.y).to.eql(-1);
// pixels are left aligned to the origin // pixels are left aligned to the origin
coordinate = new ol.Coordinate(2559.999, -1280); coordinate = new ol.Coordinate(2559.999, -1280);
tileCoord = tileGrid.getTileCoordForCoordAndResolution( tileCoord = tileGrid.getTileCoordForCoordAndResolution(
coordinate, 10); coordinate, 10);
expect(tileCoord.z).toEqual(0); expect(tileCoord.z).to.eql(0);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(-1); expect(tileCoord.y).to.eql(-1);
}); });
}); });
@@ -395,17 +395,17 @@ describe('ol.tilegrid.TileGrid', function() {
coordinate = new ol.Coordinate(0, 0); coordinate = new ol.Coordinate(0, 0);
tileCoord = tileGrid.getTileCoordForCoordAndResolution_( tileCoord = tileGrid.getTileCoordForCoordAndResolution_(
coordinate, 100); coordinate, 100);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(0); expect(tileCoord.x).to.eql(0);
expect(tileCoord.y).toEqual(0); expect(tileCoord.y).to.eql(0);
// gets higher tile for edge intersection // gets higher tile for edge intersection
coordinate = new ol.Coordinate(100000, 100000); coordinate = new ol.Coordinate(100000, 100000);
tileCoord = tileGrid.getTileCoordForCoordAndResolution_( tileCoord = tileGrid.getTileCoordForCoordAndResolution_(
coordinate, 100); coordinate, 100);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(10); expect(tileCoord.x).to.eql(10);
expect(tileCoord.y).toEqual(10); expect(tileCoord.y).to.eql(10);
}); });
@@ -424,17 +424,17 @@ describe('ol.tilegrid.TileGrid', function() {
coordinate = new ol.Coordinate(0, 0); coordinate = new ol.Coordinate(0, 0);
tileCoord = tileGrid.getTileCoordForCoordAndResolution_( tileCoord = tileGrid.getTileCoordForCoordAndResolution_(
coordinate, 100, true); coordinate, 100, true);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(-1); expect(tileCoord.x).to.eql(-1);
expect(tileCoord.y).toEqual(-1); expect(tileCoord.y).to.eql(-1);
// gets higher tile for edge intersection // gets higher tile for edge intersection
coordinate = new ol.Coordinate(100000, 100000); coordinate = new ol.Coordinate(100000, 100000);
tileCoord = tileGrid.getTileCoordForCoordAndResolution_( tileCoord = tileGrid.getTileCoordForCoordAndResolution_(
coordinate, 100, true); coordinate, 100, true);
expect(tileCoord.z).toEqual(3); expect(tileCoord.z).to.eql(3);
expect(tileCoord.x).toEqual(9); expect(tileCoord.x).to.eql(9);
expect(tileCoord.y).toEqual(9); expect(tileCoord.y).to.eql(9);
}); });
@@ -451,16 +451,16 @@ describe('ol.tilegrid.TileGrid', function() {
var center; var center;
center = tileGrid.getTileCoordCenter(new ol.TileCoord(0, 0, 0)); center = tileGrid.getTileCoordCenter(new ol.TileCoord(0, 0, 0));
expect(center.x).toEqual(50000); expect(center.x).to.eql(50000);
expect(center.y).toEqual(50000); expect(center.y).to.eql(50000);
center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 0, 0)); center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 0, 0));
expect(center.x).toEqual(5000); expect(center.x).to.eql(5000);
expect(center.y).toEqual(5000); expect(center.y).to.eql(5000);
center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 9, 9)); center = tileGrid.getTileCoordCenter(new ol.TileCoord(3, 9, 9));
expect(center.x).toEqual(95000); expect(center.x).to.eql(95000);
expect(center.y).toEqual(95000); expect(center.y).to.eql(95000);
}); });
}); });
@@ -475,22 +475,22 @@ describe('ol.tilegrid.TileGrid', function() {
var tileCoordExtent; var tileCoordExtent;
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(0, 0, 0)); tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(0, 0, 0));
expect(tileCoordExtent.minX).toEqual(0); expect(tileCoordExtent.minX).to.eql(0);
expect(tileCoordExtent.minY).toEqual(0); expect(tileCoordExtent.minY).to.eql(0);
expect(tileCoordExtent.maxX).toEqual(100000); expect(tileCoordExtent.maxX).to.eql(100000);
expect(tileCoordExtent.maxY).toEqual(100000); expect(tileCoordExtent.maxY).to.eql(100000);
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 9, 0)); tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 9, 0));
expect(tileCoordExtent.minX).toEqual(90000); expect(tileCoordExtent.minX).to.eql(90000);
expect(tileCoordExtent.minY).toEqual(0); expect(tileCoordExtent.minY).to.eql(0);
expect(tileCoordExtent.maxX).toEqual(100000); expect(tileCoordExtent.maxX).to.eql(100000);
expect(tileCoordExtent.maxY).toEqual(10000); expect(tileCoordExtent.maxY).to.eql(10000);
tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 0, 9)); tileCoordExtent = tileGrid.getTileCoordExtent(new ol.TileCoord(3, 0, 9));
expect(tileCoordExtent.minX).toEqual(0); expect(tileCoordExtent.minX).to.eql(0);
expect(tileCoordExtent.minY).toEqual(90000); expect(tileCoordExtent.minY).to.eql(90000);
expect(tileCoordExtent.maxX).toEqual(10000); expect(tileCoordExtent.maxX).to.eql(10000);
expect(tileCoordExtent.maxY).toEqual(100000); expect(tileCoordExtent.maxY).to.eql(100000);
}); });
}); });
@@ -506,31 +506,31 @@ describe('ol.tilegrid.TileGrid', function() {
tileRange = tileGrid.getTileRangeForExtentAndResolution(extent, tileRange = tileGrid.getTileRangeForExtentAndResolution(extent,
resolutions[0]); resolutions[0]);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.minX).toEqual(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.maxX).toEqual(0); expect(tileRange.maxX).to.eql(0);
expect(tileRange.maxY).toEqual(0); expect(tileRange.maxY).to.eql(0);
tileRange = tileGrid.getTileRangeForExtentAndResolution(extent, tileRange = tileGrid.getTileRangeForExtentAndResolution(extent,
resolutions[1]); resolutions[1]);
expect(tileRange.minX).toEqual(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.maxX).toEqual(1); expect(tileRange.maxX).to.eql(1);
expect(tileRange.maxY).toEqual(1); expect(tileRange.maxY).to.eql(1);
tileRange = tileGrid.getTileRangeForExtentAndResolution(extent, tileRange = tileGrid.getTileRangeForExtentAndResolution(extent,
resolutions[2]); resolutions[2]);
expect(tileRange.minX).toEqual(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.maxX).toEqual(3); expect(tileRange.maxX).to.eql(3);
expect(tileRange.maxY).toEqual(3); expect(tileRange.maxY).to.eql(3);
tileRange = tileGrid.getTileRangeForExtentAndResolution(extent, tileRange = tileGrid.getTileRangeForExtentAndResolution(extent,
resolutions[3]); resolutions[3]);
expect(tileRange.minX).toEqual(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.maxX).toEqual(9); expect(tileRange.maxX).to.eql(9);
expect(tileRange.maxY).toEqual(9); expect(tileRange.maxY).to.eql(9);
}); });
}); });
@@ -546,28 +546,28 @@ describe('ol.tilegrid.TileGrid', function() {
var tileRange; var tileRange;
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 0);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.minX).toEqual(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.maxX).toEqual(0); expect(tileRange.maxX).to.eql(0);
expect(tileRange.maxY).toEqual(0); expect(tileRange.maxY).to.eql(0);
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 1); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 1);
expect(tileRange.minX).toEqual(0); expect(tileRange.minX).to.eql(0);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.maxX).toEqual(1); expect(tileRange.maxX).to.eql(1);
expect(tileRange.maxY).toEqual(0); expect(tileRange.maxY).to.eql(0);
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 2); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 2);
expect(tileRange.minX).toEqual(1); expect(tileRange.minX).to.eql(1);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.maxX).toEqual(2); expect(tileRange.maxX).to.eql(2);
expect(tileRange.maxY).toEqual(0); expect(tileRange.maxY).to.eql(0);
tileRange = tileGrid.getTileRangeForExtentAndZ(e, 3); tileRange = tileGrid.getTileRangeForExtentAndZ(e, 3);
expect(tileRange.minX).toEqual(4); expect(tileRange.minX).to.eql(4);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.maxX).toEqual(5); expect(tileRange.maxX).to.eql(5);
expect(tileRange.maxY).toEqual(1); expect(tileRange.maxY).to.eql(1);
}); });
}); });
@@ -589,26 +589,26 @@ describe('ol.tilegrid.TileGrid', function() {
return false; return false;
}); });
expect(zs.length).toEqual(3); expect(zs.length).to.eql(3);
expect(tileRanges.length).toEqual(3); expect(tileRanges.length).to.eql(3);
expect(zs[0]).toEqual(2); expect(zs[0]).to.eql(2);
expect(tileRanges[0].minX).toEqual(2); expect(tileRanges[0].minX).to.eql(2);
expect(tileRanges[0].minY).toEqual(1); expect(tileRanges[0].minY).to.eql(1);
expect(tileRanges[0].maxX).toEqual(3); expect(tileRanges[0].maxX).to.eql(3);
expect(tileRanges[0].maxY).toEqual(1); expect(tileRanges[0].maxY).to.eql(1);
expect(zs[1]).toEqual(1); expect(zs[1]).to.eql(1);
expect(tileRanges[1].minX).toEqual(1); expect(tileRanges[1].minX).to.eql(1);
expect(tileRanges[1].minY).toEqual(0); expect(tileRanges[1].minY).to.eql(0);
expect(tileRanges[1].maxX).toEqual(1); expect(tileRanges[1].maxX).to.eql(1);
expect(tileRanges[1].maxY).toEqual(0); expect(tileRanges[1].maxY).to.eql(0);
expect(zs[2]).toEqual(0); expect(zs[2]).to.eql(0);
expect(tileRanges[2].minX).toEqual(0); expect(tileRanges[2].minX).to.eql(0);
expect(tileRanges[2].minY).toEqual(0); expect(tileRanges[2].minY).to.eql(0);
expect(tileRanges[2].maxX).toEqual(0); expect(tileRanges[2].maxX).to.eql(0);
expect(tileRanges[2].maxY).toEqual(0); expect(tileRanges[2].maxY).to.eql(0);
}); });
}); });
@@ -621,10 +621,10 @@ describe('ol.tilegrid.TileGrid', function() {
tileSize: tileSize tileSize: tileSize
}); });
expect(tileGrid.getZForResolution(1000)).toEqual(0); expect(tileGrid.getZForResolution(1000)).to.eql(0);
expect(tileGrid.getZForResolution(500)).toEqual(1); expect(tileGrid.getZForResolution(500)).to.eql(1);
expect(tileGrid.getZForResolution(250)).toEqual(2); expect(tileGrid.getZForResolution(250)).to.eql(2);
expect(tileGrid.getZForResolution(100)).toEqual(3); expect(tileGrid.getZForResolution(100)).to.eql(3);
}); });
}); });
@@ -637,19 +637,19 @@ describe('ol.tilegrid.TileGrid', function() {
tileSize: tileSize tileSize: tileSize
}); });
expect(tileGrid.getZForResolution(2000)).toEqual(0); expect(tileGrid.getZForResolution(2000)).to.eql(0);
expect(tileGrid.getZForResolution(1000)).toEqual(0); expect(tileGrid.getZForResolution(1000)).to.eql(0);
expect(tileGrid.getZForResolution(900)).toEqual(0); expect(tileGrid.getZForResolution(900)).to.eql(0);
expect(tileGrid.getZForResolution(750)).toEqual(1); expect(tileGrid.getZForResolution(750)).to.eql(1);
expect(tileGrid.getZForResolution(625)).toEqual(1); expect(tileGrid.getZForResolution(625)).to.eql(1);
expect(tileGrid.getZForResolution(500)).toEqual(1); expect(tileGrid.getZForResolution(500)).to.eql(1);
expect(tileGrid.getZForResolution(475)).toEqual(1); expect(tileGrid.getZForResolution(475)).to.eql(1);
expect(tileGrid.getZForResolution(375)).toEqual(2); expect(tileGrid.getZForResolution(375)).to.eql(2);
expect(tileGrid.getZForResolution(250)).toEqual(2); expect(tileGrid.getZForResolution(250)).to.eql(2);
expect(tileGrid.getZForResolution(200)).toEqual(2); expect(tileGrid.getZForResolution(200)).to.eql(2);
expect(tileGrid.getZForResolution(125)).toEqual(3); expect(tileGrid.getZForResolution(125)).to.eql(3);
expect(tileGrid.getZForResolution(100)).toEqual(3); expect(tileGrid.getZForResolution(100)).to.eql(3);
expect(tileGrid.getZForResolution(50)).toEqual(3); expect(tileGrid.getZForResolution(50)).to.eql(3);
}); });
}); });

View File

@@ -37,7 +37,7 @@ describe('ol.TileQueue', function() {
addRandomPriorityTiles(tq, 100); addRandomPriorityTiles(tq, 100);
tq.heapify_(); tq.heapify_();
expect(isHeap(tq)).toBeTruthy(); expect(isHeap(tq)).to.be.ok();
}); });
}); });
@@ -61,8 +61,8 @@ describe('ol.TileQueue', function() {
}; };
tq.reprioritize(); tq.reprioritize();
expect(tq.heap_.length).toEqual(50); expect(tq.heap_.length).to.eql(50);
expect(isHeap(tq)).toBeTruthy(); expect(isHeap(tq)).to.be.ok();
}); });
}); });

View File

@@ -5,45 +5,45 @@ describe('ol.TileRange', function() {
describe('constructor', function() { describe('constructor', function() {
it('creates a range', function() { it('creates a range', function() {
var range = new ol.TileRange(1, 2, 3, 4); var range = new ol.TileRange(1, 2, 3, 4);
expect(range).toBeA(ol.TileRange); expect(range).to.be.a(ol.TileRange);
}); });
it('can represent a range of one tile', function() { it('can represent a range of one tile', function() {
var range = new ol.TileRange(2, 3, 2, 3); var range = new ol.TileRange(2, 3, 2, 3);
expect(range).toBeA(ol.TileRange); expect(range).to.be.a(ol.TileRange);
expect(range.getHeight()).toBe(1); expect(range.getHeight()).to.be(1);
expect(range.getWidth()).toBe(1); expect(range.getWidth()).to.be(1);
}); });
}); });
describe('contains', function() { describe('contains', function() {
it('returns the expected value', function() { it('returns the expected value', function() {
var tileRange = new ol.TileRange(1, 1, 3, 3); var tileRange = new ol.TileRange(1, 1, 3, 3);
expect(tileRange.contains(new ol.TileCoord(0, 0, 0))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 0, 0))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 0, 1))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 0, 1))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 0, 2))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 0, 2))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 0, 3))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 0, 3))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 0, 4))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 0, 4))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 1, 0))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 1, 0))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 1, 1))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 1, 1))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 1, 2))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 1, 2))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 1, 3))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 1, 3))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 1, 4))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 1, 4))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 2, 0))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 2, 0))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 2, 1))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 2, 1))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 2, 2))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 2, 2))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 2, 3))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 2, 3))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 2, 4))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 2, 4))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 3, 0))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 3, 0))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 3, 1))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 3, 1))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 3, 2))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 3, 2))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 3, 3))).toBeTruthy(); expect(tileRange.contains(new ol.TileCoord(0, 3, 3))).to.be.ok();
expect(tileRange.contains(new ol.TileCoord(0, 3, 4))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 3, 4))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 4, 0))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 4, 0))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 4, 1))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 4, 1))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 4, 2))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 4, 2))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 4, 3))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 4, 3))).to.not.be();
expect(tileRange.contains(new ol.TileCoord(0, 4, 4))).toBeFalsy(); expect(tileRange.contains(new ol.TileCoord(0, 4, 4))).to.not.be();
}); });
}); });
@@ -52,10 +52,10 @@ describe('ol.TileRange', function() {
var tileRange = new ol.TileRange.boundingTileRange( var tileRange = new ol.TileRange.boundingTileRange(
new ol.TileCoord(3, 1, 3), new ol.TileCoord(3, 1, 3),
new ol.TileCoord(3, 2, 0)); new ol.TileCoord(3, 2, 0));
expect(tileRange.minX).toEqual(1); expect(tileRange.minX).to.eql(1);
expect(tileRange.minY).toEqual(0); expect(tileRange.minY).to.eql(0);
expect(tileRange.maxX).toEqual(2); expect(tileRange.maxX).to.eql(2);
expect(tileRange.maxY).toEqual(3); expect(tileRange.maxY).to.eql(3);
}); });
describe('with mixed z', function() { describe('with mixed z', function() {
@@ -63,7 +63,7 @@ describe('ol.TileRange', function() {
var tileRange = new ol.TileRange.boundingTileRange( var tileRange = new ol.TileRange.boundingTileRange(
new ol.TileCoord(3, 1, 3), new ol.TileCoord(3, 1, 3),
new ol.TileCoord(4, 2, 0)); new ol.TileCoord(4, 2, 0));
}).toThrow(); }).to.throwException();
}); });
}); });
@@ -75,11 +75,11 @@ describe('ol.TileRange', function() {
var diff2 = new ol.TileRange(0, 1, 3, 4); var diff2 = new ol.TileRange(0, 1, 3, 4);
var diff3 = new ol.TileRange(0, 2, 2, 4); var diff3 = new ol.TileRange(0, 2, 2, 4);
var diff4 = new ol.TileRange(1, 1, 2, 4); var diff4 = new ol.TileRange(1, 1, 2, 4);
expect(one.equals(same)).toBe(true); expect(one.equals(same)).to.be(true);
expect(one.equals(diff1)).toBe(false); expect(one.equals(diff1)).to.be(false);
expect(one.equals(diff2)).toBe(false); expect(one.equals(diff2)).to.be(false);
expect(one.equals(diff3)).toBe(false); expect(one.equals(diff3)).to.be(false);
expect(one.equals(diff4)).toBe(false); expect(one.equals(diff4)).to.be(false);
}); });
}); });
@@ -89,10 +89,10 @@ describe('ol.TileRange', function() {
var other = new ol.TileRange(-1, 10, -3, 12); var other = new ol.TileRange(-1, 10, -3, 12);
one.extend(other); one.extend(other);
expect(one.minX).toBe(-1); expect(one.minX).to.be(-1);
expect(one.minY).toBe(1); expect(one.minY).to.be(1);
expect(one.maxX).toBe(2); expect(one.maxX).to.be(2);
expect(one.maxY).toBe(12); expect(one.maxY).to.be(12);
}); });
}); });
@@ -101,8 +101,8 @@ describe('ol.TileRange', function() {
it('returns the expected size', function() { it('returns the expected size', function() {
var tileRange = new ol.TileRange(0, 1, 2, 4); var tileRange = new ol.TileRange(0, 1, 2, 4);
var size = tileRange.getSize(); var size = tileRange.getSize();
expect(size.width).toEqual(3); expect(size.width).to.eql(3);
expect(size.height).toEqual(4); expect(size.height).to.eql(4);
}); });
}); });
@@ -113,19 +113,19 @@ describe('ol.TileRange', function() {
var overlapsLeft = new ol.TileRange(-3, 1, 0, 4); var overlapsLeft = new ol.TileRange(-3, 1, 0, 4);
var overlapsTop = new ol.TileRange(0, 4, 2, 5); var overlapsTop = new ol.TileRange(0, 4, 2, 5);
var overlapsBottom = new ol.TileRange(0, -3, 2, 1); var overlapsBottom = new ol.TileRange(0, -3, 2, 1);
expect(one.intersects(overlapsLeft)).toBe(true); expect(one.intersects(overlapsLeft)).to.be(true);
expect(one.intersects(overlapsRight)).toBe(true); expect(one.intersects(overlapsRight)).to.be(true);
expect(one.intersects(overlapsTop)).toBe(true); expect(one.intersects(overlapsTop)).to.be(true);
expect(one.intersects(overlapsBottom)).toBe(true); expect(one.intersects(overlapsBottom)).to.be(true);
var right = new ol.TileRange(3, 1, 5, 4); var right = new ol.TileRange(3, 1, 5, 4);
var left = new ol.TileRange(-3, 1, -1, 4); var left = new ol.TileRange(-3, 1, -1, 4);
var above = new ol.TileRange(0, 5, 2, 6); var above = new ol.TileRange(0, 5, 2, 6);
var below = new ol.TileRange(0, -3, 2, 0); var below = new ol.TileRange(0, -3, 2, 0);
expect(one.intersects(right)).toBe(false); expect(one.intersects(right)).to.be(false);
expect(one.intersects(left)).toBe(false); expect(one.intersects(left)).to.be(false);
expect(one.intersects(above)).toBe(false); expect(one.intersects(above)).to.be(false);
expect(one.intersects(below)).toBe(false); expect(one.intersects(below)).to.be(false);
}); });
}); });

View File

@@ -5,8 +5,8 @@ describe('ol.TileUrlFunction', function() {
describe('createFromTemplate', function() { describe('createFromTemplate', function() {
it('creates expected URL', function() { it('creates expected URL', function() {
var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}'); var tileUrl = ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}');
expect(tileUrl(new ol.TileCoord(3, 2, 1))).toEqual('3/2/1'); expect(tileUrl(new ol.TileCoord(3, 2, 1))).to.eql('3/2/1');
expect(tileUrl(null)).toBeUndefined(); expect(tileUrl(null)).to.be(undefined);
}); });
describe('with number range', function() { describe('with number range', function() {
it('creates expected URL', function() { it('creates expected URL', function() {
@@ -14,11 +14,11 @@ describe('ol.TileUrlFunction', function() {
var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(template); var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(template);
var tileCoord = new ol.TileCoord(3, 2, 1); var tileCoord = new ol.TileCoord(3, 2, 1);
tileCoord.hash = function() { return 3; }; tileCoord.hash = function() { return 3; };
expect(tileUrlFunction(tileCoord)).toEqual('http://tile-1/3/2/1'); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-1/3/2/1');
tileCoord.hash = function() { return 2; }; tileCoord.hash = function() { return 2; };
expect(tileUrlFunction(tileCoord)).toEqual('http://tile-3/3/2/1'); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-3/3/2/1');
tileCoord.hash = function() { return 1; }; tileCoord.hash = function() { return 1; };
expect(tileUrlFunction(tileCoord)).toEqual('http://tile-2/3/2/1'); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-2/3/2/1');
}); });
}); });
describe('with character range', function() { describe('with character range', function() {
@@ -27,11 +27,11 @@ describe('ol.TileUrlFunction', function() {
var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(template); var tileUrlFunction = ol.TileUrlFunction.createFromTemplate(template);
var tileCoord = new ol.TileCoord(3, 2, 1); var tileCoord = new ol.TileCoord(3, 2, 1);
tileCoord.hash = function() { return 3; }; tileCoord.hash = function() { return 3; };
expect(tileUrlFunction(tileCoord)).toEqual('http://tile-c/3/2/1'); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-c/3/2/1');
tileCoord.hash = function() { return 2; }; tileCoord.hash = function() { return 2; };
expect(tileUrlFunction(tileCoord)).toEqual('http://tile-e/3/2/1'); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-e/3/2/1');
tileCoord.hash = function() { return 1; }; tileCoord.hash = function() { return 1; };
expect(tileUrlFunction(tileCoord)).toEqual('http://tile-d/3/2/1'); expect(tileUrlFunction(tileCoord)).to.eql('http://tile-d/3/2/1');
}); });
}); });
}); });
@@ -43,8 +43,8 @@ describe('ol.TileUrlFunction', function() {
return new ol.TileCoord(tileCoord.z, tileCoord.x, -tileCoord.y); return new ol.TileCoord(tileCoord.z, tileCoord.x, -tileCoord.y);
}, },
ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}')); ol.TileUrlFunction.createFromTemplate('{z}/{x}/{y}'));
expect(tileUrl(new ol.TileCoord(3, 2, -1))).toEqual('3/2/1'); expect(tileUrl(new ol.TileCoord(3, 2, -1))).to.eql('3/2/1');
expect(tileUrl(null)).toBeUndefined(); expect(tileUrl(null)).to.be(undefined);
}); });
}); });
@@ -56,8 +56,8 @@ describe('ol.TileUrlFunction', function() {
]); ]);
var tileUrl1 = tileUrl(new ol.TileCoord(1, 0, 0)); var tileUrl1 = tileUrl(new ol.TileCoord(1, 0, 0));
var tileUrl2 = tileUrl(new ol.TileCoord(1, 0, 1)); var tileUrl2 = tileUrl(new ol.TileCoord(1, 0, 1));
expect(tileUrl1).not.toEqual(tileUrl2); expect(tileUrl1).not.to.eql(tileUrl2);
expect(tileUrl(null)).toBeUndefined(); expect(tileUrl(null)).to.be(undefined);
}); });
}); });
@@ -78,7 +78,7 @@ describe('ol.TileUrlFunction', function() {
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'STYLES=&CRS=EPSG%3A3857&BBOX=-20037508.342789244%2C2' + 'STYLES=&CRS=EPSG%3A3857&BBOX=-20037508.342789244%2C2' +
'0037508.342789244%2C0%2C40075016.68557849'; '0037508.342789244%2C0%2C40075016.68557849';
expect(tileUrl).toEqual(expected); expect(tileUrl).to.eql(expected);
}); });
it('creates expected URL respecting axis orientation', function() { it('creates expected URL respecting axis orientation', function() {
var epsg4326 = ol.projection.get('EPSG:4326'); var epsg4326 = ol.projection.get('EPSG:4326');
@@ -90,7 +90,7 @@ describe('ol.TileUrlFunction', function() {
'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' + 'GetMap&FORMAT=image%2Fpng&TRANSPARENT=true&WIDTH=256&HEIGHT=256&' +
'STYLES=&CRS=EPSG%3A4326&BBOX=20037508.342789244%2C' + 'STYLES=&CRS=EPSG%3A4326&BBOX=20037508.342789244%2C' +
'-20037508.342789244%2C40075016.68557849%2C0'; '-20037508.342789244%2C40075016.68557849%2C0';
expect(tileUrl).toEqual(expected); expect(tileUrl).to.eql(expected);
}); });
}); });
}); });

View File

@@ -10,9 +10,9 @@ describe('ol.View2D', function() {
var options = {}; var options = {};
var fn = ol.View2D.createConstraints_(options).resolution; var fn = ol.View2D.createConstraints_(options).resolution;
expect(fn(156543.03392804097, 0)) expect(fn(156543.03392804097, 0))
.toRoughlyEqual(156543.03392804097, 1e-9); .to.roughlyEqual(156543.03392804097, 1e-9);
expect(fn(78271.51696402048, 0)) expect(fn(78271.51696402048, 0))
.toRoughlyEqual(78271.51696402048, 1e-10); .to.roughlyEqual(78271.51696402048, 1e-10);
}); });
}); });
@@ -25,12 +25,12 @@ describe('ol.View2D', function() {
zoomFactor: 3 zoomFactor: 3
}; };
var fn = ol.View2D.createConstraints_(options).resolution; var fn = ol.View2D.createConstraints_(options).resolution;
expect(fn(82, 0)).toEqual(81); expect(fn(82, 0)).to.eql(81);
expect(fn(81, 0)).toEqual(81); expect(fn(81, 0)).to.eql(81);
expect(fn(27, 0)).toEqual(27); expect(fn(27, 0)).to.eql(27);
expect(fn(9, 0)).toEqual(9); expect(fn(9, 0)).to.eql(9);
expect(fn(3, 0)).toEqual(3); expect(fn(3, 0)).to.eql(3);
expect(fn(2, 0)).toEqual(3); expect(fn(2, 0)).to.eql(3);
}); });
}); });
@@ -40,11 +40,11 @@ describe('ol.View2D', function() {
resolutions: [97, 76, 65, 54, 0.45] resolutions: [97, 76, 65, 54, 0.45]
}; };
var fn = ol.View2D.createConstraints_(options).resolution; var fn = ol.View2D.createConstraints_(options).resolution;
expect(fn(97, 0)).toEqual(97); expect(fn(97, 0)).to.eql(97);
expect(fn(76, 0)).toEqual(76); expect(fn(76, 0)).to.eql(76);
expect(fn(65, 0)).toEqual(65); expect(fn(65, 0)).to.eql(65);
expect(fn(54, 0)).toEqual(54); expect(fn(54, 0)).to.eql(54);
expect(fn(0.45, 0)).toEqual(0.45); expect(fn(0.45, 0)).to.eql(0.45);
}); });
}); });
@@ -54,8 +54,8 @@ describe('ol.View2D', function() {
it('gives a correct rotation constraint function', function() { it('gives a correct rotation constraint function', function() {
var options = {}; var options = {};
var fn = ol.View2D.createConstraints_(options).rotation; var fn = ol.View2D.createConstraints_(options).rotation;
expect(fn(0.01, 0)).toEqual(0); expect(fn(0.01, 0)).to.eql(0);
expect(fn(0.15, 0)).toEqual(0.15); expect(fn(0.15, 0)).to.eql(0.15);
}); });
}); });

View File

@@ -10,26 +10,26 @@ describe('ol.tilegrid.XYZ', function() {
var xyzTileGrid = new ol.tilegrid.XYZ({ var xyzTileGrid = new ol.tilegrid.XYZ({
maxZoom: 22 maxZoom: 22
}); });
expect(xyzTileGrid.getResolution(0)).toRoughlyEqual(156543.04, 1e-2); expect(xyzTileGrid.getResolution(0)).to.roughlyEqual(156543.04, 1e-2);
expect(xyzTileGrid.getResolution(1)).toRoughlyEqual(78271.52, 1e-2); expect(xyzTileGrid.getResolution(1)).to.roughlyEqual(78271.52, 1e-2);
expect(xyzTileGrid.getResolution(2)).toRoughlyEqual(39135.76, 1e-2); expect(xyzTileGrid.getResolution(2)).to.roughlyEqual(39135.76, 1e-2);
expect(xyzTileGrid.getResolution(3)).toRoughlyEqual(19567.88, 1e-2); expect(xyzTileGrid.getResolution(3)).to.roughlyEqual(19567.88, 1e-2);
expect(xyzTileGrid.getResolution(4)).toRoughlyEqual(9783.94, 1e-2); expect(xyzTileGrid.getResolution(4)).to.roughlyEqual(9783.94, 1e-2);
expect(xyzTileGrid.getResolution(5)).toRoughlyEqual(4891.97, 1e-2); expect(xyzTileGrid.getResolution(5)).to.roughlyEqual(4891.97, 1e-2);
expect(xyzTileGrid.getResolution(6)).toRoughlyEqual(2445.98, 1e-2); expect(xyzTileGrid.getResolution(6)).to.roughlyEqual(2445.98, 1e-2);
expect(xyzTileGrid.getResolution(7)).toRoughlyEqual(1222.99, 1e-2); expect(xyzTileGrid.getResolution(7)).to.roughlyEqual(1222.99, 1e-2);
expect(xyzTileGrid.getResolution(8)).toRoughlyEqual(611.50, 1e-2); expect(xyzTileGrid.getResolution(8)).to.roughlyEqual(611.50, 1e-2);
expect(xyzTileGrid.getResolution(9)).toRoughlyEqual(305.75, 1e-2); expect(xyzTileGrid.getResolution(9)).to.roughlyEqual(305.75, 1e-2);
expect(xyzTileGrid.getResolution(10)).toRoughlyEqual(152.87, 1e-2); expect(xyzTileGrid.getResolution(10)).to.roughlyEqual(152.87, 1e-2);
expect(xyzTileGrid.getResolution(11)).toRoughlyEqual(76.44, 1e-2); expect(xyzTileGrid.getResolution(11)).to.roughlyEqual(76.44, 1e-2);
expect(xyzTileGrid.getResolution(12)).toRoughlyEqual(38.22, 1e-2); expect(xyzTileGrid.getResolution(12)).to.roughlyEqual(38.22, 1e-2);
expect(xyzTileGrid.getResolution(13)).toRoughlyEqual(19.11, 1e-2); expect(xyzTileGrid.getResolution(13)).to.roughlyEqual(19.11, 1e-2);
expect(xyzTileGrid.getResolution(14)).toRoughlyEqual(9.55, 1e-2); expect(xyzTileGrid.getResolution(14)).to.roughlyEqual(9.55, 1e-2);
expect(xyzTileGrid.getResolution(15)).toRoughlyEqual(4.78, 1e-2); expect(xyzTileGrid.getResolution(15)).to.roughlyEqual(4.78, 1e-2);
expect(xyzTileGrid.getResolution(16)).toRoughlyEqual(2.39, 1e-2); expect(xyzTileGrid.getResolution(16)).to.roughlyEqual(2.39, 1e-2);
expect(xyzTileGrid.getResolution(17)).toRoughlyEqual(1.19, 1e-2); expect(xyzTileGrid.getResolution(17)).to.roughlyEqual(1.19, 1e-2);
expect(xyzTileGrid.getResolution(18)).toRoughlyEqual(0.60, 1e-2); expect(xyzTileGrid.getResolution(18)).to.roughlyEqual(0.60, 1e-2);
expect(xyzTileGrid.getResolution(19)).toRoughlyEqual(0.30, 1e-2); expect(xyzTileGrid.getResolution(19)).to.roughlyEqual(0.30, 1e-2);
}); });
}); });

24
test/test-extensions.js Normal file
View File

@@ -0,0 +1,24 @@
function waitsFor(condition, message, timeout, callback) {
var timeWaiting = 0;
function inner() {
if (condition()) {
callback();
return;
}
if (timeWaiting >= timeout) {
throw new Error(message);
}
timeWaiting += 10;
setTimeout(inner, 10);
}
inner();
}
expect.Assertion.prototype.roughlyEqual = function(other, tol) {
return Math.abs(this.actual - other) <= tol;
};