summaryrefslogtreecommitdiff
path: root/test/webhelper/testTranslate.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/webhelper/testTranslate.js')
-rw-r--r--test/webhelper/testTranslate.js39
1 files changed, 31 insertions, 8 deletions
diff --git a/test/webhelper/testTranslate.js b/test/webhelper/testTranslate.js
index 10e389c..651ddf5 100644
--- a/test/webhelper/testTranslate.js
+++ b/test/webhelper/testTranslate.js
@@ -49,24 +49,47 @@ function setUp() {
function testStringIsTranslated() {
let translationFunctionWasCalled = false;
let translationFunctionCalledWithString;
- app._translationFunction = function(s) {
+ app.set_translation_function(function(s) {
translationFunctionWasCalled = true;
translationFunctionCalledWithString = s;
return s;
- };
+ });
app.run([]);
assertTrue(translationFunctionWasCalled);
assertEquals('Translate Me', translationFunctionCalledWithString);
}
-// The following two tests are commented out because GJS cannot catch exceptions
+// The following test is commented out because GJS cannot catch exceptions
// across FFI interfaces (e.g. in GObject callbacks.)
// function testMissingTranslationFunctionIsHandled() {
-// assertRaises(app.run([]));
+// assertRaises(function() {
+// app.run([]);
+// });
// }
-// function testBadTranslationFunctionIsHandled() {
-// app._translationFunction = "I am not a function";
-// assertRaises(app.run([]));
-// } \ No newline at end of file
+function testSetBadTranslationFunction() {
+ assertRaises(function() {
+ app.set_translation_function("I am not a function");
+ });
+}
+
+function testGetSetTranslationFunction() {
+ let translationFunction = function(string) {
+ return string;
+ };
+ app.set_translation_function(translationFunction);
+ let actualTranslationFunction = app.get_translation_function();
+ assertEquals(translationFunction, actualTranslationFunction);
+}
+
+function testTranslationFunctionIsNullByDefault() {
+ assertNull(app.get_translation_function());
+}
+
+function testGetSetNullTranslationFunction() {
+ app.set_translation_function(function (s) { return s; });
+ assertNotNull(app.get_translation_function());
+ app.set_translation_function(null);
+ assertNull(app.get_translation_function());
+}