henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | * or more contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. The ASF licenses this file |
| 6 | * to you under the Apache License, Version 2.0 (the |
| 7 | * "License"); you may not use this file except in compliance |
| 8 | * with the License. You may obtain a copy of the License at |
| 9 | * |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | /* jshint -W100 */ |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 20 | |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 21 | /* |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 22 | * Fully Async JavaScript test suite for ThriftTest.thrift. |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 23 | * These tests are designed to exercise the WebSocket transport |
| 24 | * (which is exclusively async). |
| 25 | * |
| 26 | * To compile client code for this test use: |
| 27 | * $ thrift -gen js ThriftTest.thrift |
| 28 | */ |
| 29 | |
| 30 | |
| 31 | |
| 32 | // all Languages in UTF-8 |
| 33 | var stringTest = "Afrikaans, Alemannisch, Aragonés, العربية, مصرى, Asturianu, Aymar aru, Azərbaycan, Башҡорт, Boarisch, Žemaitėška, Беларуская, Беларуская (тарашкевіца), Български, Bamanankan, বাংলা, Brezhoneg, Bosanski, Català, Mìng-dĕ̤ng-ngṳ̄, Нохчийн, Cebuano, ᏣᎳᎩ, Česky, Словѣ́ньскъ / ⰔⰎⰑⰂⰡⰐⰠⰔⰍⰟ, Чӑвашла, Cymraeg, Dansk, Zazaki, ދިވެހިބަސް, Ελληνικά, Emiliàn e rumagnòl, English, Esperanto, Español, Eesti, Euskara, فارسی, Suomi, Võro, Føroyskt, Français, Arpetan, Furlan, Frysk, Gaeilge, 贛語, Gàidhlig, Galego, Avañe'ẽ, ગુજરાતી, Gaelg, עברית, हिन्दी, Fiji Hindi, Hrvatski, Kreyòl ayisyen, Magyar, Հայերեն, Interlingua, Bahasa Indonesia, Ilokano, Ido, Íslenska, Italiano, 日本語, Lojban, Basa Jawa, ქართული, Kongo, Kalaallisut, ಕನ್ನಡ, 한국어, Къарачай-Малкъар, Ripoarisch, Kurdî, Коми, Kernewek, Кыргызча, Latina, Ladino, Lëtzebuergesch, Limburgs, Lingála, ລາວ, Lietuvių, Latviešu, Basa Banyumasan, Malagasy, Македонски, മലയാളം, मराठी, Bahasa Melayu, مازِرونی, Nnapulitano, Nedersaksisch, नेपाल भाषा, Nederlands, Norsk (nynorsk), Norsk (bokmål), Nouormand, Diné bizaad, Occitan, Иронау, Papiamentu, Deitsch, Norfuk / Pitkern, Polski, پنجابی, پښتو, Português, Runa Simi, Rumantsch, Romani, Română, Русский, Саха тыла, Sardu, Sicilianu, Scots, Sámegiella, Simple English, Slovenčina, Slovenščina, Српски / Srpski, Seeltersk, Svenska, Kiswahili, தமிழ், తెలుగు, Тоҷикӣ, ไทย, Türkmençe, Tagalog, Türkçe, Татарча/Tatarça, Українська, اردو, Tiếng Việt, Volapük, Walon, Winaray, 吴语, isiXhosa, ייִדיש, Yorùbá, Zeêuws, 中文, Bân-lâm-gú, 粵語"; |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 34 | |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 35 | function checkRecursively(map1, map2) { |
| 36 | if (typeof map1 !== 'function' && typeof map2 !== 'function') { |
| 37 | if (!map1 || typeof map1 !== 'object') { |
| 38 | equal(map1, map2); |
| 39 | } else { |
| 40 | for (var key in map1) { |
| 41 | checkRecursively(map1[key], map2[key]); |
| 42 | } |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 47 | module('Base Types'); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 48 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 49 | asyncTest('Void', function() { |
| 50 | expect(1); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 51 | client.testVoid(function(result) { |
| 52 | equal(result, undefined); |
| 53 | QUnit.start(); |
| 54 | }); |
| 55 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 56 | |
| 57 | |
| 58 | asyncTest('String', function() { |
| 59 | expect(3); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 60 | QUnit.stop(2); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 61 | client.testString('', function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 62 | equal(result, ''); |
| 63 | QUnit.start(); |
| 64 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 65 | client.testString(stringTest, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 66 | equal(result, stringTest); |
| 67 | QUnit.start(); |
| 68 | }); |
| 69 | |
| 70 | var specialCharacters = 'quote: \" backslash:' + |
| 71 | ' forwardslash-escaped: \/ ' + |
| 72 | ' backspace: \b formfeed: \f newline: \n return: \r tab: ' + |
| 73 | ' now-all-of-them-together: "\\\/\b\n\r\t' + |
| 74 | ' now-a-bunch-of-junk: !@#$%&()(&%$#{}{}<><><'; |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 75 | client.testString(specialCharacters, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 76 | equal(result, specialCharacters); |
| 77 | QUnit.start(); |
| 78 | }); |
| 79 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 80 | asyncTest('Double', function() { |
| 81 | expect(4); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 82 | QUnit.stop(3); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 83 | client.testDouble(0, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 84 | equal(result, 0); |
| 85 | QUnit.start(); |
| 86 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 87 | client.testDouble(-1, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 88 | equal(result, -1); |
| 89 | QUnit.start(); |
| 90 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 91 | client.testDouble(3.14, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 92 | equal(result, 3.14); |
| 93 | QUnit.start(); |
| 94 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 95 | client.testDouble(Math.pow(2, 60), function(result) { |
| 96 | equal(result, Math.pow(2, 60)); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 97 | QUnit.start(); |
| 98 | }); |
| 99 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 100 | // TODO: add testBinary() |
| 101 | asyncTest('Byte', function() { |
| 102 | expect(2); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 103 | QUnit.stop(); |
| 104 | client.testByte(0, function(result) { |
| 105 | equal(result, 0); |
| 106 | QUnit.start(); |
| 107 | }); |
| 108 | client.testByte(0x01, function(result) { |
| 109 | equal(result, 0x01); |
| 110 | QUnit.start(); |
| 111 | }); |
| 112 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 113 | asyncTest('I32', function() { |
| 114 | expect(3); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 115 | QUnit.stop(2); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 116 | client.testI32(0, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 117 | equal(result, 0); |
| 118 | QUnit.start(); |
| 119 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 120 | client.testI32(Math.pow(2, 30), function(result) { |
| 121 | equal(result, Math.pow(2, 30)); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 122 | QUnit.start(); |
| 123 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 124 | client.testI32(-Math.pow(2, 30), function(result) { |
| 125 | equal(result, -Math.pow(2, 30)); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 126 | QUnit.start(); |
| 127 | }); |
| 128 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 129 | asyncTest('I64', function() { |
| 130 | expect(3); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 131 | QUnit.stop(2); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 132 | client.testI64(0, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 133 | equal(result, 0); |
| 134 | QUnit.start(); |
| 135 | }); |
| 136 | //This is usually 2^60 but JS cannot represent anything over 2^52 accurately |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 137 | client.testI64(Math.pow(2, 52), function(result) { |
| 138 | equal(result, Math.pow(2, 52)); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 139 | QUnit.start(); |
| 140 | }); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 141 | client.testI64(-Math.pow(2, 52), function(result) { |
| 142 | equal(result, -Math.pow(2, 52)); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 143 | QUnit.start(); |
| 144 | }); |
| 145 | }); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 146 | |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 147 | |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 148 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 149 | |
| 150 | module('Structured Types'); |
| 151 | |
| 152 | asyncTest('Struct', function() { |
| 153 | expect(5); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 154 | var structTestInput = new ThriftTest.Xtruct(); |
| 155 | structTestInput.string_thing = 'worked'; |
| 156 | structTestInput.byte_thing = 0x01; |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 157 | structTestInput.i32_thing = Math.pow(2, 30); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 158 | //This is usually 2^60 but JS cannot represent anything over 2^52 accurately |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 159 | structTestInput.i64_thing = Math.pow(2, 52); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 160 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 161 | client.testStruct(structTestInput, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 162 | equal(result.string_thing, structTestInput.string_thing); |
| 163 | equal(result.byte_thing, structTestInput.byte_thing); |
| 164 | equal(result.i32_thing, structTestInput.i32_thing); |
| 165 | equal(result.i64_thing, structTestInput.i64_thing); |
| 166 | equal(JSON.stringify(result), JSON.stringify(structTestInput)); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 167 | QUnit.start(); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 168 | }); |
| 169 | }); |
| 170 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 171 | asyncTest('Nest', function() { |
| 172 | expect(7); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 173 | var xtrTestInput = new ThriftTest.Xtruct(); |
| 174 | xtrTestInput.string_thing = 'worked'; |
| 175 | xtrTestInput.byte_thing = 0x01; |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 176 | xtrTestInput.i32_thing = Math.pow(2, 30); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 177 | //This is usually 2^60 but JS cannot represent anything over 2^52 accurately |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 178 | xtrTestInput.i64_thing = Math.pow(2, 52); |
| 179 | |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 180 | var nestTestInput = new ThriftTest.Xtruct2(); |
| 181 | nestTestInput.byte_thing = 0x02; |
| 182 | nestTestInput.struct_thing = xtrTestInput; |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 183 | nestTestInput.i32_thing = Math.pow(2, 15); |
| 184 | |
| 185 | client.testNest(nestTestInput, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 186 | equal(result.byte_thing, nestTestInput.byte_thing); |
| 187 | equal(result.struct_thing.string_thing, nestTestInput.struct_thing.string_thing); |
| 188 | equal(result.struct_thing.byte_thing, nestTestInput.struct_thing.byte_thing); |
| 189 | equal(result.struct_thing.i32_thing, nestTestInput.struct_thing.i32_thing); |
| 190 | equal(result.struct_thing.i64_thing, nestTestInput.struct_thing.i64_thing); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 191 | equal(result.i32_thing, nestTestInput.i32_thing); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 192 | equal(JSON.stringify(result), JSON.stringify(nestTestInput)); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 193 | QUnit.start(); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 194 | }); |
| 195 | }); |
| 196 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 197 | asyncTest('Map', function() { |
| 198 | expect(3); |
| 199 | var mapTestInput = {7: 77, 8: 88, 9: 99}; |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 200 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 201 | client.testMap(mapTestInput, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 202 | for (var key in result) { |
| 203 | equal(result[key], mapTestInput[key]); |
| 204 | } |
| 205 | QUnit.start(); |
| 206 | }); |
| 207 | }); |
| 208 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 209 | asyncTest('StringMap', function() { |
| 210 | expect(6); |
| 211 | var mapTestInput = { |
| 212 | 'a': '123', 'a b': 'with spaces ', 'same': 'same', '0': 'numeric key', |
| 213 | 'longValue': stringTest, stringTest: 'long key' |
| 214 | }; |
| 215 | |
| 216 | client.testStringMap(mapTestInput, function(result) { |
| 217 | for (var key in result) { |
| 218 | equal(result[key], mapTestInput[key]); |
| 219 | } |
| 220 | QUnit.start(); |
| 221 | }); |
| 222 | }); |
| 223 | |
| 224 | asyncTest('Set', function() { |
| 225 | expect(1); |
| 226 | var setTestInput = [1, 2, 3]; |
| 227 | client.testSet(setTestInput, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 228 | ok(result, setTestInput); |
| 229 | QUnit.start(); |
| 230 | }); |
| 231 | }); |
| 232 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 233 | asyncTest('List', function() { |
| 234 | expect(1); |
| 235 | var listTestInput = [1, 2, 3]; |
| 236 | client.testList(listTestInput, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 237 | ok(result, listTestInput); |
| 238 | QUnit.start(); |
| 239 | }); |
| 240 | }); |
| 241 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 242 | asyncTest('Enum', function() { |
| 243 | expect(1); |
| 244 | client.testEnum(ThriftTest.Numberz.ONE, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 245 | equal(result, ThriftTest.Numberz.ONE); |
| 246 | QUnit.start(); |
| 247 | }); |
| 248 | }); |
| 249 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 250 | asyncTest('TypeDef', function() { |
| 251 | expect(1); |
| 252 | client.testTypedef(69, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 253 | equal(result, 69); |
| 254 | QUnit.start(); |
| 255 | }); |
| 256 | }); |
| 257 | |
| 258 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 259 | module('deeper!'); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 260 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 261 | asyncTest('MapMap', function() { |
| 262 | expect(16); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 263 | var mapMapTestExpectedResult = { |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 264 | '4': {'1': 1, '2': 2, '3': 3, '4': 4}, |
| 265 | '-4': {'-4': -4, '-3': -3, '-2': -2, '-1': -1} |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 266 | }; |
| 267 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 268 | client.testMapMap(1, function(result) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 269 | for (var key in result) { |
| 270 | for (var key2 in result[key]) { |
| 271 | equal(result[key][key2], mapMapTestExpectedResult[key][key2]); |
| 272 | } |
| 273 | } |
| 274 | checkRecursively(result, mapMapTestExpectedResult); |
| 275 | QUnit.start(); |
| 276 | }); |
| 277 | }); |
| 278 | |
| 279 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 280 | module('Exception'); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 281 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 282 | asyncTest('Xception', function() { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 283 | expect(2); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 284 | client.testException('Xception', function(e) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 285 | equal(e.errorCode, 1001); |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 286 | equal(e.message, 'Xception'); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 287 | QUnit.start(); |
| 288 | }); |
| 289 | }); |
| 290 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 291 | asyncTest('no Exception', 0, function() { |
| 292 | expect(1); |
| 293 | client.testException('no Exception', function(e) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 294 | ok(!e); |
| 295 | QUnit.start(); |
| 296 | }); |
| 297 | }); |
| 298 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 299 | module('Insanity'); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 300 | |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 301 | asyncTest('testInsanity', function() { |
| 302 | expect(24); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 303 | var insanity = { |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 304 | '1': { |
| 305 | '2': { |
| 306 | 'userMap': { '5': 5, '8': 8 }, |
| 307 | 'xtructs': [{ |
| 308 | 'string_thing': 'Goodbye4', |
| 309 | 'byte_thing': 4, |
| 310 | 'i32_thing': 4, |
| 311 | 'i64_thing': 4 |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 312 | }, |
| 313 | { |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 314 | 'string_thing': 'Hello2', |
| 315 | 'byte_thing': 2, |
| 316 | 'i32_thing': 2, |
| 317 | 'i64_thing': 2 |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 318 | } |
| 319 | ] |
| 320 | }, |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 321 | '3': { |
| 322 | 'userMap': { '5': 5, '8': 8 }, |
| 323 | 'xtructs': [{ |
| 324 | 'string_thing': 'Goodbye4', |
| 325 | 'byte_thing': 4, |
| 326 | 'i32_thing': 4, |
| 327 | 'i64_thing': 4 |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 328 | }, |
| 329 | { |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 330 | 'string_thing': 'Hello2', |
| 331 | 'byte_thing': 2, |
| 332 | 'i32_thing': 2, |
| 333 | 'i64_thing': 2 |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 334 | } |
| 335 | ] |
| 336 | } |
| 337 | }, |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 338 | '2': { '6': { 'userMap': null, 'xtructs': null } } |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 339 | }; |
Kazuki Matsuda | b909a38 | 2016-02-13 19:36:09 +0900 | [diff] [blame] | 340 | client.testInsanity(new ThriftTest.Insanity(), function(res) { |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 341 | ok(res, JSON.stringify(res)); |
| 342 | ok(insanity, JSON.stringify(insanity)); |
| 343 | checkRecursively(res, insanity); |
| 344 | QUnit.start(); |
| 345 | }); |
| 346 | }); |
| 347 | |
Philip Frank | 8fdd610 | 2017-12-06 12:38:05 +0100 | [diff] [blame] | 348 | module('Oneway'); |
henrique | 2a7dccc | 2014-03-07 22:16:51 +0100 | [diff] [blame] | 349 | |
Philip Frank | 8fdd610 | 2017-12-06 12:38:05 +0100 | [diff] [blame] | 350 | asyncTest('testOneway', function() { |
| 351 | expect(1); |
| 352 | client.testOneway(1, function(result) { |
| 353 | equal(result, undefined); |
| 354 | QUnit.start(); |
| 355 | }); |
| 356 | }); |