Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Node promise-based tests to use the jasmine 'done' callback #468

Merged
merged 1 commit into from
Aug 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
94 changes: 44 additions & 50 deletions spec/integration/rest/accounts/v1/credential/aws.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,17 @@ describe('Aws', function() {
}
);
it('should generate valid list request',
function() {
function(done) {
holodeck.mock(new Response(500, '{}'));

var promise = client.accounts.v1.credentials
.aws.list();
promise = promise.then(function() {
promise.then(function() {
throw new Error('failed');
}, function(error) {
expect(error.constructor).toBe(RestException.prototype.constructor);
});
promise.done();
done();
}).done();

var url = 'https://accounts.twilio.com/v1/Credentials/AWS';

Expand All @@ -140,7 +140,7 @@ describe('Aws', function() {
}
);
it('should generate valid read_empty response',
function() {
function(done) {
var body = JSON.stringify({
'credentials': [],
'meta': {
Expand All @@ -158,17 +158,16 @@ describe('Aws', function() {

var promise = client.accounts.v1.credentials
.aws.list();
promise = promise.then(function(response) {
promise.then(function(response) {
expect(response).toBeDefined();
done();
}, function() {
throw new Error('failed');
});

promise.done();
}).done();
}
);
it('should generate valid read_full response',
function() {
function(done) {
var body = JSON.stringify({
'credentials': [
{
Expand All @@ -195,28 +194,27 @@ describe('Aws', function() {

var promise = client.accounts.v1.credentials
.aws.list();
promise = promise.then(function(response) {
promise.then(function(response) {
expect(response).toBeDefined();
done();
}, function() {
throw new Error('failed');
});

promise.done();
}).done();
}
);
it('should generate valid create request',
function() {
function(done) {
holodeck.mock(new Response(500, '{}'));

var opts = {credentials: 'AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'};
var promise = client.accounts.v1.credentials
.aws.create(opts);
promise = promise.then(function() {
promise.then(function() {
throw new Error('failed');
}, function(error) {
expect(error.constructor).toBe(RestException.prototype.constructor);
});
promise.done();
done();
}).done();

var url = 'https://accounts.twilio.com/v1/Credentials/AWS';

Expand All @@ -229,7 +227,7 @@ describe('Aws', function() {
}
);
it('should generate valid create response',
function() {
function(done) {
var body = JSON.stringify({
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
Expand All @@ -244,27 +242,26 @@ describe('Aws', function() {
var opts = {credentials: 'AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'};
var promise = client.accounts.v1.credentials
.aws.create(opts);
promise = promise.then(function(response) {
promise.then(function(response) {
expect(response).toBeDefined();
done();
}, function() {
throw new Error('failed');
});

promise.done();
}).done();
}
);
it('should generate valid fetch request',
function() {
function(done) {
holodeck.mock(new Response(500, '{}'));

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch();
promise = promise.then(function() {
promise.then(function() {
throw new Error('failed');
}, function(error) {
expect(error.constructor).toBe(RestException.prototype.constructor);
});
promise.done();
done();
}).done();

var sid = 'CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var url = `https://accounts.twilio.com/v1/Credentials/AWS/${sid}`;
Expand All @@ -276,7 +273,7 @@ describe('Aws', function() {
}
);
it('should generate valid fetch response',
function() {
function(done) {
var body = JSON.stringify({
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
Expand All @@ -290,27 +287,26 @@ describe('Aws', function() {

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch();
promise = promise.then(function(response) {
promise.then(function(response) {
expect(response).toBeDefined();
done();
}, function() {
throw new Error('failed');
});

promise.done();
}).done();
}
);
it('should generate valid update request',
function() {
function(done) {
holodeck.mock(new Response(500, '{}'));

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update();
promise = promise.then(function() {
promise.then(function() {
throw new Error('failed');
}, function(error) {
expect(error.constructor).toBe(RestException.prototype.constructor);
});
promise.done();
done();
}).done();

var sid = 'CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var url = `https://accounts.twilio.com/v1/Credentials/AWS/${sid}`;
Expand All @@ -322,7 +318,7 @@ describe('Aws', function() {
}
);
it('should generate valid update response',
function() {
function(done) {
var body = JSON.stringify({
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
Expand All @@ -336,27 +332,26 @@ describe('Aws', function() {

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update();
promise = promise.then(function(response) {
promise.then(function(response) {
expect(response).toBeDefined();
done();
}, function() {
throw new Error('failed');
});

promise.done();
}).done();
}
);
it('should generate valid remove request',
function() {
function(done) {
holodeck.mock(new Response(500, '{}'));

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();
promise = promise.then(function() {
promise.then(function() {
throw new Error('failed');
}, function(error) {
expect(error.constructor).toBe(RestException.prototype.constructor);
});
promise.done();
done();
}).done();

var sid = 'CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX';
var url = `https://accounts.twilio.com/v1/Credentials/AWS/${sid}`;
Expand All @@ -368,20 +363,19 @@ describe('Aws', function() {
}
);
it('should generate valid delete response',
function() {
function(done) {
var body = JSON.stringify(null);

holodeck.mock(new Response(204, body));

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();
promise = promise.then(function(response) {
promise.then(function(response) {
expect(response).toBe(true);
done();
}, function() {
throw new Error('failed');
});

promise.done();
}).done();
}
);
});
Loading