openseadragon/test/modules/strings.js

46 lines
1.6 KiB
JavaScript
Raw Normal View History

2017-12-02 03:52:34 +03:00
/* global QUnit, testLog */
2013-04-27 01:19:23 +04:00
(function() {
2017-12-02 03:52:34 +03:00
QUnit.module("strings", {
beforeEach: function () {
testLog.reset();
}
});
2017-12-02 03:52:34 +03:00
QUnit.test("getSubString", function(assert) {
assert.equal(OpenSeadragon.getString("Errors.Dzi"),
2013-04-27 01:19:23 +04:00
"Hmm, this doesn't appear to be a valid Deep Zoom Image.",
"Read sub-string");
});
2017-12-02 03:52:34 +03:00
QUnit.test("getStringWithPlaceholders", function(assert) {
assert.equal(OpenSeadragon.getString("Errors.OpenFailed", "foo", "bar"),
"Unable to open foo: bar",
"String placeholder replacement");
});
2017-12-02 03:52:34 +03:00
QUnit.test("getInvalidString", function(assert) {
assert.equal(OpenSeadragon.getString("Greeting"), "", "Handled unset string key");
assert.ok(testLog.log.contains('["Untranslated source string:","Greeting"]'),
'Invalid string keys are logged');
2017-12-02 03:52:34 +03:00
assert.equal(OpenSeadragon.getString("Errors"), "", "Handled requesting parent key");
assert.ok(testLog.log.contains('["Untranslated source string:","Errors"]'),
'Invalid string parent keys are logged');
2013-04-27 01:19:23 +04:00
});
2017-12-02 03:52:34 +03:00
QUnit.test("setString", function(assert) {
2013-04-27 01:19:23 +04:00
OpenSeadragon.setString("Greeting", "Hello world");
2017-12-02 03:52:34 +03:00
assert.equal(OpenSeadragon.getString("Greeting"), "Hello world",
2013-04-27 01:19:23 +04:00
"Set a string");
});
2017-12-02 03:52:34 +03:00
QUnit.test("setSubString", function(assert) {
2013-04-27 01:19:23 +04:00
OpenSeadragon.setString("CustomGreeting.Hello", "Hello world");
2017-12-02 03:52:34 +03:00
assert.equal(OpenSeadragon.getString("CustomGreeting.Hello"), "Hello world",
2013-04-27 01:19:23 +04:00
"Set a sub-string");
});
})();