2017-12-02 03:52:34 +03:00
|
|
|
/* global QUnit, testLog */
|
2013-07-02 23:20:17 +04:00
|
|
|
|
2013-04-27 01:19:23 +04:00
|
|
|
(function() {
|
|
|
|
|
2017-12-02 03:52:34 +03:00
|
|
|
QUnit.module("strings", {
|
|
|
|
beforeEach: function () {
|
2013-07-02 23:20:17 +04:00
|
|
|
testLog.reset();
|
|
|
|
}
|
|
|
|
});
|
2013-07-02 00:55:39 +04:00
|
|
|
|
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"),
|
2013-07-02 00:55:39 +04:00
|
|
|
"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");
|
2022-03-23 16:05:58 +03:00
|
|
|
assert.ok(testLog.error.contains('["Untranslated source string:","Greeting"]'),
|
2013-07-02 23:20:17 +04:00
|
|
|
'Invalid string keys are logged');
|
|
|
|
|
2017-12-02 03:52:34 +03:00
|
|
|
assert.equal(OpenSeadragon.getString("Errors"), "", "Handled requesting parent key");
|
2022-03-23 16:05:58 +03:00
|
|
|
assert.ok(testLog.error.contains('["Untranslated source string:","Errors"]'),
|
2013-07-02 23:20:17 +04:00
|
|
|
'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");
|
|
|
|
});
|
|
|
|
|
|
|
|
})();
|