THRIFT-4625: Use let/const variable decorators in ES6 Javascript
diff --git a/lib/js/test/test-jq.js b/lib/js/test/test-jq.js
index d8649a0..f62bb95 100644
--- a/lib/js/test/test-jq.js
+++ b/lib/js/test/test-jq.js
@@ -33,19 +33,18 @@
//////////////////////////////////
//jQuery asynchronous tests
jQuery.ajaxSetup({ timeout: 0 });
-$(document).ajaxError(function() { QUnit.start(); });
-module('jQ Async Manual');
+QUnit.module('jQ Async Manual');
- test('testI32', function() {
- expect(2);
- QUnit.stop();
+ QUnit.test('testI32', function(assert) {
+ assert.expect(2);
+ const done = assert.async(2);
- var transport = new Thrift.Transport();
- var protocol = new Thrift.Protocol(transport);
- var client = new ThriftTest.ThriftTestClient(protocol);
+ const transport = new Thrift.Transport();
+ const protocol = new Thrift.Protocol(transport);
+ const client = new ThriftTest.ThriftTestClient(protocol);
- var jqxhr = jQuery.ajax({
+ const jqxhr = jQuery.ajax({
url: '/service',
data: client.send_testI32(Math.pow(-2, 31)),
type: 'POST',
@@ -53,23 +52,24 @@
dataType: 'text',
success: function(res) {
transport.setRecvBuffer(res);
- equal(client.recv_testI32(), Math.pow(-2, 31));
+ assert.equal(client.recv_testI32(), Math.pow(-2, 31));
+ done();
},
- error: function() { ok(false); },
+ error: function() { assert.ok(false); },
complete: function() {
- ok(true);
- QUnit.start();
+ assert.ok(true);
+ done();
}
});
});
- test('testI64', function() {
- expect(2);
- QUnit.stop();
+ QUnit.test('testI64', function(assert) {
+ assert.expect(2);
+ const done = assert.async(2);
- var transport = new Thrift.Transport();
- var protocol = new Thrift.Protocol(transport);
- var client = new ThriftTest.ThriftTestClient(protocol);
+ const transport = new Thrift.Transport();
+ const protocol = new Thrift.Protocol(transport);
+ const client = new ThriftTest.ThriftTestClient(protocol);
jQuery.ajax({
url: '/service',
@@ -81,78 +81,79 @@
success: function(res) {
transport.setRecvBuffer(res);
//This is usually 2^61 but JS cannot represent anything over 2^52 accurately
- equal(client.recv_testI64(), Math.pow(-2, 52));
+ assert.equal(client.recv_testI64(), Math.pow(-2, 52));
+ done();
},
- error: function() { ok(false); },
+ error: function() { assert.ok(false); },
complete: function() {
- ok(true);
- QUnit.start();
+ assert.ok(true);
+ done();
}
});
});
-module('jQ Async');
- test('I32', function() {
- expect(3);
+QUnit.module('jQ Async');
+ QUnit.test('I32', function(assert) {
+ assert.expect(3);
- QUnit.stop();
+ const done = assert.async(3);
client.testI32(Math.pow(2, 30), function(result) {
- equal(result, Math.pow(2, 30));
- QUnit.start();
+ assert.equal(result, Math.pow(2, 30));
+ done();
});
- QUnit.stop();
- var jqxhr = client.testI32(Math.pow(-2, 31), function(result) {
- equal(result, Math.pow(-2, 31));
+ const jqxhr = client.testI32(Math.pow(-2, 31), function(result) {
+ assert.equal(result, Math.pow(-2, 31));
+ done();
});
jqxhr.success(function(result) {
- equal(result, Math.pow(-2, 31));
- QUnit.start();
+ assert.equal(result, Math.pow(-2, 31));
+ done();
});
});
- test('I64', function() {
- expect(4);
+ QUnit.test('I64', function(assert) {
+ assert.expect(4);
- QUnit.stop();
+ const done = assert.async(4);
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
client.testI64(Math.pow(2, 52), function(result) {
- equal(result, Math.pow(2, 52));
- QUnit.start();
+ assert.equal(result, Math.pow(2, 52));
+ done();
});
- QUnit.stop();
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
client.testI64(Math.pow(-2, 52), function(result) {
- equal(result, Math.pow(-2, 52));
+ assert.equal(result, Math.pow(-2, 52));
+ done();
})
- .error(function(xhr, status, e) { ok(false, e.message); })
+ .error(function(xhr, status, e) { assert.ok(false, e.message); })
.success(function(result) {
//This is usually 2^60 but JS cannot represent anything over 2^52 accurately
- equal(result, Math.pow(-2, 52));
+ assert.equal(result, Math.pow(-2, 52));
+ done();
})
.complete(function() {
- ok(true);
- QUnit.start();
+ assert.ok(true);
+ done();
});
});
- test('Xception', function() {
- expect(2);
+ QUnit.test('Xception', function(assert) {
+ assert.expect(2);
- QUnit.stop();
+ const done = assert.async(2);
- var dfd = client.testException('Xception', function(result) {
- ok(false);
- QUnit.start();
+ const dfd = client.testException('Xception', function(result) {
+ assert.ok(false);
+ done();
})
.error(function(xhr, status, e) {
- equal(e.errorCode, 1001);
- equal(e.message, 'Xception');
- //QUnit.start();
- //Note start is not required here because:
- //$(document).ajaxError( function() { QUnit.start(); } );
+ assert.equal(e.errorCode, 1001);
+ assert.equal(e.message, 'Xception');
+ done();
+ $(document).ajaxError( function() { done(); } );
});
});