summaryrefslogtreecommitdiff
path: root/misc/openlayers/tests/Lang.html
diff options
context:
space:
mode:
authorChris Schlaeger <chris@linux.com>2015-10-17 21:36:38 +0200
committerChris Schlaeger <chris@linux.com>2015-10-17 21:36:38 +0200
commite30f267181d990947e67909de4809fa941698c85 (patch)
tree46e9f94c2b3699ed378963b420b8a8d361286ea1 /misc/openlayers/tests/Lang.html
parente763ceb183f389fcd314a4a6a712d87c9d4cdb32 (diff)
downloadpostrunner-e30f267181d990947e67909de4809fa941698c85.zip
Upgrading openlayers to 3.x
Diffstat (limited to 'misc/openlayers/tests/Lang.html')
-rw-r--r--misc/openlayers/tests/Lang.html106
1 files changed, 0 insertions, 106 deletions
diff --git a/misc/openlayers/tests/Lang.html b/misc/openlayers/tests/Lang.html
deleted file mode 100644
index 9f4fa9b..0000000
--- a/misc/openlayers/tests/Lang.html
+++ /dev/null
@@ -1,106 +0,0 @@
-<html>
-<head>
- <script src="OLLoader.js"></script>
- <script src="../lib/OpenLayers/Lang/en-CA.js" type="text/javascript"></script>
- <script src="../lib/OpenLayers/Lang/fr.js" type="text/javascript"></script>
- <script type="text/javascript">
-
- function test_setCode(t) {
- t.plan(4);
- OpenLayers.Lang.code = null;
-
- // test with no argument - this could result in the default or the
- // browser language if a dictionary exists
- OpenLayers.Lang.setCode();
- t.ok(OpenLayers.Lang.code != null,
- "code set when no argument is sent");
-
- var primary = "xx";
- var subtag = "XX";
- var code = primary + "-" + subtag;
- OpenLayers.Lang[code] = {};
-
- // test code for dictionary that exists
- OpenLayers.Lang.setCode(code);
- t.eq(OpenLayers.Lang.code, code,
- "code properly set for existing dictionary");
-
- // test code for dictionary that doesn't exist
- OpenLayers.Lang.setCode(primary + "-YY");
- t.eq(OpenLayers.Lang.code, OpenLayers.Lang.defaultCode,
- "code set to default for non-existing dictionary");
-
- // test code for existing primary but missing subtag
- OpenLayers.Lang[primary] = {};
- OpenLayers.Lang.setCode(primary + "-YY");
- t.eq(OpenLayers.Lang.code, primary,
- "code set to primary when subtag dictionary is missing");
-
- // clean up
- delete OpenLayers.Lang[code];
- delete OpenLayers.Lang[primary];
- OpenLayers.Lang.code = null;
- }
-
- function test_getCode(t) {
- t.plan(3);
- OpenLayers.Lang.code = null;
-
- // test that a non-null value is retrieved - could be browser language
- // or defaultCode
- var code = OpenLayers.Lang.getCode();
- t.ok(code != null, "returns a non-null code");
- t.ok(OpenLayers.Lang.code != null, "sets the code to a non-null value");
-
- // test that the code is returned if non-null
- OpenLayers.Lang.code = "foo";
- t.eq(OpenLayers.Lang.getCode(), "foo", "returns the code if non-null");
-
- // clean up
- OpenLayers.Lang.code = null;
- }
-
- function test_i18n(t) {
- t.plan(1);
- t.ok(OpenLayers.i18n === OpenLayers.Lang.translate,
- "i18n is an alias for OpenLayers.Lang.translate");
- }
-
- function test_translate(t) {
- var keys = ['test1', 'test3', 'noKey'];
- var codes = ['en', 'en-CA', 'fr', 'fr-CA', 'sw'];
- var result = {
- 'en': {'Overlays':'Overlays',
- 'unhandledRequest':'Unhandled request return foo',
- 'noKey':'noKey'},
- 'en-CA': {'Overlays':'Overlays',
- 'unhandledRequest':'Unhandled request return foo',
- 'noKey':'noKey'},
- 'fr': {'Overlays':'Calques',
- 'unhandledRequest':'Requête non gérée, retournant foo',
- 'noKey':'noKey'},
- 'fr-CA': {'Overlays':'Calques', //this should result in 'fr'
- 'unhandledRequest':'Requête non gérée, retournant foo',
- 'noKey':'noKey'},
- 'sw': {'Overlays':'Overlays', //this should result in 'en'
- 'unhandledRequest':'Unhandled request return foo',
- 'noKey':'noKey'}
- };
-
- t.plan(keys.length*codes.length);
-
- for (var i=0; i<codes.length; ++i) {
- var code = codes[i];
- OpenLayers.Lang.setCode(code);
- t.eq(OpenLayers.Lang.translate('Overlays'), result[code]['Overlays'], "simple key lookup in "+code);
- t.eq(OpenLayers.Lang.translate('unhandledRequest',{'statusText':'foo'}),
- result[code]['unhandledRequest'], "lookup with argument substitution in "+code);
- t.eq(OpenLayers.Lang.translate('noKey'), result[code]['noKey'], "invalid key returns the key in "+code);
- }
- }
-
- </script>
-</head>
-<body>
-</body>
-</html>