Skip to content

Commit

Permalink
fix: Page JSON parsing and integration tests (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanholtz authored Mar 13, 2020
1 parent ef0d339 commit d073d8c
Show file tree
Hide file tree
Showing 330 changed files with 5,037 additions and 5,037 deletions.
2 changes: 1 addition & 1 deletion lib/base/Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ Page.prototype.processResponse = function(response) {
throw new RestException(response);
}

return JSON.parse(response.body);
return response.body;
};

/**
Expand Down
44 changes: 22 additions & 22 deletions spec/integration/rest/accounts/v1/credential/aws.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('Aws', function() {
});
it('should treat the first each arg as a callback',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -51,15 +51,15 @@ describe('Aws', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/AWS?PageSize=50&Page=0'
}
});
};
holodeck.mock(new Response(200, body));
client.accounts.v1.credentials
.aws.each(() => done());
}
);
it('should treat the second arg as a callback',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -79,7 +79,7 @@ describe('Aws', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/AWS?PageSize=50&Page=0'
}
});
};
holodeck.mock(new Response(200, body));
client.accounts.v1.credentials
.aws.each({pageSize: 20}, () => done());
Expand All @@ -92,7 +92,7 @@ describe('Aws', function() {
);
it('should find the callback in the opts object',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -112,15 +112,15 @@ describe('Aws', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/AWS?PageSize=50&Page=0'
}
});
};
holodeck.mock(new Response(200, body));
client.accounts.v1.credentials
.aws.each({callback: () => done()}, () => fail('wrong callback!'));
}
);
it('should generate valid list request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.aws.list();
Expand All @@ -141,7 +141,7 @@ describe('Aws', function() {
);
it('should generate valid read_empty response',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [],
'meta': {
'first_page_url': 'https://accounts.twilio.com/v1/Credentials/AWS?PageSize=50&Page=0',
Expand All @@ -152,7 +152,7 @@ describe('Aws', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/AWS?PageSize=50&Page=0'
}
});
};

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

Expand All @@ -168,7 +168,7 @@ describe('Aws', function() {
);
it('should generate valid read_full response',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -188,7 +188,7 @@ describe('Aws', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/AWS?PageSize=50&Page=0'
}
});
};

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

Expand All @@ -204,7 +204,7 @@ describe('Aws', function() {
);
it('should generate valid create request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var opts = {credentials: 'AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'};
var promise = client.accounts.v1.credentials
Expand All @@ -228,14 +228,14 @@ describe('Aws', function() {
);
it('should generate valid create response',
function(done) {
var body = JSON.stringify({
var body = {
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
'date_updated': '2015-07-31T04:00:00Z',
'friendly_name': 'friendly_name',
'sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'url': 'https://accounts.twilio.com/v1/Credentials/AWS/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
});
};

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

Expand All @@ -252,7 +252,7 @@ describe('Aws', function() {
);
it('should generate valid fetch request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch();
Expand All @@ -274,14 +274,14 @@ describe('Aws', function() {
);
it('should generate valid fetch response',
function(done) {
var body = JSON.stringify({
var body = {
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
'date_updated': '2015-07-31T04:00:00Z',
'friendly_name': 'friendly_name',
'sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'url': 'https://accounts.twilio.com/v1/Credentials/AWS/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
});
};

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

Expand All @@ -297,7 +297,7 @@ describe('Aws', function() {
);
it('should generate valid update request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update();
Expand All @@ -319,14 +319,14 @@ describe('Aws', function() {
);
it('should generate valid update response',
function(done) {
var body = JSON.stringify({
var body = {
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
'date_updated': '2015-07-31T04:00:00Z',
'friendly_name': 'friendly_name',
'sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'url': 'https://accounts.twilio.com/v1/Credentials/AWS/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
});
};

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

Expand All @@ -342,7 +342,7 @@ describe('Aws', function() {
);
it('should generate valid remove request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.aws('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();
Expand All @@ -364,7 +364,7 @@ describe('Aws', function() {
);
it('should generate valid delete response',
function(done) {
var body = JSON.stringify(null);
var body = null;

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

Expand Down
44 changes: 22 additions & 22 deletions spec/integration/rest/accounts/v1/credential/publicKey.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('PublicKey', function() {
});
it('should treat the first each arg as a callback',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -51,15 +51,15 @@ describe('PublicKey', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0'
}
});
};
holodeck.mock(new Response(200, body));
client.accounts.v1.credentials
.publicKey.each(() => done());
}
);
it('should treat the second arg as a callback',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -79,7 +79,7 @@ describe('PublicKey', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0'
}
});
};
holodeck.mock(new Response(200, body));
client.accounts.v1.credentials
.publicKey.each({pageSize: 20}, () => done());
Expand All @@ -92,7 +92,7 @@ describe('PublicKey', function() {
);
it('should find the callback in the opts object',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -112,15 +112,15 @@ describe('PublicKey', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0'
}
});
};
holodeck.mock(new Response(200, body));
client.accounts.v1.credentials
.publicKey.each({callback: () => done()}, () => fail('wrong callback!'));
}
);
it('should generate valid list request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.publicKey.list();
Expand All @@ -141,7 +141,7 @@ describe('PublicKey', function() {
);
it('should generate valid read_empty response',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [],
'meta': {
'first_page_url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0',
Expand All @@ -152,7 +152,7 @@ describe('PublicKey', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0'
}
});
};

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

Expand All @@ -168,7 +168,7 @@ describe('PublicKey', function() {
);
it('should generate valid read_full response',
function(done) {
var body = JSON.stringify({
var body = {
'credentials': [
{
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
Expand All @@ -188,7 +188,7 @@ describe('PublicKey', function() {
'previous_page_url': null,
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys?PageSize=50&Page=0'
}
});
};

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

Expand All @@ -204,7 +204,7 @@ describe('PublicKey', function() {
);
it('should generate valid create request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var opts = {publicKey: 'publickey'};
var promise = client.accounts.v1.credentials
Expand All @@ -228,14 +228,14 @@ describe('PublicKey', function() {
);
it('should generate valid create response',
function(done) {
var body = JSON.stringify({
var body = {
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
'date_updated': '2015-07-31T04:00:00Z',
'friendly_name': 'friendly_name',
'sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
});
};

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

Expand All @@ -252,7 +252,7 @@ describe('PublicKey', function() {
);
it('should generate valid fetch request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.publicKey('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').fetch();
Expand All @@ -274,14 +274,14 @@ describe('PublicKey', function() {
);
it('should generate valid fetch response',
function(done) {
var body = JSON.stringify({
var body = {
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
'date_updated': '2015-07-31T04:00:00Z',
'friendly_name': 'friendly_name',
'sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
});
};

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

Expand All @@ -297,7 +297,7 @@ describe('PublicKey', function() {
);
it('should generate valid update request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.publicKey('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').update();
Expand All @@ -319,14 +319,14 @@ describe('PublicKey', function() {
);
it('should generate valid update response',
function(done) {
var body = JSON.stringify({
var body = {
'account_sid': 'ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'date_created': '2015-07-31T04:00:00Z',
'date_updated': '2015-07-31T04:00:00Z',
'friendly_name': 'friendly_name',
'sid': 'CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
'url': 'https://accounts.twilio.com/v1/Credentials/PublicKeys/CRaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'
});
};

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

Expand All @@ -342,7 +342,7 @@ describe('PublicKey', function() {
);
it('should generate valid remove request',
function(done) {
holodeck.mock(new Response(500, '{}'));
holodeck.mock(new Response(500, {}));

var promise = client.accounts.v1.credentials
.publicKey('CRXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();
Expand All @@ -364,7 +364,7 @@ describe('PublicKey', function() {
);
it('should generate valid delete response',
function(done) {
var body = JSON.stringify(null);
var body = null;

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

Expand Down
Loading

0 comments on commit d073d8c

Please sign in to comment.