Skip to content

Commit

Permalink
Remove "Promise" from name of Ably*Promise helpers
Browse files Browse the repository at this point in the history
Thus replacing the (unused as of 6fe4914) callback versions.
  • Loading branch information
lawrence-forooghian committed Jun 22, 2023
1 parent cad6569 commit 49c4d92
Show file tree
Hide file tree
Showing 35 changed files with 368 additions and 389 deletions.
32 changes: 16 additions & 16 deletions test/browser/connection.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
});

it('device_going_offline_causes_disconnected_state', function (done) {
var realtime = helper.AblyRealtimePromise(),
var realtime = helper.AblyRealtime(),
connection = realtime.connection,
offlineEvent = new Event('offline', { bubbles: true });

Expand Down Expand Up @@ -94,7 +94,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {

it('device_going_online_causes_disconnected_connection_to_reconnect_immediately', function (done) {
/* Give up trying to connect fairly quickly */
var realtime = helper.AblyRealtimePromise({ realtimeRequestTimeout: 1000 }),
var realtime = helper.AblyRealtime({ realtimeRequestTimeout: 1000 }),
connection = realtime.connection,
onlineEvent = new Event('online', { bubbles: true });

Expand Down Expand Up @@ -139,7 +139,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {

it('device_going_online_causes_suspended_connection_to_reconnect_immediately', function (done) {
/* move to suspended state after 2s of being disconnected */
var realtime = helper.AblyRealtimePromise({
var realtime = helper.AblyRealtime({
disconnectedRetryTimeout: 500,
realtimeRequestTimeout: 500,
connectionStateTtl: 2000,
Expand Down Expand Up @@ -183,7 +183,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
});

it('device_going_online_causes_connecting_connection_to_retry_attempt', function (done) {
var realtime = helper.AblyRealtimePromise({}),
var realtime = helper.AblyRealtime({}),
connection = realtime.connection,
onlineEvent = new Event('online', { bubbles: true }),
oldTransport,
Expand Down Expand Up @@ -223,7 +223,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
cb(true);
},
},
realtime = helper.AblyRealtimePromise(realtimeOpts),
realtime = helper.AblyRealtime(realtimeOpts),
refreshEvent = new Event('beforeunload', { bubbles: true });

monitorConnection(done, realtime);
Expand All @@ -242,7 +242,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
return;
}

var newRealtime = helper.AblyRealtimePromise(realtimeOpts);
var newRealtime = helper.AblyRealtime(realtimeOpts);
newRealtime.connection.once('connected', function () {
try {
expect(
Expand All @@ -264,7 +264,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
cb(false);
},
};
var realtime = helper.AblyRealtimePromise(realtimeOpts),
var realtime = helper.AblyRealtime(realtimeOpts),
refreshEvent = new Event('beforeunload', { bubbles: true });

monitorConnection(done, realtime);
Expand All @@ -283,7 +283,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
return;
}

var newRealtime = helper.AblyRealtimePromise(realtimeOpts);
var newRealtime = helper.AblyRealtime(realtimeOpts);
newRealtime.connection.once('connected', function () {
try {
expect(
Expand All @@ -301,7 +301,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
});

it('page_refresh_with_close_on_unload', function (done) {
var realtime = helper.AblyRealtimePromise({ closeOnUnload: true }),
var realtime = helper.AblyRealtime({ closeOnUnload: true }),
refreshEvent = new Event('beforeunload', { bubbles: true });

monitorConnection(done, realtime);
Expand All @@ -321,7 +321,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
});

it('page_refresh_with_manual_recovery', function (done) {
var realtime = helper.AblyRealtimePromise({ closeOnUnload: false }),
var realtime = helper.AblyRealtime({ closeOnUnload: false }),
refreshEvent = new Event('beforeunload', { bubbles: true });

monitorConnection(done, realtime);
Expand All @@ -342,7 +342,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
return;
}

var newRealtime = helper.AblyRealtimePromise({ recover: recoveryKey });
var newRealtime = helper.AblyRealtime({ recover: recoveryKey });
newRealtime.connection.once('connected', function () {
try {
expect(
Expand All @@ -359,7 +359,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
});

it('persist_preferred_transport', function (done) {
var realtime = helper.AblyRealtimePromise();
var realtime = helper.AblyRealtime();

realtime.connection.connectionManager.on(function (transport) {
if (this.event === 'transport.active' && transport.shortName === 'web_socket') {
Expand All @@ -381,7 +381,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
var transportPreferenceName = 'ably-transport-preference';
window.localStorage.setItem(transportPreferenceName, JSON.stringify({ value: 'web_socket' }));

var realtime = helper.AblyRealtimePromise();
var realtime = helper.AblyRealtime();

realtime.connection.connectionManager.on(function (transport) {
if (this.event === 'transport.active') {
Expand All @@ -400,7 +400,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
it('use_persisted_transport1', function (done) {
window.localStorage.setItem(transportPreferenceName, JSON.stringify({ value: 'xhr_streaming' }));

var realtime = helper.AblyRealtimePromise();
var realtime = helper.AblyRealtime();

realtime.connection.connectionManager.on(function (transport) {
if (this.event === 'transport.active') {
Expand All @@ -417,7 +417,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
});

it('browser_transports', function (done) {
var realtime = helper.AblyRealtimePromise();
var realtime = helper.AblyRealtime();
try {
expect(realtime.connection.connectionManager.baseTransport).to.equal('xhr_polling');
expect(realtime.connection.connectionManager.upgradeTransports).to.deep.equal([
Expand All @@ -437,7 +437,7 @@ define(['shared_helper', 'chai'], function (helper, chai) {
* realtime)
*/
it('connection behaviour with a proxy through which streaming is broken', function (done) {
const realtime = helper.AblyRealtimePromise({
const realtime = helper.AblyRealtime({
transportParams: {
simulateNoStreamingProxy: true,
maxStreamDuration: 7500,
Expand Down
2 changes: 1 addition & 1 deletion test/browser/http.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) {
initialXhrSupported = Ably.Rest.Platform.Config.xhrSupported;
Ably.Rest.Platform.Config.xhrSupported = false;
helper.setupApp(function () {
rest = helper.AblyRestPromise();
rest = helper.AblyRest();
done();
});
});
Expand Down
2 changes: 1 addition & 1 deletion test/browser/simple.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ define(['ably', 'shared_helper', 'chai'], function (Ably, helper, chai) {
function realtimeConnection(transports) {
var options = {};
if (transports) options.transports = transports;
return helper.AblyRealtimePromise(options);
return helper.AblyRealtime(options);
}

function failWithin(timeInSeconds, done, ably, description) {
Expand Down
10 changes: 0 additions & 10 deletions test/common/modules/client_module.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,16 @@ define(['ably', 'globals', 'test/common/modules/testapp_module'], function (Ably
}

function ablyRest(options) {
return new Ably.Rest(ablyClientOptions(options));
}

function ablyRestPromise(options) {
return new Ably.Rest.Promise(ablyClientOptions(options));
}

function ablyRealtime(options) {
return new Ably.Realtime(ablyClientOptions(options));
}

function ablyRealtimePromise(options) {
return new Ably.Realtime.Promise(ablyClientOptions(options));
}

return (module.exports = {
Ably: Ably,
AblyRest: ablyRest,
AblyRestPromise: ablyRestPromise,
AblyRealtime: ablyRealtime,
AblyRealtimePromise: ablyRealtimePromise,
});
});
6 changes: 2 additions & 4 deletions test/common/modules/shared_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ define([
function restTestOnJsonMsgpack(name, testFn, skip) {
var itFn = skip ? it.skip : it;
itFn(name + ' with binary protocol', async function () {
await testFn(new clientModule.AblyRestPromise({ useBinaryProtocol: true }), name + '_binary');
await testFn(new clientModule.AblyRest({ useBinaryProtocol: true }), name + '_binary');
});
itFn(name + ' with text protocol', async function () {
await testFn(new clientModule.AblyRestPromise({ useBinaryProtocol: false }), name + '_text');
await testFn(new clientModule.AblyRest({ useBinaryProtocol: false }), name + '_text');
});
}

Expand Down Expand Up @@ -226,9 +226,7 @@ define([

Ably: clientModule.Ably,
AblyRest: clientModule.AblyRest,
AblyRestPromise: clientModule.AblyRestPromise,
AblyRealtime: clientModule.AblyRealtime,
AblyRealtimePromise: clientModule.AblyRealtimePromise,
Utils: utils,

loadTestData: testAppManager.loadJsonData,
Expand Down
Loading

0 comments on commit 49c4d92

Please sign in to comment.