Skip to content

Commit

Permalink
fix(tests): delete arrow functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bnjjj committed May 27, 2016
1 parent 56574bc commit 7481598
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 36 deletions.
64 changes: 48 additions & 16 deletions tests/02_REST_check.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ exports.REST_check = {
});

rest.requestPromised('GET', '/deprecated/my-service/route')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.ok(err));
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.ok(err);
});
},
'Check call not found warning': function (done) {
'use strict';
Expand Down Expand Up @@ -150,8 +154,12 @@ exports.REST_check = {
});

rest.requestPromised('GET', '/auth/not-found')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.ok(err));
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.ok(err);
});
},
'Check api not found warning': function (done) {
'use strict';
Expand Down Expand Up @@ -206,8 +214,12 @@ exports.REST_check = {
});

rest.requestPromised('GET', '/auth')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.ok(err));
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.ok(err);
});
},
'Check HTTP method not found warning': function (done) {
'use strict';
Expand Down Expand Up @@ -260,8 +272,12 @@ exports.REST_check = {
});

rest.requestPromised('OVH', '/me')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.ok(err));
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.ok(err);
});
},
'Call method without CK': function (done) {
'use strict';
Expand Down Expand Up @@ -314,8 +330,12 @@ exports.REST_check = {
});

rest.requestPromised('GET', '/me')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.ok(err));
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.ok(err);
});
},
'Unable to load schema': function (done) {
'use strict';
Expand Down Expand Up @@ -357,8 +377,12 @@ exports.REST_check = {
});

rest.requestPromised('GET', '/me')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.equal(err.error, '[OVH] Unable to load schema /1.0/meh.json, HTTP response code: 404'))
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.equal(err.error, '[OVH] Unable to load schema /1.0/meh.json, HTTP response code: 404');
})
.finally(done);
},
'Unable to parse schema': function (done) {
Expand Down Expand Up @@ -401,8 +425,12 @@ exports.REST_check = {
});

rest.requestPromised('GET', '/me')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.equal(err.error, '[OVH] Unable to parse the schema: /1.0/me.json'))
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.equal(err.error, '[OVH] Unable to parse the schema: /1.0/me.json');
})
.finally(done);
},
'Unable to fetch time': function (done) {
Expand Down Expand Up @@ -439,8 +467,12 @@ exports.REST_check = {
});

rest.requestPromised('GET', '/me')
.then((resp) => assert.ok(!resp))
.catch((err) => assert.equal(err.error, '[OVH] Unable to fetch OVH API time'))
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.equal(err.error, '[OVH] Unable to fetch OVH API time');
})
.finally(done);
}
};
16 changes: 12 additions & 4 deletions tests/03_REST_auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ exports.REST_call = {
});

rest.requestPromised('GET', '/auth/time', {})
.then((result) => assert.ok(typeof(result) === 'number'))
.catch((err) => assert.ok(!err))
.then(function (result) {
assert.ok(typeof(result) === 'number');
})
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
},
'GET /auth/credential - ovh.request()': function (done) {
Expand Down Expand Up @@ -127,8 +131,12 @@ exports.REST_call = {
],
'redirection': 'https://npmjs.org/package/ovh'
})
.then((credential) => assert.ok(credential && credential.state === 'pendingValidation'))
.catch((err) => assert.ok(!err))
.then(function (credential) {
assert.ok(credential && credential.state === 'pendingValidation');
})
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
}
};
Expand Down
36 changes: 26 additions & 10 deletions tests/04_REST_me.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ exports.REST_me = {
rest.requestPromised('PUT', '/me', {
'city': 'Roubaix Valley'
})
.catch((err) => assert.ok(!err))
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
},
'PUT /me - ovh.request() - 403 [promised]': function (done) {
Expand All @@ -106,8 +108,10 @@ exports.REST_me = {
rest.requestPromised('PUT', '/me', {
'city': 'Roubaix Valley'
})
.then((resp) => assert.ok(!resp))
.catch((err) => {
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.equal(err.error, 403);
assert.equal(err.message, 'This credential is not valid');
})
Expand Down Expand Up @@ -153,7 +157,9 @@ exports.REST_me = {
rest.requestPromised('GET', '/me/agreements/{id}', {
'id': 42
})
.catch((err) => assert.ok(!err))
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
},
'GET /me/agreements - Filtering': function (done) {
Expand Down Expand Up @@ -207,8 +213,12 @@ exports.REST_me = {
rest.requestPromised('GET', '/me/agreement', {
'agreed': 'ok'
})
.then((agreements) => assert.equal(agreements.length, 0))
.catch((err) => assert.ok(!err))
.then(function (agreements) {
assert.equal(agreements.length, 0);
})
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
},
'PUT /me - Remove undefined': function (done) {
Expand Down Expand Up @@ -262,8 +272,10 @@ exports.REST_me = {
'city': 'Roubaix Valley',
'firstname': undefined
})
.then((resp) => assert.ok(!resp))
.catch((err) => {
.then(function (resp) {
assert.ok(!resp);
})
.catch(function (err) {
assert.equal(err.error, 403);
assert.equal(err.message, 'This credential is not valid');
})
Expand Down Expand Up @@ -306,8 +318,12 @@ exports.REST_me = {
});

rest.requestPromised('DELETE', '/todelete')
.then((resp) => assert.equal(resp, null))
.catch((err) => assert.ok(!err))
.then(function (resp) {
assert.equal(resp, null);
})
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
}
};
Expand Down
4 changes: 3 additions & 1 deletion tests/05_REST_unicode.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ exports.REST_sms = {

var rest = ovh(apiKeys);
rest.requestPromised('POST', '/sms/foo/jobs', {'message': 'tèsté'})
.catch((err) => assert.ok(!err))
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
}
};
4 changes: 3 additions & 1 deletion tests/integration/01_REST_noAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ exports.REST_call = {
rest.requestPromised('POST', '/newAccount', {
email: 'h@ovh.fr',
})
.then((result) => assert.ok(result.indexOf('Missing') > -1))
.then(function (result) {
assert.ok(result.indexOf('Missing') > -1);
})
.finally(done);
}
};
8 changes: 6 additions & 2 deletions tests/integration/02_REST_domain.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,12 @@ exports.REST_domain = {

var rest = ovh(apiKeys);
rest.requestPromised('GET', '/domain/zone')
.then((zones) => assert.ok(zones.length >= 1))
.catch((err) => assert.ok(!err))
.then(function (zones) {
assert.ok(zones.length >= 1);
})
.catch(function (err) {
assert.ok(!err);
})
.finally(done);
}
};
8 changes: 6 additions & 2 deletions tests/integration/03_REST_unicode.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,12 @@ exports.REST_sms = {

var rest = ovh(apiKeys);
rest.request('POST', '/sms/foo/jobs', {'message': 'tèsté'})
.then((msg) => assert.ok(!msg))
.catch((err) => assert.equal(err.error, 401))
.then(function (msg) {
assert.ok(!msg);
})
.catch(function (err) {
assert.equal(err.error, 401);
})
.finally(done);
}
};

0 comments on commit 7481598

Please sign in to comment.