| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 }); | 73 }); |
| 74 | 74 |
| 75 test("flattenArray", 5, function() { | 75 test("flattenArray", 5, function() { |
| 76 deepEqual(base.flattenArray([]), []); | 76 deepEqual(base.flattenArray([]), []); |
| 77 deepEqual(base.flattenArray([["a"]]), ["a"]); | 77 deepEqual(base.flattenArray([["a"]]), ["a"]); |
| 78 deepEqual(base.flattenArray([["a"], ["b"]]), ["a", "b"]); | 78 deepEqual(base.flattenArray([["a"], ["b"]]), ["a", "b"]); |
| 79 deepEqual(base.flattenArray([["a"], ["b", "c"]]), ["a", "b", "c"]); | 79 deepEqual(base.flattenArray([["a"], ["b", "c"]]), ["a", "b", "c"]); |
| 80 deepEqual(base.flattenArray([["a"], [], ["b"]]), ["a", "b"]); | 80 deepEqual(base.flattenArray([["a"], [], ["b"]]), ["a", "b"]); |
| 81 }); | 81 }); |
| 82 | 82 |
| 83 test("callInParallel", 4, function() { | |
| 84 var expectedCall = [true, true, true]; | |
| 85 var expectCompletionCallback = true; | |
| 86 | |
| 87 base.callInParallel([ | |
| 88 function(callback) { | |
| 89 ok(expectedCall[0]); | |
| 90 expectedCall[0] = false; | |
| 91 callback(); | |
| 92 }, | |
| 93 function(callback) { | |
| 94 ok(expectedCall[1]); | |
| 95 expectedCall[1] = false; | |
| 96 callback(); | |
| 97 }, | |
| 98 function(callback) { | |
| 99 ok(expectedCall[2]); | |
| 100 expectedCall[2] = false; | |
| 101 callback(); | |
| 102 }, | |
| 103 ], function() { | |
| 104 ok(expectCompletionCallback); | |
| 105 expectCompletionCallback = false; | |
| 106 }) | |
| 107 }); | |
| 108 | |
| 109 test("RequestTracker", 5, function() { | |
| 110 var ready = false; | |
| 111 var tracker = new base.RequestTracker(1, function() { | |
| 112 ok(ready); | |
| 113 }); | |
| 114 ready = true; | |
| 115 tracker.requestComplete(); | |
| 116 ready = false; | |
| 117 | |
| 118 tracker = new base.RequestTracker(2, function(parameter) { | |
| 119 ok(ready); | |
| 120 equals(parameter, 'argument'); | |
| 121 }, ['argument']); | |
| 122 tracker.requestComplete(); | |
| 123 ready = true; | |
| 124 tracker.requestComplete(); | |
| 125 ready = false; | |
| 126 | |
| 127 tracker = new base.RequestTracker(0, function() { | |
| 128 ok(true); | |
| 129 }); | |
| 130 tracker.requestComplete(); | |
| 131 | |
| 132 tracker = new base.RequestTracker(0); | |
| 133 tracker.requestComplete(); | |
| 134 // Should not barf. | |
| 135 ok(true); | |
| 136 }); | |
| 137 | |
| 138 test("filterDictionary", 3, function() { | 83 test("filterDictionary", 3, function() { |
| 139 var dictionary = { | 84 var dictionary = { |
| 140 'foo': 43, | 85 'foo': 43, |
| 141 'bar': 11 | 86 'bar': 11 |
| 142 }; | 87 }; |
| 143 deepEqual(base.filterDictionary(dictionary, function() { return true; }), { | 88 deepEqual(base.filterDictionary(dictionary, function() { return true; }), { |
| 144 "foo": 43, | 89 "foo": 43, |
| 145 "bar": 11 | 90 "bar": 11 |
| 146 }); | 91 }); |
| 147 deepEqual(base.filterDictionary(dictionary, function() { return false; }), {
}); | 92 deepEqual(base.filterDictionary(dictionary, function() { return false; }), {
}); |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 test("parseJSONP", 6, function() { | 352 test("parseJSONP", 6, function() { |
| 408 deepEqual(base.parseJSONP(""), {}); | 353 deepEqual(base.parseJSONP(""), {}); |
| 409 deepEqual(base.parseJSONP('p({"key": "value"})'), {"key": "value"}); | 354 deepEqual(base.parseJSONP('p({"key": "value"})'), {"key": "value"}); |
| 410 deepEqual(base.parseJSONP('ADD_RESULTS({"dummy":"data"});'), {"dummy":"data"
}); | 355 deepEqual(base.parseJSONP('ADD_RESULTS({"dummy":"data"});'), {"dummy":"data"
}); |
| 411 deepEqual(base.parseJSONP('{"dummy":"data"}'), {"dummy":"data"}); | 356 deepEqual(base.parseJSONP('{"dummy":"data"}'), {"dummy":"data"}); |
| 412 deepEqual(base.parseJSONP('ADD_RESULTS({"builder(1)":"data"});'), {"builder(
1)":"data"}); | 357 deepEqual(base.parseJSONP('ADD_RESULTS({"builder(1)":"data"});'), {"builder(
1)":"data"}); |
| 413 deepEqual(base.parseJSONP('{"builder(1)":"data"}'), {"builder(1)":"data"}); | 358 deepEqual(base.parseJSONP('{"builder(1)":"data"}'), {"builder(1)":"data"}); |
| 414 }); | 359 }); |
| 415 | 360 |
| 416 })(); | 361 })(); |
| OLD | NEW |