From 08e4905237ea6eb7b4e6d049969edf0e9048b102 Mon Sep 17 00:00:00 2001 From: Alex Rattray Date: Fri, 3 May 2019 20:04:03 -0700 Subject: [PATCH] lebab transform: arrow --- examples/webhook-signing/express.js | 2 +- lib/Error.js | 2 +- lib/StripeMethod.basic.js | 117 +++--- lib/StripeResource.js | 31 +- lib/Webhooks.js | 2 +- lib/autoPagination.js | 22 +- lib/makeRequest.js | 8 +- lib/resources/Files.js | 8 +- lib/stripe.js | 6 +- lib/utils.js | 46 +-- test/Error.spec.js | 14 +- test/StripeResource.spec.js | 140 ++++--- test/Webhook.spec.js | 46 +-- test/autoPagination.spec.js | 355 +++++++--------- test/flows.spec.js | 379 ++++++++---------- test/resources/Account.spec.js | 96 ++--- test/resources/AccountLinks.spec.js | 6 +- test/resources/ApplePayDomains.spec.js | 18 +- test/resources/ApplicationFeeRefunds.spec.js | 14 +- test/resources/ApplicationFees.spec.js | 20 +- test/resources/Balance.spec.js | 20 +- test/resources/BitcoinReceivers.spec.js | 14 +- test/resources/ChargeRefunds.spec.js | 18 +- test/resources/Charges.spec.js | 54 +-- test/resources/Checkout/Sessions.spec.js | 12 +- test/resources/CountrySpecs.spec.js | 10 +- test/resources/Coupons.spec.js | 22 +- test/resources/CreditNotes.spec.js | 22 +- test/resources/CustomerCards.spec.js | 22 +- test/resources/CustomerSubscriptions.spec.js | 28 +- test/resources/Customers.spec.js | 217 +++++----- test/resources/Disputes.spec.js | 18 +- test/resources/EphemeralKeys.spec.js | 28 +- test/resources/Events.spec.js | 10 +- test/resources/ExchangeRates.spec.js | 10 +- test/resources/FileLinks.spec.js | 18 +- test/resources/FileUploads.spec.js | 26 +- test/resources/Files.spec.js | 26 +- test/resources/InvoiceItems.spec.js | 22 +- test/resources/Invoices.spec.js | 72 ++-- test/resources/IssuerFraudRecords.spec.js | 10 +- test/resources/Issuing/Authorization.spec.js | 24 +- test/resources/Issuing/Cardholders.spec.js | 20 +- test/resources/Issuing/Cards.spec.js | 26 +- test/resources/Issuing/Disputes.spec.js | 20 +- test/resources/Issuing/Transactions.spec.js | 16 +- test/resources/LoginLinks.spec.js | 6 +- test/resources/OAuth.spec.js | 32 +- test/resources/OrderReturns.spec.js | 12 +- test/resources/Orders.spec.js | 28 +- test/resources/PaymentIntents.spec.js | 30 +- test/resources/PaymentMethods.spec.js | 26 +- test/resources/Payouts.spec.js | 26 +- test/resources/Persons.spec.js | 22 +- test/resources/Plans.spec.js | 28 +- test/resources/Products.spec.js | 24 +- test/resources/Radar/ValueListItems.spec.js | 20 +- test/resources/Radar/ValueLists.spec.js | 24 +- test/resources/RecipientCards.spec.js | 22 +- test/resources/Recipients.spec.js | 52 +-- test/resources/Refunds.spec.js | 18 +- test/resources/Reporting/ReportRuns.spec.js | 16 +- test/resources/Reporting/ReportTypes.spec.js | 12 +- test/resources/Reviews.spec.js | 14 +- test/resources/SKUs.spec.js | 24 +- .../Sigma/ScheduledQueryRuns.spec.js | 12 +- test/resources/Sources.spec.js | 22 +- test/resources/SubscriptionItems.spec.js | 22 +- test/resources/SubscriptionSchedule.spec.js | 36 +- .../SubscriptionScheduleRevision.spec.js | 10 +- test/resources/Subscriptions.spec.js | 44 +- test/resources/TaxIds.spec.js | 18 +- test/resources/TaxRates.spec.js | 18 +- .../Terminal/ConnectionTokens.spec.js | 8 +- test/resources/Terminal/Locations.spec.js | 24 +- test/resources/Terminal/Readers.spec.js | 24 +- test/resources/ThreeDSecure.spec.js | 10 +- test/resources/Tokens.spec.js | 10 +- test/resources/Topups.spec.js | 22 +- test/resources/TransferReversals.spec.js | 18 +- test/resources/Transfers.spec.js | 30 +- test/resources/UsageRecordSummaries.spec.js | 14 +- test/resources/UsageRecords.spec.js | 14 +- test/resources/WebhookEndpoints.spec.js | 22 +- test/stripe.spec.js | 138 ++++--- test/telemetry.spec.js | 49 +-- test/utils.spec.js | 116 +++--- testUtils/index.js | 6 +- 88 files changed, 1543 insertions(+), 1697 deletions(-) diff --git a/examples/webhook-signing/express.js b/examples/webhook-signing/express.js index f011e631ca..9317c86f7d 100644 --- a/examples/webhook-signing/express.js +++ b/examples/webhook-signing/express.js @@ -37,6 +37,6 @@ app.post( } ); -app.listen(3000, function() { +app.listen(3000, () => { console.log('Example app listening on port 3000!'); }); diff --git a/lib/Error.js b/lib/Error.js index cc7a0d18df..236f11e652 100644 --- a/lib/Error.js +++ b/lib/Error.js @@ -49,7 +49,7 @@ var StripeError = (_Error.StripeError = _Error.extend({ /** * Helper factory which takes raw stripe errors and outputs wrapping instances */ -StripeError.generate = function(rawStripeError) { +StripeError.generate = (rawStripeError) => { switch (rawStripeError.type) { case 'card_error': return new _Error.StripeCardError(rawStripeError); diff --git a/lib/StripeMethod.basic.js b/lib/StripeMethod.basic.js index cad47caaa5..370eab8cd9 100644 --- a/lib/StripeMethod.basic.js +++ b/lib/StripeMethod.basic.js @@ -54,57 +54,55 @@ module.exports = { var path = this.createFullPath('/' + id, urlData); return utils.callbackifyPromiseWithTimeout( - new Promise( - function(resolve, reject) { - if (isNull) { - // Reset metadata: - sendMetadata(null, auth); - } else if (!isObject) { - // Set individual metadata property: - var metadata = {}; - metadata[key] = value; - sendMetadata(metadata, auth); - } else { - // Set entire metadata object after resetting it: - this._request( - 'POST', - null, - path, - { - metadata: null, - }, - auth, - {}, - function(err, response) { - if (err) { - return reject(err); - } - sendMetadata(data, auth); + new Promise((resolve, reject) => { + if (isNull) { + // Reset metadata: + sendMetadata(null, auth); + } else if (!isObject) { + // Set individual metadata property: + var metadata = {}; + metadata[key] = value; + sendMetadata(metadata, auth); + } else { + // Set entire metadata object after resetting it: + this._request( + 'POST', + null, + path, + { + metadata: null, + }, + auth, + {}, + (err, response) => { + if (err) { + return reject(err); } - ); - } + sendMetadata(data, auth); + } + ); + } - function sendMetadata(metadata, auth) { - self._request( - 'POST', - null, - path, - { - metadata: metadata, - }, - auth, - {}, - function(err, response) { - if (err) { - reject(err); - } else { - resolve(response.metadata); - } + function sendMetadata(metadata, auth) { + self._request( + 'POST', + null, + path, + { + metadata: metadata, + }, + auth, + {}, + (err, response) => { + if (err) { + reject(err); + } else { + resolve(response.metadata); } - ); - } - }.bind(this) - ), + } + ); + } + }), cb ); }, @@ -119,20 +117,15 @@ module.exports = { var path = this.createFullPath('/' + id, urlData); return utils.callbackifyPromiseWithTimeout( - new Promise( - function(resolve, reject) { - this._request('GET', null, path, {}, auth, {}, function( - err, - response - ) { - if (err) { - reject(err); - } else { - resolve(response.metadata); - } - }); - }.bind(this) - ), + new Promise((resolve, reject) => { + this._request('GET', null, path, {}, auth, {}, (err, response) => { + if (err) { + reject(err); + } else { + resolve(response.metadata); + } + }); + }), cb ); }, diff --git a/lib/StripeResource.js b/lib/StripeResource.js index e6f39bdd18..e28ef195fb 100644 --- a/lib/StripeResource.js +++ b/lib/StripeResource.js @@ -98,7 +98,7 @@ StripeResource.prototype = { _timeoutHandler: function(timeout, req, callback) { var self = this; - return function() { + return () => { var timeoutErr = new Error('ETIMEDOUT'); timeoutErr.code = 'ETIMEDOUT'; @@ -119,14 +119,14 @@ StripeResource.prototype = { _responseHandler: function(req, callback) { var self = this; - return function(res) { + return (res) => { var response = ''; res.setEncoding('utf8'); - res.on('data', function(chunk) { + res.on('data', (chunk) => { response += chunk; }); - res.on('end', function() { + res.on('end', () => { var headers = res.headers || {}; // NOTE: Stripe responds with lowercase header names/keys. @@ -216,7 +216,7 @@ StripeResource.prototype = { _errorHandler: function(req, requestRetries, callback) { var self = this; - return function(error) { + return (error) => { if (req._isAborted) { // already handled return; @@ -349,7 +349,7 @@ StripeResource.prototype = { requestData = data; headers = self._defaultHeaders(auth, requestData.length, apiVersion); - self._stripe.getClientUserAgent(function(cua) { + self._stripe.getClientUserAgent((cua) => { headers['X-Stripe-Client-User-Agent'] = cua; if (options.headers) { @@ -429,7 +429,7 @@ StripeResource.prototype = { req.setTimeout(timeout, self._timeoutHandler(timeout, req, callback)); - req.on('response', function(res) { + req.on('response', (res) => { if (self._shouldRetry(res, requestRetries)) { return retryRequest(makeRequest, apiVersion, headers, requestRetries); } else { @@ -437,7 +437,7 @@ StripeResource.prototype = { } }); - req.on('error', function(error) { + req.on('error', (error) => { if (self._shouldRetry(null, requestRetries)) { return retryRequest(makeRequest, apiVersion, headers, requestRetries); } else { @@ -445,16 +445,13 @@ StripeResource.prototype = { } }); - req.on('socket', function(socket) { + req.on('socket', (socket) => { if (socket.connecting) { - socket.on( - isInsecureConnection ? 'connect' : 'secureConnect', - function() { - // Send payload; we're safe: - req.write(requestData); - req.end(); - } - ); + socket.on(isInsecureConnection ? 'connect' : 'secureConnect', () => { + // Send payload; we're safe: + req.write(requestData); + req.end(); + }); } else { // we're already connected req.write(requestData); diff --git a/lib/Webhooks.js b/lib/Webhooks.js index 2543761b87..1165b23c84 100644 --- a/lib/Webhooks.js +++ b/lib/Webhooks.js @@ -102,7 +102,7 @@ function parseHeader(header, scheme) { } return header.split(',').reduce( - function(accum, item) { + (accum, item) => { var kv = item.split('='); if (kv[0] === 't') { diff --git a/lib/autoPagination.js b/lib/autoPagination.js index f54d5504dd..3d9394d944 100644 --- a/lib/autoPagination.js +++ b/lib/autoPagination.js @@ -38,12 +38,12 @@ function makeAutoPaginationMethods(self, requestArgs, spec, firstPagePromise) { } function asyncIteratorNext() { - return memoizedPromise(promiseCache, function(resolve, reject) { - return listPromise + return memoizedPromise(promiseCache, (resolve, reject) => + listPromise .then(iterate) .then(resolve) - .catch(reject); - }); + .catch(reject) + ); } var autoPagingEach = makeAutoPagingEach(asyncIteratorNext); @@ -162,7 +162,7 @@ function memoizedPromise(promiseCache, cb) { if (promiseCache.currentPromise) { return promiseCache.currentPromise; } - promiseCache.currentPromise = new Promise(cb).then(function(ret) { + promiseCache.currentPromise = new Promise(cb).then((ret) => { promiseCache.currentPromise = undefined; return ret; }); @@ -199,15 +199,15 @@ function makeAutoPagingToArray(autoPagingEach) { 'You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.' ); } - var promise = new Promise(function(resolve, reject) { + var promise = new Promise((resolve, reject) => { var items = []; - autoPagingEach(function(item) { + autoPagingEach((item) => { items.push(item); if (items.length >= limit) { return false; } }) - .then(function() { + .then(() => { resolve(items); }) .catch(reject); @@ -217,7 +217,7 @@ function makeAutoPagingToArray(autoPagingEach) { } function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { function handleIteration(iterResult) { if (iterResult.done) { resolve(); @@ -225,12 +225,12 @@ function wrapAsyncIteratorWithCallback(asyncIteratorNext, onItem) { } var item = iterResult.value; - return new Promise(function(next) { + return new Promise((next) => { // Bit confusing, perhaps; we pass a `resolve` fn // to the user, so they can decide when and if to continue. // They can return false, or a promise which resolves to false, to break. onItem(item, next); - }).then(function(shouldContinue) { + }).then((shouldContinue) => { if (shouldContinue === false) { return handleIteration({done: true}); } else { diff --git a/lib/makeRequest.js b/lib/makeRequest.js index 1f5ea60664..163b9d4087 100644 --- a/lib/makeRequest.js +++ b/lib/makeRequest.js @@ -11,11 +11,7 @@ function getRequestOpts(self, requestArgs, spec, overrideData) { : utils.makeURLInterpolator(spec.path || ''); var requestMethod = (spec.method || 'GET').toUpperCase(); var urlParams = spec.urlParams || []; - var encode = - spec.encode || - function(data) { - return data; - }; + var encode = spec.encode || ((data) => data); var host = spec.host; // Don't mutate args externally. @@ -110,7 +106,7 @@ function getRequestOpts(self, requestArgs, spec, overrideData) { } function makeRequest(self, requestArgs, spec, overrideData) { - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { try { var opts = getRequestOpts(self, requestArgs, spec, overrideData); } catch (err) { diff --git a/lib/resources/Files.js b/lib/resources/Files.js index 4fd258fea4..7aac71c53a 100644 --- a/lib/resources/Files.js +++ b/lib/resources/Files.js @@ -30,16 +30,16 @@ module.exports = StripeResource.extend({ function streamProcessor(fn) { var bufferArray = []; data.file.data - .on('data', function(line) { + .on('data', (line) => { bufferArray.push(line); }) - .on('end', function() { + .on('end', () => { var bufferData = Object.assign({}, data); bufferData.file.data = Buffer.concat(bufferArray); var buffer = fn(method, bufferData, headers); callback(null, buffer); }) - .on('error', function(err) { + .on('error', (err) => { var errorHandler = streamError(callback); errorHandler(err); }); @@ -54,7 +54,7 @@ module.exports = StripeResource.extend({ this.detail = raw.detail; }, }); - return function(error) { + return (error) => { callback( new StreamProcessingError({ message: diff --git a/lib/stripe.js b/lib/stripe.js index 46ed677b63..1b418bdc33 100644 --- a/lib/stripe.js +++ b/lib/stripe.js @@ -216,7 +216,7 @@ Stripe.prototype = { info = info || {}; - var appInfo = APP_INFO_PROPERTIES.reduce(function(accum, prop) { + var appInfo = APP_INFO_PROPERTIES.reduce((accum, prop) => { if (typeof info[prop] == 'string') { accum = accum || {}; @@ -285,7 +285,7 @@ Stripe.prototype = { if (Stripe.USER_AGENT_SERIALIZED) { return cb(Stripe.USER_AGENT_SERIALIZED); } - this.getClientUserAgentSeeded(Stripe.USER_AGENT, function(cua) { + this.getClientUserAgentSeeded(Stripe.USER_AGENT, (cua) => { Stripe.USER_AGENT_SERIALIZED = cua; cb(Stripe.USER_AGENT_SERIALIZED); }); @@ -296,7 +296,7 @@ Stripe.prototype = { getClientUserAgentSeeded: function(seed, cb) { var self = this; - utils.safeExec('uname -a', function(err, uname) { + utils.safeExec('uname -a', (err, uname) => { var userAgent = {}; for (var field in seed) { userAgent[field] = encodeURIComponent(seed[field]); diff --git a/lib/utils.js b/lib/utils.js index 9cbfe9b918..0933253760 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -22,12 +22,7 @@ var utils = (module.exports = { }, isOptionsHash: function(o) { - return ( - isPlainObject(o) && - OPTIONS_KEYS.some(function(key) { - return hasOwn.call(o, key); - }) - ); + return isPlainObject(o) && OPTIONS_KEYS.some((key) => hasOwn.call(o, key)); }, /** @@ -56,7 +51,7 @@ var utils = (module.exports = { * var fn = makeURLInterpolator('some/url/{param1}/{param2}'); * fn({ param1: 123, param2: 456 }); // => 'some/url/123/456' */ - makeURLInterpolator: (function() { + makeURLInterpolator: (() => { var rc = { '\n': '\\n', '"': '\\"', @@ -64,14 +59,11 @@ var utils = (module.exports = { '\u2029': '\\u2029', }; return function makeURLInterpolator(str) { - var cleanString = str.replace(/["\n\r\u2028\u2029]/g, function($0) { - return rc[$0]; - }); - return function(outputs) { - return cleanString.replace(/\{([\s\S]+?)\}/g, function($0, $1) { - return encodeURIComponent(outputs[$1] || ''); - }); - }; + var cleanString = str.replace(/["\n\r\u2028\u2029]/g, ($0) => rc[$0]); + return (outputs) => + cleanString.replace(/\{([\s\S]+?)\}/g, ($0, $1) => + encodeURIComponent(outputs[$1] || '') + ); }; })(), @@ -89,9 +81,9 @@ var utils = (module.exports = { var argKeys = Object.keys(args[0]); - var optionKeysInArgs = argKeys.filter(function(key) { - return OPTIONS_KEYS.indexOf(key) > -1; - }); + var optionKeysInArgs = argKeys.filter( + (key) => OPTIONS_KEYS.indexOf(key) > -1 + ); // In some cases options may be the provided as the first argument. // Here we're detecting a case where there are two distinct arguments @@ -127,9 +119,9 @@ var utils = (module.exports = { } else if (utils.isOptionsHash(arg)) { var params = args.pop(); - var extraKeys = Object.keys(params).filter(function(key) { - return OPTIONS_KEYS.indexOf(key) == -1; - }); + var extraKeys = Object.keys(params).filter( + (key) => OPTIONS_KEYS.indexOf(key) == -1 + ); if (extraKeys.length) { emitWarning( @@ -213,7 +205,7 @@ var utils = (module.exports = { throw new Error('Argument must be an object'); } - Object.keys(obj).forEach(function(key) { + Object.keys(obj).forEach((key) => { if (obj[key] === null || obj[key] === undefined) { delete obj[key]; } @@ -237,13 +229,13 @@ var utils = (module.exports = { if (callback) { // Ensure callback is called outside of promise stack. return promise.then( - function(res) { - setTimeout(function() { + (res) => { + setTimeout(() => { callback(null, res); }, 0); }, - function(err) { - setTimeout(function() { + (err) => { + setTimeout(() => { callback(err, null); }, 0); } @@ -294,7 +286,7 @@ var utils = (module.exports = { var result = {}; function step(obj, prevKey) { - Object.keys(obj).forEach(function(key) { + Object.keys(obj).forEach((key) => { var value = obj[key]; var newKey = prevKey ? `${prevKey}[${key}]` : key; diff --git a/test/Error.spec.js b/test/Error.spec.js index 100618c7b0..fa44a132bd 100644 --- a/test/Error.spec.js +++ b/test/Error.spec.js @@ -5,16 +5,16 @@ require('../testUtils'); var Error = require('../lib/Error'); var expect = require('chai').expect; -describe('Error', function() { - it('Populates with type and message params', function() { +describe('Error', () => { + it('Populates with type and message params', () => { var e = new Error('FooError', 'Foo happened'); expect(e).to.have.property('type', 'FooError'); expect(e).to.have.property('message', 'Foo happened'); expect(e).to.have.property('stack'); }); - describe('StripeError', function() { - it('Generates specific instance depending on error-type', function() { + describe('StripeError', () => { + it('Generates specific instance depending on error-type', () => { expect(Error.StripeError.generate({type: 'card_error'})).to.be.instanceOf( Error.StripeCardError ); @@ -29,7 +29,7 @@ describe('Error', function() { ).to.be.instanceOf(Error.StripeIdempotencyError); }); - it('Pulls in headers', function() { + it('Pulls in headers', () => { var headers = {'Request-Id': '123'}; var e = Error.StripeError.generate({ type: 'card_error', @@ -38,7 +38,7 @@ describe('Error', function() { expect(e).to.have.property('headers', headers); }); - it('Pulls in request IDs', function() { + it('Pulls in request IDs', () => { var e = Error.StripeError.generate({ type: 'card_error', requestId: 'foo', @@ -46,7 +46,7 @@ describe('Error', function() { expect(e).to.have.property('requestId', 'foo'); }); - it('Pulls in HTTP status code', function() { + it('Pulls in HTTP status code', () => { var e = Error.StripeError.generate({type: 'card_error', statusCode: 400}); expect(e).to.have.property('statusCode', 400); }); diff --git a/test/StripeResource.spec.js b/test/StripeResource.spec.js index 9b30bbb779..48526e1b98 100644 --- a/test/StripeResource.spec.js +++ b/test/StripeResource.spec.js @@ -8,21 +8,21 @@ var nock = require('nock'); var stripe = require('../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('StripeResource', function() { - describe('createResourcePathWithSymbols', function() { - it('Generates a path', function() { +describe('StripeResource', () => { + describe('createResourcePathWithSymbols', () => { + it('Generates a path', () => { stripe.invoices.create({}); var path = stripe.invoices.createResourcePathWithSymbols('{id}'); expect(path).to.equal('/invoices/{id}'); }); }); - describe('_defaultHeaders', function() { - it('sets the Authorization header with Bearer auth using the global API key', function() { + describe('_defaultHeaders', () => { + it('sets the Authorization header with Bearer auth using the global API key', () => { var headers = stripe.invoices._defaultHeaders(null, 0, null); expect(headers.Authorization).to.equal('Bearer fakeAuthToken'); }); - it('sets the Authorization header with Bearer auth using the specified API key', function() { + it('sets the Authorization header with Bearer auth using the specified API key', () => { var headers = stripe.invoices._defaultHeaders( 'anotherFakeAuthToken', 0, @@ -30,26 +30,26 @@ describe('StripeResource', function() { ); expect(headers.Authorization).to.equal('Bearer anotherFakeAuthToken'); }); - it('sets the Stripe-Version header if an API version is provided', function() { + it('sets the Stripe-Version header if an API version is provided', () => { var headers = stripe.invoices._defaultHeaders(null, 0, '1970-01-01'); expect(headers['Stripe-Version']).to.equal('1970-01-01'); }); - it('does not the set the Stripe-Version header if no API version is provided', function() { + it('does not the set the Stripe-Version header if no API version is provided', () => { var headers = stripe.invoices._defaultHeaders(null, 0, null); expect(headers).to.not.include.keys('Stripe-Version'); }); }); - describe('Parameter encoding', function() { + describe('Parameter encoding', () => { // Use a real instance of stripe as we're mocking the http.request responses. var realStripe = require('../lib/stripe')(utils.getUserStripeKey()); - after(function() { + after(() => { nock.cleanAll(); }); - describe('_request', function() { - it('encodes the query string in GET requests', function(done) { + describe('_request', () => { + it('encodes the query string in GET requests', (done) => { var options = { host: stripe.getConstant('DEFAULT_HOST'), path: '/v1/invoices/upcoming', @@ -66,16 +66,17 @@ describe('StripeResource', function() { .query(Object.assign({customer: 'cus_123'}, options.data)) .reply(200, '{}'); - realStripe.invoices.retrieveUpcoming('cus_123', options.data, function( - err, - response - ) { - done(); - scope.done(); - }); + realStripe.invoices.retrieveUpcoming( + 'cus_123', + options.data, + (err, response) => { + done(); + scope.done(); + } + ); }); - it('encodes the body in POST requests', function(done) { + it('encodes the body in POST requests', (done) => { var options = { host: stripe.getConstant('DEFAULT_HOST'), path: '/v1/subscriptions/sub_123', @@ -91,25 +92,24 @@ describe('StripeResource', function() { .post(options.path, options.body) .reply(200, '{}'); - realStripe.subscriptions.update('sub_123', options.data, function( - err, - response - ) { - done(); - scope.done(); - }); + realStripe.subscriptions.update( + 'sub_123', + options.data, + (err, response) => { + done(); + scope.done(); + } + ); }); }); }); - describe('Retry Network Requests', function() { + describe('Retry Network Requests', () => { // Use a real instance of stripe as we're mocking the http.request responses. var realStripe = require('../lib/stripe')(utils.getUserStripeKey()); // Override the sleep timer to speed up tests - realStripe.charges._getSleepTimeInMS = function() { - return 0; - }; + realStripe.charges._getSleepTimeInMS = () => 0; var options = { host: stripe.getConstant('DEFAULT_HOST'), @@ -123,29 +123,29 @@ describe('StripeResource', function() { params: 'amount=1000¤cy=usd&source=tok_visa&description=test', }; - afterEach(function() { + afterEach(() => { realStripe.setMaxNetworkRetries(0); stripe.setMaxNetworkRetries(0); }); - after(function() { + after(() => { nock.cleanAll(); }); - describe('_request', function() { - it('throws an error on connection failure', function(done) { + describe('_request', () => { + it('throws an error on connection failure', (done) => { // Mock the connection error. nock('https://' + options.host) .post(options.path, options.params) .replyWithError('bad stuff'); - realStripe.charges.create(options.data, function(err) { + realStripe.charges.create(options.data, (err) => { expect(err.detail.message).to.deep.equal('bad stuff'); done(); }); }); - it('should retry the request if max retries are set', function(done) { + it('should retry the request if max retries are set', (done) => { nock('https://' + options.host) .post(options.path, options.params) .replyWithError('bad stuff') @@ -154,7 +154,7 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err) { + realStripe.charges.create(options.data, (err) => { var errorMessage = realStripe.invoices._generateConnectionErrorMessage( 1 ); @@ -164,7 +164,7 @@ describe('StripeResource', function() { }); }); - it('should stop retrying after a successful retry', function(done) { + it('should stop retrying after a successful retry', (done) => { nock('https://' + options.host) .post(options.path, options.params) .replyWithError('bad stuff') @@ -177,13 +177,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(2); - realStripe.charges.create(options.data, function(err, charge) { + realStripe.charges.create(options.data, (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should retry on a 409 error', function(done) { + it('should retry on a 409 error', (done) => { nock('https://' + options.host) .post(options.path, options.params) .reply(409, { @@ -200,13 +200,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err, charge) { + realStripe.charges.create(options.data, (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should not retry on a 400 error', function(done) { + it('should not retry on a 400 error', (done) => { nock('https://' + options.host) .post(options.path, options.params) .reply(400, { @@ -217,13 +217,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err) { + realStripe.charges.create(options.data, (err) => { expect(err.type).to.equal('StripeCardError'); done(); }); }); - it('should not retry on a 500 error when the method is POST', function(done) { + it('should not retry on a 500 error when the method is POST', (done) => { nock('https://' + options.host) .post(options.path, options.params) .reply(500, { @@ -234,13 +234,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err) { + realStripe.charges.create(options.data, (err) => { expect(err.type).to.equal('StripeAPIError'); done(); }); }); - it('should handle OAuth errors gracefully', function(done) { + it('should handle OAuth errors gracefully', (done) => { nock('https://connect.stripe.com') .post('/oauth/token') .reply(400, { @@ -251,13 +251,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.oauth.token(options.data, function(err) { + realStripe.oauth.token(options.data, (err) => { expect(err.type).to.equal('StripeInvalidGrantError'); done(); }); }); - it('should retry on a 503 error when the method is POST', function(done) { + it('should retry on a 503 error when the method is POST', (done) => { nock('https://' + options.host) .post(options.path, options.params) .reply(503, { @@ -274,13 +274,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function(err, charge) { + realStripe.charges.create(options.data, (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should retry on a 500 error when the method is GET', function(done) { + it('should retry on a 500 error when the method is GET', (done) => { nock('https://' + options.host) .get(options.path + '/ch_123') .reply(500, { @@ -297,13 +297,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.retrieve('ch_123', function(err, charge) { + realStripe.charges.retrieve('ch_123', (err, charge) => { expect(charge.id).to.equal('ch_123'); done(); }); }); - it('should add an idempotency key for retries using the POST method', function(done) { + it('should add an idempotency key for retries using the POST method', (done) => { var headers; // Fail the first request but succeed on the 2nd. @@ -326,13 +326,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create(options.data, function() { + realStripe.charges.create(options.data, () => { expect(headers).to.have.property('idempotency-key'); done(); }); }); - it('should not add idempotency key for retries using the GET method', function(done) { + it('should not add idempotency key for retries using the GET method', (done) => { var headers; nock('https://' + options.host) @@ -354,13 +354,13 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.retrieve('ch_123', function() { + realStripe.charges.retrieve('ch_123', () => { expect(headers).to.not.have.property('idempotency-key'); done(); }); }); - it('should reuse the given idempotency key provided for retries', function(done) { + it('should reuse the given idempotency key provided for retries', (done) => { var key = uuid(); var headers; @@ -383,19 +383,15 @@ describe('StripeResource', function() { realStripe.setMaxNetworkRetries(1); - realStripe.charges.create( - options.data, - {idempotency_key: key}, - function() { - expect(headers['idempotency-key']).to.equal(key); - done(); - } - ); + realStripe.charges.create(options.data, {idempotency_key: key}, () => { + expect(headers['idempotency-key']).to.equal(key); + done(); + }); }); }); - describe('_shouldRetry', function() { - it("should return false if we've reached maximum retries", function() { + describe('_shouldRetry', () => { + it("should return false if we've reached maximum retries", () => { stripe.setMaxNetworkRetries(1); var res = stripe.invoices._shouldRetry( { @@ -407,7 +403,7 @@ describe('StripeResource', function() { expect(res).to.equal(false); }); - it('should return true if we have more retries available', function() { + it('should return true if we have more retries available', () => { stripe.setMaxNetworkRetries(1); var res = stripe.invoices._shouldRetry( { @@ -419,7 +415,7 @@ describe('StripeResource', function() { expect(res).to.equal(true); }); - it('should return true if the error code is either 409 or 503', function() { + it('should return true if the error code is either 409 or 503', () => { stripe.setMaxNetworkRetries(1); var res = stripe.invoices._shouldRetry( { @@ -440,7 +436,7 @@ describe('StripeResource', function() { expect(res).to.equal(true); }); - it('should return false if the status is 200', function() { + it('should return false if the status is 200', () => { stripe.setMaxNetworkRetries(2); // mocking that we're on our 2nd request @@ -456,8 +452,8 @@ describe('StripeResource', function() { }); }); - describe('_getSleepTimeInMS', function() { - it('should not exceed the maximum or minimum values', function() { + describe('_getSleepTimeInMS', () => { + it('should not exceed the maximum or minimum values', () => { var sleepSeconds; var max = stripe.getMaxNetworkRetryDelay(); var min = stripe.getInitialNetworkRetryDelay(); diff --git a/test/Webhook.spec.js b/test/Webhook.spec.js index 2ba87061a9..f51c1ab549 100644 --- a/test/Webhook.spec.js +++ b/test/Webhook.spec.js @@ -12,9 +12,9 @@ var EVENT_PAYLOAD_STRING = JSON.stringify(EVENT_PAYLOAD, null, 2); var SECRET = 'whsec_test_secret'; -describe('Webhooks', function() { - describe('.constructEvent', function() { - it('should return an Event instance from a valid JSON payload and valid signature header', function() { +describe('Webhooks', () => { + describe('.constructEvent', () => { + it('should return an Event instance from a valid JSON payload and valid signature header', () => { var header = generateHeaderString({ payload: EVENT_PAYLOAD_STRING, }); @@ -28,11 +28,11 @@ describe('Webhooks', function() { expect(event.id).to.equal(EVENT_PAYLOAD.id); }); - it('should raise a JSON error from invalid JSON payload', function() { + it('should raise a JSON error from invalid JSON payload', () => { var header = generateHeaderString({ payload: '} I am not valid JSON; 123][', }); - expect(function() { + expect(() => { stripe.webhooks.constructEvent( '} I am not valid JSON; 123][', header, @@ -41,22 +41,22 @@ describe('Webhooks', function() { }).to.throw(/Unexpected token/); }); - it('should raise a SignatureVerificationError from a valid JSON payload and an invalid signature header', function() { + it('should raise a SignatureVerificationError from a valid JSON payload and an invalid signature header', () => { var header = 'bad_header'; - expect(function() { + expect(() => { stripe.webhooks.constructEvent(EVENT_PAYLOAD_STRING, header, SECRET); }).to.throw(/Unable to extract timestamp and signatures from header/); }); }); - describe('.verifySignatureHeader', function() { - it('should raise a SignatureVerificationError when the header does not have the expected format', function() { + describe('.verifySignatureHeader', () => { + it('should raise a SignatureVerificationError when the header does not have the expected format', () => { var header = "I'm not even a real signature header"; var expectedMessage = /Unable to extract timestamp and signatures from header/; - expect(function() { + expect(() => { stripe.webhooks.signature.verifyHeader( EVENT_PAYLOAD_STRING, header, @@ -64,7 +64,7 @@ describe('Webhooks', function() { ); }).to.throw(expectedMessage); - expect(function() { + expect(() => { stripe.webhooks.signature.verifyHeader( EVENT_PAYLOAD_STRING, null, @@ -72,7 +72,7 @@ describe('Webhooks', function() { ); }).to.throw(expectedMessage); - expect(function() { + expect(() => { stripe.webhooks.signature.verifyHeader( EVENT_PAYLOAD_STRING, undefined, @@ -80,7 +80,7 @@ describe('Webhooks', function() { ); }).to.throw(expectedMessage); - expect(function() { + expect(() => { stripe.webhooks.signature.verifyHeader( EVENT_PAYLOAD_STRING, '', @@ -89,12 +89,12 @@ describe('Webhooks', function() { }).to.throw(expectedMessage); }); - it('should raise a SignatureVerificationError when there are no signatures with the expected scheme', function() { + it('should raise a SignatureVerificationError when there are no signatures with the expected scheme', () => { var header = generateHeaderString({ scheme: 'v0', }); - expect(function() { + expect(() => { stripe.webhooks.signature.verifyHeader( EVENT_PAYLOAD_STRING, header, @@ -103,12 +103,12 @@ describe('Webhooks', function() { }).to.throw(/No signatures found with expected scheme/); }); - it('should raise a SignatureVerificationError when there are no valid signatures for the payload', function() { + it('should raise a SignatureVerificationError when there are no valid signatures for the payload', () => { var header = generateHeaderString({ signature: 'bad_signature', }); - expect(function() { + expect(() => { stripe.webhooks.signature.verifyHeader( EVENT_PAYLOAD_STRING, header, @@ -119,12 +119,12 @@ describe('Webhooks', function() { ); }); - it('should raise a SignatureVerificationError when the timestamp is not within the tolerance', function() { + it('should raise a SignatureVerificationError when the timestamp is not within the tolerance', () => { var header = generateHeaderString({ timestamp: Date.now() / 1000 - 15, }); - expect(function() { + expect(() => { stripe.webhooks.signature.verifyHeader( EVENT_PAYLOAD_STRING, header, @@ -137,7 +137,7 @@ describe('Webhooks', function() { it( 'should return true when the header contains a valid signature and ' + 'the timestamp is within the tolerance', - function() { + () => { var header = generateHeaderString({ timestamp: Date.now() / 1000, }); @@ -153,7 +153,7 @@ describe('Webhooks', function() { } ); - it('should return true when the header contains at least one valid signature', function() { + it('should return true when the header contains at least one valid signature', () => { var header = generateHeaderString({ timestamp: Date.now() / 1000, }); @@ -173,7 +173,7 @@ describe('Webhooks', function() { it( 'should return true when the header contains a valid signature ' + 'and the timestamp is off but no tolerance is provided', - function() { + () => { var header = generateHeaderString({ timestamp: 12345, }); @@ -188,7 +188,7 @@ describe('Webhooks', function() { } ); - it('should accept Buffer instances for the payload and header', function() { + it('should accept Buffer instances for the payload and header', () => { var header = generateHeaderString({ timestamp: Date.now() / 1000, }); diff --git a/test/autoPagination.spec.js b/test/autoPagination.spec.js index 8aa204b129..28ae934a0a 100644 --- a/test/autoPagination.spec.js +++ b/test/autoPagination.spec.js @@ -15,41 +15,37 @@ describe('auto pagination', function() { var email = 'test.' + Date.now() + '@example.com'; var realCustomerIds; - before(function() { - return new Promise(function(resolve) { - var createReqs = []; - for (var i = 0; i < TOTAL_OBJECTS; i++) { - createReqs.push(stripe.customers.create({email: email})); - } - return Promise.all(createReqs) - .then(function() { - // re-fetch to ensure correct order - return stripe.customers - .list({email: email}) - .then(function(customers) { - realCustomerIds = customers.data.map(function(customer) { - return customer.id; - }); - }); - }) - .then(resolve); - }); - }); - - after(function() { - return new Promise(function(resolve) { - Promise.all( - realCustomerIds.map(function(customerId) { - return stripe.customers.del(customerId); - }) - ).then(resolve); - }); - }); - - describe('callbacks', function() { - it('lets you call `next()` to iterate and `next(false)` to break', function() { - return expect( - new Promise(function(resolve, reject) { + before( + () => + new Promise((resolve) => { + var createReqs = []; + for (var i = 0; i < TOTAL_OBJECTS; i++) { + createReqs.push(stripe.customers.create({email: email})); + } + return Promise.all(createReqs) + .then(() => + // re-fetch to ensure correct order + stripe.customers.list({email: email}).then((customers) => { + realCustomerIds = customers.data.map((customer) => customer.id); + }) + ) + .then(resolve); + }) + ); + + after( + () => + new Promise((resolve) => { + Promise.all( + realCustomerIds.map((customerId) => stripe.customers.del(customerId)) + ).then(resolve); + }) + ); + + describe('callbacks', () => { + it('lets you call `next()` to iterate and `next(false)` to break', () => + expect( + new Promise((resolve, reject) => { var customerIds = []; function onCustomer(customer, next) { customerIds.push(customer.id); @@ -72,12 +68,11 @@ describe('auto pagination', function() { .list({limit: 3, email: email}) .autoPagingEach(onCustomer, onDone); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - it('lets you ignore the second arg and `return false` to break', function() { - return expect( - new Promise(function(resolve, reject) { + it('lets you ignore the second arg and `return false` to break', () => + expect( + new Promise((resolve, reject) => { var customerIds = []; function onCustomer(customer) { customerIds.push(customer.id); @@ -99,12 +94,11 @@ describe('auto pagination', function() { .list({limit: 3, email: email}) .autoPagingEach(onCustomer, onDone); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - it('lets you ignore the second arg and return a Promise which returns `false` to break', function() { - return expect( - new Promise(function(resolve, reject) { + it('lets you ignore the second arg and return a Promise which returns `false` to break', () => + expect( + new Promise((resolve, reject) => { var customerIds = []; function onCustomer(customer) { customerIds.push(customer.id); @@ -127,12 +121,11 @@ describe('auto pagination', function() { .list({limit: 3, email: email}) .autoPagingEach(onCustomer, onDone); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - it('can use a promise instead of a callback for onDone', function() { - return expect( - new Promise(function(resolve, reject) { + it('can use a promise instead of a callback for onDone', () => + expect( + new Promise((resolve, reject) => { var customerIds = []; function onCustomer(customer) { customerIds.push(customer.id); @@ -147,63 +140,59 @@ describe('auto pagination', function() { .then(onDone) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds); - }); + ).to.eventually.deep.equal(realCustomerIds)); - it('handles the end of a list properly when the last page is full', function() { - return expect( - new Promise(function(resolve, reject) { + it('handles the end of a list properly when the last page is full', () => + expect( + new Promise((resolve, reject) => { var customerIds = []; return stripe.customers .list({email: email, limit: TOTAL_OBJECTS / 2}) - .autoPagingEach(function(customer) { + .autoPagingEach((customer) => { customerIds.push(customer.id); }) .catch(reject) - .then(function() { + .then(() => { resolve(customerIds); }); }) - ).to.eventually.deep.equal(realCustomerIds); - }); + ).to.eventually.deep.equal(realCustomerIds)); - it('handles the end of a list properly when the last page is not full', function() { - return expect( - new Promise(function(resolve, reject) { + it('handles the end of a list properly when the last page is not full', () => + expect( + new Promise((resolve, reject) => { var customerIds = []; return stripe.customers .list({email: email, limit: TOTAL_OBJECTS - 2}) - .autoPagingEach(function(customer) { + .autoPagingEach((customer) => { customerIds.push(customer.id); }) .catch(reject) - .then(function() { + .then(() => { resolve(customerIds); }); }) - ).to.eventually.deep.equal(realCustomerIds); - }); + ).to.eventually.deep.equal(realCustomerIds)); - it('handles a list which is shorter than the page size properly', function() { - return expect( - new Promise(function(resolve, reject) { + it('handles a list which is shorter than the page size properly', () => + expect( + new Promise((resolve, reject) => { var customerIds = []; return stripe.customers .list({email: email, limit: TOTAL_OBJECTS + 2}) - .autoPagingEach(function(customer) { + .autoPagingEach((customer) => { customerIds.push(customer.id); }) .catch(reject) - .then(function() { + .then(() => { resolve(customerIds); }); }) - ).to.eventually.deep.equal(realCustomerIds); - }); + ).to.eventually.deep.equal(realCustomerIds)); - it('handles errors after the first page correctly (callback)', function() { - return expect( - new Promise(function(resolve, reject) { + it('handles errors after the first page correctly (callback)', () => + expect( + new Promise((resolve, reject) => { var i = 0; function onCustomer() { i += 1; @@ -213,7 +202,7 @@ describe('auto pagination', function() { } return stripe.customers .list({email: email, limit: 3}) - .autoPagingEach(onCustomer, function(err) { + .autoPagingEach(onCustomer, (err) => { if (err) { resolve(err.message); } else { @@ -221,12 +210,11 @@ describe('auto pagination', function() { } }); }) - ).to.eventually.deep.equal('Simulated error'); - }); + ).to.eventually.deep.equal('Simulated error')); - it('handles errors after the first page correctly (promise)', function() { - return expect( - new Promise(function(resolve, reject) { + it('handles errors after the first page correctly (promise)', () => + expect( + new Promise((resolve, reject) => { var i = 0; function onCustomer() { i += 1; @@ -237,86 +225,70 @@ describe('auto pagination', function() { return stripe.customers .list({email: email, limit: 3}) .autoPagingEach(onCustomer) - .then(function() { + .then(() => { reject(Error('Expected an error, did not get one.')); }) - .catch(function(err) { + .catch((err) => { resolve(err.message); }); }) - ).to.eventually.deep.equal('Simulated error'); - }); + ).to.eventually.deep.equal('Simulated error')); }); - describe('async iterators', function() { + describe('async iterators', () => { if (testUtils.envSupportsForAwait()) { // `for await` throws a syntax error everywhere but node 10, // so we must conditionally require it. var forAwaitUntil = require('../testUtils/forAwait.node10').forAwaitUntil; - it('works with `for await` when that feature exists (user break)', function() { - return expect( - new Promise(function(resolve, reject) { + it('works with `for await` when that feature exists (user break)', () => + expect( + new Promise((resolve, reject) => { forAwaitUntil( stripe.customers.list({limit: 3, email: email}), LIMIT ) - .then(function(customers) { - resolve( - customers.map(function(customer) { - return customer.id; - }) - ); + .then((customers) => { + resolve(customers.map((customer) => customer.id)); }) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - it('works with `for await` when that feature exists (end of list)', function() { - return expect( - new Promise(function(resolve, reject) { + it('works with `for await` when that feature exists (end of list)', () => + expect( + new Promise((resolve, reject) => { forAwaitUntil( stripe.customers.list({limit: 3, email: email}), TOTAL_OBJECTS + 1 ) - .then(function(customers) { - resolve( - customers.map(function(customer) { - return customer.id; - }) - ); + .then((customers) => { + resolve(customers.map((customer) => customer.id)); }) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds); - }); + ).to.eventually.deep.equal(realCustomerIds)); } if (testUtils.envSupportsAwait()) { // Similarly, `await` throws a syntax error below Node 7.6. var awaitUntil = require('../testUtils/await.node7').awaitUntil; - it('works with `await` and a while loop when await exists', function() { - return expect( - new Promise(function(resolve, reject) { + it('works with `await` and a while loop when await exists', () => + expect( + new Promise((resolve, reject) => { awaitUntil(stripe.customers.list({limit: 3, email: email}), LIMIT) - .then(function(customers) { - resolve( - customers.map(function(customer) { - return customer.id; - }) - ); + .then((customers) => { + resolve(customers.map((customer) => customer.id)); }) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); } - it('returns an empty object from .return() so that `break;` works in for-await', function() { - return expect( - new Promise(function(resolve, reject) { + it('returns an empty object from .return() so that `break;` works in for-await', () => + expect( + new Promise((resolve, reject) => { var iter = stripe.customers.list({limit: 3, email: email}); var customerIds = []; @@ -328,17 +300,16 @@ describe('auto pagination', function() { iter .next() .then(handleIter) - .then(function() { + .then(() => { resolve(customerIds); }) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, 1)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, 1))); - it('works when you call it sequentially', function() { - return expect( - new Promise(function(resolve, reject) { + it('works when you call it sequentially', () => + expect( + new Promise((resolve, reject) => { var iter = stripe.customers.list({limit: 3, email: email}); var customerIds = []; @@ -351,17 +322,16 @@ describe('auto pagination', function() { iter .next() .then(handleIter) - .then(function() { + .then(() => { resolve(customerIds); }) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - it('gives you the same result each time when you call it multiple times in parallel', function() { - return expect( - new Promise(function(resolve, reject) { + it('gives you the same result each time when you call it multiple times in parallel', () => + expect( + new Promise((resolve, reject) => { var iter = stripe.customers.list({limit: 3, email: email}); var customerIds = []; @@ -374,87 +344,72 @@ describe('auto pagination', function() { iter .next() .then(handleIter) - .then(function() { - return Promise.all([ + .then(() => + Promise.all([ iter.next().then(handleIter), iter.next().then(handleIter), - ]); - }) - .then(function() { - return Promise.all([ + ]) + ) + .then(() => + Promise.all([ iter.next().then(handleIter), iter.next().then(handleIter), - ]); - }) - .then(function() { - return Promise.all([ + ]) + ) + .then(() => + Promise.all([ iter.next().then(handleIter), iter.next().then(handleIter), - ]); - }), + ]) + ), ]) - .then(function() { + .then(() => { resolve(customerIds); }) .catch(reject); }) ).to.eventually.deep.equal( - realCustomerIds.slice(0, 4).reduce(function(acc, x) { + realCustomerIds.slice(0, 4).reduce((acc, x) => { acc.push(x); acc.push(x); return acc; }, []) - ); - }); + )); }); - describe('autoPagingToArray', function() { - it('can go to the end', function() { - return expect( - new Promise(function(resolve, reject) { + describe('autoPagingToArray', () => { + it('can go to the end', () => + expect( + new Promise((resolve, reject) => { stripe.customers .list({limit: 3, email: email}) .autoPagingToArray({limit: TOTAL_OBJECTS + 1}) - .then(function(customers) { - return customers.map(function(customer) { - return customer.id; - }); - }) + .then((customers) => customers.map((customer) => customer.id)) .then(resolve) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds); - }); + ).to.eventually.deep.equal(realCustomerIds)); - it('returns a promise of an array', function() { - return expect( - new Promise(function(resolve, reject) { + it('returns a promise of an array', () => + expect( + new Promise((resolve, reject) => { stripe.customers .list({limit: 3, email: email}) .autoPagingToArray({limit: LIMIT}) - .then(function(customers) { - return customers.map(function(customer) { - return customer.id; - }); - }) + .then((customers) => customers.map((customer) => customer.id)) .then(resolve) .catch(reject); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - it('accepts an onDone callback, passing an array', function() { - return expect( - new Promise(function(resolve, reject) { + it('accepts an onDone callback, passing an array', () => + expect( + new Promise((resolve, reject) => { function onDone(err, customers) { if (err) { reject(err); } else { - resolve( - customers.map(function(customer) { - return customer.id; - }) - ); + resolve(customers.map((customer) => customer.id)); } } @@ -462,12 +417,11 @@ describe('auto pagination', function() { .list({limit: 3, email: email}) .autoPagingToArray({limit: LIMIT}, onDone); }) - ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT)); - }); + ).to.eventually.deep.equal(realCustomerIds.slice(0, LIMIT))); - it('enforces a `limit` arg', function() { - return expect( - new Promise(function(resolve, reject) { + it('enforces a `limit` arg', () => + expect( + new Promise((resolve, reject) => { try { stripe.customers.list({limit: 3, email: email}).autoPagingToArray(); reject(Error('Should have thrown.')); @@ -477,12 +431,11 @@ describe('auto pagination', function() { }) ).to.eventually.equal( 'You must pass a `limit` option to autoPagingToArray, eg; `autoPagingToArray({limit: 1000});`.' - ); - }); + )); - it('caps the `limit` arg to a reasonable ceiling', function() { - return expect( - new Promise(function(resolve, reject) { + it('caps the `limit` arg to a reasonable ceiling', () => + expect( + new Promise((resolve, reject) => { try { stripe.customers .list({limit: 3, email: email}) @@ -494,14 +447,13 @@ describe('auto pagination', function() { }) ).to.eventually.equal( 'You cannot specify a limit of more than 10,000 items to fetch in `autoPagingToArray`; use `autoPagingEach` to iterate through longer lists.' - ); - }); + )); }); - describe('api compat edge cases', function() { - it('lets you listen to the first request as its own promise, and separately each item, but only sends one request for the first page.', function() { - return expect( - new Promise(function(resolve, reject) { + describe('api compat edge cases', () => { + it('lets you listen to the first request as its own promise, and separately each item, but only sends one request for the first page.', () => + expect( + new Promise((resolve, reject) => { // Count requests: we want one for the first page (not two), and then one for the second page. var reqCount = 0; function onRequest() { @@ -513,18 +465,16 @@ describe('auto pagination', function() { var p = stripe.customers.list({email: email, limit: 4}); Promise.all([ p, - p.autoPagingEach(function(customer) { + p.autoPagingEach((customer) => { customerIds.push(customer.id); }), ]) - .then(function(results) { + .then((results) => { stripe.off('request', onRequest); expect(reqCount).to.equal(2); // not 3. resolve({ - firstReq: results[0].data.map(function(customer) { - return customer.id; - }), + firstReq: results[0].data.map((customer) => customer.id), paginated: customerIds, }); }) @@ -533,7 +483,6 @@ describe('auto pagination', function() { ).to.eventually.deep.equal({ firstReq: realCustomerIds.slice(0, 4), paginated: realCustomerIds, - }); - }); + })); }); }); diff --git a/test/flows.spec.js b/test/flows.spec.js index e577bcc90c..84596cb327 100644 --- a/test/flows.spec.js +++ b/test/flows.spec.js @@ -22,18 +22,17 @@ describe('Flows', function() { var cleanup = new testUtils.CleanupUtility(); this.timeout(30000); - it('Allows me to retrieve default_currency', function() { - return expect( - stripe.account.retrieve().then(function(acct) { + it('Allows me to retrieve default_currency', () => + expect( + stripe.account.retrieve().then((acct) => { CURRENCY = acct.default_currency; return acct; }) - ).to.eventually.have.property('default_currency'); - }); + ).to.eventually.have.property('default_currency')); - describe('Plan+Subscription flow', function() { - it('Allows me to: Create a plan and subscribe a customer to it', function() { - return expect( + describe('Plan+Subscription flow', () => { + it('Allows me to: Create a plan and subscribe a customer to it', () => + expect( Promise.all([ stripe.plans.create({ id: 'plan' + testUtils.getRandomString(), @@ -46,7 +45,7 @@ describe('Flows', function() { }, }), stripe.customers.create(CUSTOMER_DETAILS), - ]).then(function(j) { + ]).then((j) => { var plan = j[0]; var customer = j[1]; @@ -57,10 +56,9 @@ describe('Flows', function() { plan: plan.id, }); }) - ).to.eventually.have.property('status', 'active'); - }); + ).to.eventually.have.property('status', 'active')); - it('Allows me to: Create a plan and subscribe a customer to it, and update subscription (multi-subs API)', function() { + it('Allows me to: Create a plan and subscribe a customer to it, and update subscription (multi-subs API)', () => { var plan; return expect( Promise.all([ @@ -76,7 +74,7 @@ describe('Flows', function() { }), stripe.customers.create(CUSTOMER_DETAILS), ]) - .then(function(j) { + .then((j) => { plan = j[0]; var customer = j[1]; @@ -87,46 +85,44 @@ describe('Flows', function() { plan: plan.id, }); }) - .then(function(subscription) { - return stripe.customers.updateSubscription( + .then((subscription) => + stripe.customers.updateSubscription( subscription.customer, subscription.id, { plan: plan.id, quantity: '3', } - ); - }) - .then(function(subscription) { - return [subscription.status, subscription.quantity]; - }) + ) + ) + .then((subscription) => [subscription.status, subscription.quantity]) ).to.eventually.deep.equal(['active', 3]); }); - it('Errors when I attempt to subscribe a customer to a non-existent plan', function() { - return expect( - stripe.customers.create(CUSTOMER_DETAILS).then(function(customer) { + it('Errors when I attempt to subscribe a customer to a non-existent plan', () => + expect( + stripe.customers.create(CUSTOMER_DETAILS).then((customer) => { cleanup.deleteCustomer(customer.id); return stripe.customers .updateSubscription(customer.id, { plan: 'someNonExistentPlan' + testUtils.getRandomString(), }) - .then(null, function(err) { - // Resolve with the error so we can inspect it below - return err; - }); + .then( + null, + (err) => + // Resolve with the error so we can inspect it below + err + ); }) - ).to.eventually.satisfy(function(err) { - return ( + ).to.eventually.satisfy( + (err) => err.type === 'StripeInvalidRequestError' && err.rawType === 'invalid_request_error' - ); - }); - }); + )); - it('Allows me to: subscribe then update with `cancel_at_period_end` defined', function() { - return expect( + it('Allows me to: subscribe then update with `cancel_at_period_end` defined', () => + expect( Promise.all([ stripe.plans.create({ id: 'plan' + testUtils.getRandomString(), @@ -139,7 +135,7 @@ describe('Flows', function() { }, }), stripe.customers.create(CUSTOMER_DETAILS), - ]).then(function(j) { + ]).then((j) => { var plan = j[0]; var customer = j[1]; @@ -151,235 +147,187 @@ describe('Flows', function() { cancel_at_period_end: true, }); }) - ).to.eventually.have.property('cancel_at_period_end', true); - }); + ).to.eventually.have.property('cancel_at_period_end', true)); - describe('Plan name variations', function() { + describe('Plan name variations', () => { [ '34535_355453' + testUtils.getRandomString(), 'TEST_239291' + testUtils.getRandomString(), 'TEST_a-i' + testUtils.getRandomString(), 'foobarbazteston___etwothree' + testUtils.getRandomString(), - ].forEach(function(planID) { - it( - 'Allows me to create and retrieve plan with ID: ' + planID, - function() { - return expect( - stripe.plans - .create({ - id: planID, - amount: 1700, - currency: CURRENCY, - interval: 'month', - nickname: 'generic', - product: { - name: 'product' + testUtils.getRandomString(), - }, - }) - .then(function() { - cleanup.deletePlan(planID); - return stripe.plans.retrieve(planID); - }) - ).to.eventually.have.property('id', planID); - } + ].forEach((planID) => { + it('Allows me to create and retrieve plan with ID: ' + planID, () => + expect( + stripe.plans + .create({ + id: planID, + amount: 1700, + currency: CURRENCY, + interval: 'month', + nickname: 'generic', + product: { + name: 'product' + testUtils.getRandomString(), + }, + }) + .then(() => { + cleanup.deletePlan(planID); + return stripe.plans.retrieve(planID); + }) + ).to.eventually.have.property('id', planID) ); }); }); }); - describe('Coupon flow', function() { + describe('Coupon flow', () => { var customer; var coupon; - describe('When I create a coupon & customer', function() { - it('Does so', function() { - return expect( + describe('When I create a coupon & customer', () => { + it('Does so', () => + expect( Promise.all([ stripe.coupons.create({ percent_off: 20, duration: 'once', }), stripe.customers.create(CUSTOMER_DETAILS), - ]).then(function(joined) { + ]).then((joined) => { coupon = joined[0]; customer = joined[1]; }) - ).to.not.be.eventually.rejected; - }); - describe('And I apply the coupon to the customer', function() { - it('Does so', function() { - return expect( + ).to.not.be.eventually.rejected); + describe('And I apply the coupon to the customer', () => { + it('Does so', () => + expect( stripe.customers.update(customer.id, { coupon: coupon.id, }) - ).to.not.be.eventually.rejected; - }); - it('Can be retrieved from that customer', function() { - return expect( + ).to.not.be.eventually.rejected); + it('Can be retrieved from that customer', () => + expect( stripe.customers.retrieve(customer.id) - ).to.eventually.have.nested.property('discount.coupon.id', coupon.id); - }); - describe('The resulting discount', function() { - it('Can be removed', function() { - return expect( + ).to.eventually.have.nested.property( + 'discount.coupon.id', + coupon.id + )); + describe('The resulting discount', () => { + it('Can be removed', () => + expect( stripe.customers.deleteDiscount(customer.id) - ).to.eventually.have.property('deleted', true); - }); - describe('Re-querying it', function() { - it('Does indeed indicate that it is deleted', function() { - return expect( + ).to.eventually.have.property('deleted', true)); + describe('Re-querying it', () => { + it('Does indeed indicate that it is deleted', () => + expect( stripe.customers.retrieve(customer.id) - ).to.eventually.have.property('discount', null); - }); + ).to.eventually.have.property('discount', null)); }); }); }); }); }); - describe('Metadata flow', function() { - it('Can save and retrieve metadata', function() { + describe('Metadata flow', () => { + it('Can save and retrieve metadata', () => { var customer; return expect( stripe.customers .create(CUSTOMER_DETAILS) - .then(function(cust) { + .then((cust) => { customer = cust; cleanup.deleteCustomer(cust.id); return stripe.customers.setMetadata(cust.id, {foo: '123'}); }) - .then(function() { - return stripe.customers.getMetadata(customer.id); - }) + .then(() => stripe.customers.getMetadata(customer.id)) ).to.eventually.deep.equal({foo: '123'}); }); - it('Can reset metadata', function() { + it('Can reset metadata', () => { var customer; return expect( stripe.customers .create(CUSTOMER_DETAILS) - .then(function(cust) { + .then((cust) => { customer = cust; cleanup.deleteCustomer(cust.id); return stripe.customers.setMetadata(cust.id, {baz: '123'}); }) - .then(function() { - return stripe.customers.setMetadata(customer.id, null); - }) - .then(function() { - return stripe.customers.getMetadata(customer.id); - }) + .then(() => stripe.customers.setMetadata(customer.id, null)) + .then(() => stripe.customers.getMetadata(customer.id)) ).to.eventually.deep.equal({}); }); - it('Resets metadata when setting new metadata', function() { + it('Resets metadata when setting new metadata', () => { var customer; return expect( stripe.customers .create(CUSTOMER_DETAILS) - .then(function(cust) { + .then((cust) => { customer = cust; cleanup.deleteCustomer(cust.id); return stripe.customers.setMetadata(cust.id, {foo: '123'}); }) - .then(function() { - return stripe.customers.setMetadata(customer.id, {baz: '456'}); - }) + .then(() => stripe.customers.setMetadata(customer.id, {baz: '456'})) ).to.eventually.deep.equal({baz: '456'}); }); - it('Can set individual key/value pairs', function() { + it('Can set individual key/value pairs', () => { var customer; return expect( stripe.customers .create(CUSTOMER_DETAILS) - .then(function(cust) { + .then((cust) => { customer = cust; cleanup.deleteCustomer(cust.id); }) - .then(function() { - return stripe.customers.setMetadata(customer.id, 'baz', 456); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, '_other_', 999); - }) - .then(function() { - return stripe.customers.setMetadata(customer.id, 'foo', 123); - }) - .then(function() { + .then(() => stripe.customers.setMetadata(customer.id, 'baz', 456)) + .then(() => stripe.customers.setMetadata(customer.id, '_other_', 999)) + .then(() => stripe.customers.setMetadata(customer.id, 'foo', 123)) + .then(() => // Change foo - return stripe.customers.setMetadata(customer.id, 'foo', 222); - }) - .then(function() { + stripe.customers.setMetadata(customer.id, 'foo', 222) + ) + .then(() => // Delete baz - return stripe.customers.setMetadata(customer.id, 'baz', null); - }) - .then(function() { - return stripe.customers.getMetadata(customer.id); - }) + stripe.customers.setMetadata(customer.id, 'baz', null) + ) + .then(() => stripe.customers.getMetadata(customer.id)) ).to.eventually.deep.equal({_other_: '999', foo: '222'}); }); - it('Can set individual key/value pairs [with per request token]', function() { + it('Can set individual key/value pairs [with per request token]', () => { var customer; var authToken = testUtils.getUserStripeKey(); return expect( stripe.customers .create(CUSTOMER_DETAILS) - .then(function(cust) { + .then((cust) => { customer = cust; cleanup.deleteCustomer(cust.id); }) - .then(function() { - return stripe.customers.setMetadata( - customer.id, - {baz: 456}, - authToken - ); - }) - .then(function() { - return stripe.customers.setMetadata( - customer.id, - '_other_', - 999, - authToken - ); - }) - .then(function() { - return stripe.customers.setMetadata( - customer.id, - 'foo', - 123, - authToken - ); - }) - .then(function() { + .then(() => + stripe.customers.setMetadata(customer.id, {baz: 456}, authToken) + ) + .then(() => + stripe.customers.setMetadata(customer.id, '_other_', 999, authToken) + ) + .then(() => + stripe.customers.setMetadata(customer.id, 'foo', 123, authToken) + ) + .then(() => // Change foo - return stripe.customers.setMetadata( - customer.id, - 'foo', - 222, - authToken - ); - }) - .then(function() { + stripe.customers.setMetadata(customer.id, 'foo', 222, authToken) + ) + .then(() => // Delete baz - return stripe.customers.setMetadata( - customer.id, - 'baz', - null, - authToken - ); - }) - .then(function() { - return stripe.customers.getMetadata(customer.id, authToken); - }) + stripe.customers.setMetadata(customer.id, 'baz', null, authToken) + ) + .then(() => stripe.customers.getMetadata(customer.id, authToken)) ).to.eventually.deep.equal({_other_: '999', foo: '222'}); }); }); - describe('Expanding', function() { - describe('A customer within a charge', function() { - it('Allows you to expand a customer object', function() { - return expect( - stripe.customers.create(CUSTOMER_DETAILS).then(function(cust) { + describe('Expanding', () => { + describe('A customer within a charge', () => { + it('Allows you to expand a customer object', () => + expect( + stripe.customers.create(CUSTOMER_DETAILS).then((cust) => { cleanup.deleteCustomer(cust.id); return stripe.charges.create({ customer: cust.id, @@ -388,31 +336,29 @@ describe('Flows', function() { expand: ['customer'], }); }) - ).to.eventually.have.nested.property('customer.created'); - }); + ).to.eventually.have.nested.property('customer.created')); }); - describe("A customer's default source", function() { - it('Allows you to expand a default_source', function() { - return expect( + describe("A customer's default source", () => { + it('Allows you to expand a default_source', () => + expect( stripe.customers .create({ description: 'Some customer', source: 'tok_visa', expand: ['default_source'], }) - .then(function(cust) { + .then((cust) => { cleanup.deleteCustomer(cust.id); return cust; }) // Confirm it's expanded by checking that some prop (e.g. exp_year) exists: - ).to.eventually.have.nested.property('default_source.exp_year'); - }); + ).to.eventually.have.nested.property('default_source.exp_year')); }); }); - describe('Charge', function() { - it('Allows you to create a charge', function() { - return expect( + describe('Charge', () => { + it('Allows you to create a charge', () => + expect( stripe.charges .create({ amount: 1234, @@ -425,37 +371,32 @@ describe('Flows', function() { }, }, }) - .then(null, function(error) { - return error; - }) - ).to.eventually.have.nested.property('raw.charge'); - }); + .then(null, (error) => error) + ).to.eventually.have.nested.property('raw.charge')); }); - describe('Getting balance', function() { - it('Allows me to do so', function() { - return expect(stripe.balance.retrieve()).to.eventually.have.property( + describe('Getting balance', () => { + it('Allows me to do so', () => + expect(stripe.balance.retrieve()).to.eventually.have.property( 'object', 'balance' - ); - }); - it('Allows me to do so with specified auth key', function() { - return expect( + )); + it('Allows me to do so with specified auth key', () => + expect( stripe.balance.retrieve(testUtils.getUserStripeKey()) - ).to.eventually.have.property('object', 'balance'); - }); + ).to.eventually.have.property('object', 'balance')); }); - describe('Request/Response Events', function() { + describe('Request/Response Events', () => { var connectedAccountId; - before(function(done) { + before((done) => { // Pick a random connected account to use in the `Stripe-Account` header stripe.accounts .list({ limit: 1, }) - .then(function(accounts) { + .then((accounts) => { if (accounts.data.length < 1) { return done( new Error( @@ -470,7 +411,7 @@ describe('Flows', function() { }); }); - it('should emit a `request` event to listeners on request', function(done) { + it('should emit a `request` event to listeners on request', (done) => { var apiVersion = '2017-06-05'; var idempotencyKey = Math.random() .toString(36) @@ -505,12 +446,12 @@ describe('Flows', function() { stripe_account: connectedAccountId, } ) - .then(null, function() { + .then(null, () => { // I expect there to be an error here. }); }); - it('should emit a `response` event to listeners on response', function(done) { + it('should emit a `response` event to listeners on response', (done) => { var apiVersion = '2017-06-05'; var idempotencyKey = Math.random() .toString(36) @@ -552,12 +493,12 @@ describe('Flows', function() { stripe_account: connectedAccountId, } ) - .then(null, function() { + .then(null, () => { // I expect there to be an error here. }); }); - it('should not emit a `response` event to removed listeners on response', function(done) { + it('should not emit a `response` event to removed listeners on response', (done) => { function onResponse(response) { done(new Error('How did you get here?')); } @@ -571,14 +512,14 @@ describe('Flows', function() { currency: 'usd', card: 'tok_visa', }) - .then(function() { + .then(() => { done(); }); }); }); - describe('FileUpload', function() { - it('Allows you to upload a file as a stream', function() { + describe('FileUpload', () => { + it('Allows you to upload a file as a stream', () => { var testFilename = path.join(__dirname, 'resources/data/minimal.pdf'); var f = fs.createReadStream(testFilename); @@ -592,13 +533,11 @@ describe('Flows', function() { type: 'application/octet-stream', }, }) - .then(null, function(error) { - return error; - }) + .then(null, (error) => error) ).to.eventually.have.nested.property('size', 739); }); - it('Allows you to upload a file synchronously', function() { + it('Allows you to upload a file synchronously', () => { var testFilename = path.join(__dirname, 'resources/data/minimal.pdf'); var f = fs.readFileSync(testFilename); @@ -612,19 +551,17 @@ describe('Flows', function() { type: 'application/octet-stream', }, }) - .then(null, function(error) { - return error; - }) + .then(null, (error) => error) ).to.eventually.have.nested.property('size', 739); }); - it('Surfaces stream errors correctly', function(done) { + it('Surfaces stream errors correctly', (done) => { var mockedStream = new stream.Readable(); - mockedStream._read = function() {}; + mockedStream._read = () => {}; var fakeError = new Error('I am a fake error'); - process.nextTick(function() { + process.nextTick(() => { mockedStream.emit('error', fakeError); }); @@ -637,7 +574,7 @@ describe('Flows', function() { type: 'application/octet-stream', }, }) - .catch(function(error) { + .catch((error) => { expect(error.message).to.equal( 'An error occurred while attempting to process the file for upload.' ); diff --git a/test/resources/Account.spec.js b/test/resources/Account.spec.js index 5eaef72394..255a3bebf4 100644 --- a/test/resources/Account.spec.js +++ b/test/resources/Account.spec.js @@ -5,12 +5,12 @@ var expect = require('chai').expect; var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Account Resource', function() { +describe('Account Resource', () => { function uniqueEmail() { return Math.random() + 'bob@example.com'; } - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { var data = { managed: false, country: 'US', @@ -26,8 +26,8 @@ describe('Account Resource', function() { }); }); - describe('delete', function() { - it('deletes an account successfully', function() { + describe('delete', () => { + it('deletes an account successfully', () => { stripe.account.del('acct_16Tzq6DBahdM4C8s'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -38,8 +38,8 @@ describe('Account Resource', function() { }); }); - describe('reject', function() { - it('rejects an account successfully', function() { + describe('reject', () => { + it('rejects an account successfully', () => { stripe.account.reject('acct_16Tzq6DBahdM4C8s', {reason: 'fraud'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -50,8 +50,8 @@ describe('Account Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request with no params', function() { + describe('retrieve', () => { + it('Sends the correct request with no params', () => { stripe.account.retrieve(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -61,7 +61,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with ID param', function() { + it('Sends the correct request with ID param', () => { stripe.account.retrieve('foo'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -71,7 +71,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with secret key', function() { + it('Sends the correct request with secret key', () => { var key = 'sk_12345678901234567890123456789012'; stripe.account.retrieve(null, key); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -83,7 +83,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with secret key as first object', function() { + it('Sends the correct request with secret key as first object', () => { var params = {api_key: 'sk_12345678901234567890123456789012'}; stripe.account.retrieve(params); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -95,8 +95,8 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request with a callback', function() { - stripe.account.retrieve(function(err, account) {}); + it('Sends the correct request with a callback', () => { + stripe.account.retrieve((err, account) => {}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/account', @@ -106,9 +106,9 @@ describe('Account Resource', function() { }); }); - describe('External account methods', function() { - describe('retrieveExternalAccount', function() { - it('Sends the correct request', function() { + describe('External account methods', () => { + describe('retrieveExternalAccount', () => { + it('Sends the correct request', () => { stripe.account.retrieveExternalAccount( 'accountIdFoo321', 'externalAccountIdFoo456' @@ -122,7 +122,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.retrieveExternalAccount( 'accountIdFoo321', 'externalAccountIdFoo456', @@ -139,8 +139,8 @@ describe('Account Resource', function() { }); }); - describe('createExternalAccount', function() { - it('Sends the correct request', function() { + describe('createExternalAccount', () => { + it('Sends the correct request', () => { stripe.account.createExternalAccount('accountIdFoo321', { number: '123456', currency: 'usd', @@ -154,7 +154,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.createExternalAccount( 'accountIdFoo321', { @@ -174,8 +174,8 @@ describe('Account Resource', function() { }); }); - describe('updateExternalAccount', function() { - it('Sends the correct request', function() { + describe('updateExternalAccount', () => { + it('Sends the correct request', () => { stripe.account.updateExternalAccount( 'accountIdFoo321', 'externalAccountIdFoo456', @@ -193,8 +193,8 @@ describe('Account Resource', function() { }); }); - describe('deleteExternalAccount', function() { - it('Sends the correct request', function() { + describe('deleteExternalAccount', () => { + it('Sends the correct request', () => { stripe.account.deleteExternalAccount( 'accountIdFoo321', 'externalAccountIdFoo456' @@ -208,7 +208,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.deleteExternalAccount( 'accountIdFoo321', 'externalAccountIdFoo456', @@ -225,8 +225,8 @@ describe('Account Resource', function() { }); }); - describe('listExternalAccounts', function() { - it('Sends the correct request', function() { + describe('listExternalAccounts', () => { + it('Sends the correct request', () => { stripe.account.listExternalAccounts('accountIdFoo321'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -236,7 +236,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.listExternalAccounts('accountIdFoo321', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -249,9 +249,9 @@ describe('Account Resource', function() { }); }); - describe('LoginLink methods', function() { - describe('createLoginLink', function() { - it('Sends the correct request', function() { + describe('LoginLink methods', () => { + describe('createLoginLink', () => { + it('Sends the correct request', () => { stripe.account.createLoginLink('acct_EXPRESS'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -263,9 +263,9 @@ describe('Account Resource', function() { }); }); - describe('Person methods', function() { - describe('retrievePerson', function() { - it('Sends the correct request', function() { + describe('Person methods', () => { + describe('retrievePerson', () => { + it('Sends the correct request', () => { stripe.account.retrievePerson('acct_123', 'person_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -275,7 +275,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.retrievePerson('acct_123', 'person_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -287,8 +287,8 @@ describe('Account Resource', function() { }); }); - describe('createPerson', function() { - it('Sends the correct request', function() { + describe('createPerson', () => { + it('Sends the correct request', () => { stripe.account.createPerson('acct_123', { first_name: 'John', }); @@ -300,7 +300,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.createPerson( 'acct_123', { @@ -318,8 +318,8 @@ describe('Account Resource', function() { }); }); - describe('updatePerson', function() { - it('Sends the correct request', function() { + describe('updatePerson', () => { + it('Sends the correct request', () => { stripe.account.updatePerson('acct_123', 'person_123', { first_name: 'John', }); @@ -331,7 +331,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.updatePerson( 'acct_123', 'person_123', @@ -350,8 +350,8 @@ describe('Account Resource', function() { }); }); - describe('deletePerson', function() { - it('Sends the correct request', function() { + describe('deletePerson', () => { + it('Sends the correct request', () => { stripe.account.deletePerson('acct_123', 'person_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -361,7 +361,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.deletePerson('acct_123', 'person_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -373,8 +373,8 @@ describe('Account Resource', function() { }); }); - describe('listPersons', function() { - it('Sends the correct request', function() { + describe('listPersons', () => { + it('Sends the correct request', () => { stripe.account.listPersons('acct_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -384,7 +384,7 @@ describe('Account Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.account.listPersons('acct_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/AccountLinks.spec.js b/test/resources/AccountLinks.spec.js index 74dfe1caef..4f79dc21d8 100644 --- a/test/resources/AccountLinks.spec.js +++ b/test/resources/AccountLinks.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('AccountLinks Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('AccountLinks Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.accountLinks.create({ account: 'acct_123', failure_url: 'https://stripe.com/failure', diff --git a/test/resources/ApplePayDomains.spec.js b/test/resources/ApplePayDomains.spec.js index 106e3fd9fd..1e0071bd4a 100644 --- a/test/resources/ApplePayDomains.spec.js +++ b/test/resources/ApplePayDomains.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('ApplePayDomains Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('ApplePayDomains Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.applePayDomains.retrieve('apwc_retrieve'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('ApplePayDomains Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.applePayDomains.del('apwc_delete'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('ApplePayDomains Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.applePayDomains.create({ domain_name: 'example.com', }); @@ -45,8 +45,8 @@ describe('ApplePayDomains Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.applePayDomains.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/ApplicationFeeRefunds.spec.js b/test/resources/ApplicationFeeRefunds.spec.js index 8f97d8db0e..15d0760b01 100644 --- a/test/resources/ApplicationFeeRefunds.spec.js +++ b/test/resources/ApplicationFeeRefunds.spec.js @@ -15,9 +15,9 @@ var appFeeRefund = new resources.ApplicationFeeRefunds(stripe, { // Use spy from existing resource: appFeeRefund._request = stripe.customers._request; -describe('ApplicationFeeRefund Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('ApplicationFeeRefund Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { appFeeRefund.retrieve(REFUND_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -32,8 +32,8 @@ describe('ApplicationFeeRefund Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { appFeeRefund.update(REFUND_TEST_ID, { metadata: {key: 'value'}, }); @@ -50,8 +50,8 @@ describe('ApplicationFeeRefund Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { appFeeRefund.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/ApplicationFees.spec.js b/test/resources/ApplicationFees.spec.js index 34dbac595e..28361f3131 100644 --- a/test/resources/ApplicationFees.spec.js +++ b/test/resources/ApplicationFees.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('ApplicationFee Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('ApplicationFee Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.applicationFees.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('ApplicationFee Resource', function() { }); }); - describe('refund', function() { - it('Sends the correct request', function() { + describe('refund', () => { + it('Sends the correct request', () => { stripe.applicationFees.refund('applicationFeeIdExample3242', { amount: 23, }); @@ -30,8 +30,8 @@ describe('ApplicationFee Resource', function() { }); }); - describe('refunds', function() { - it('Sends the correct update request', function() { + describe('refunds', () => { + it('Sends the correct update request', () => { stripe.applicationFees.updateRefund( 'appFeeIdExample3242', 'refundIdExample2312', @@ -46,7 +46,7 @@ describe('ApplicationFee Resource', function() { }); }); - it('Sends the correct create request', function() { + it('Sends the correct create request', () => { stripe.applicationFees.createRefund('appFeeIdExample3242', {amount: 100}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -56,7 +56,7 @@ describe('ApplicationFee Resource', function() { }); }); - it('Sends the correct list request', function() { + it('Sends the correct list request', () => { stripe.applicationFees.listRefunds('appFeeIdExample3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -66,7 +66,7 @@ describe('ApplicationFee Resource', function() { }); }); - it('Sends the correct retrieve request', function() { + it('Sends the correct retrieve request', () => { stripe.applicationFees.retrieveRefund( 'appFeeIdExample3242', 'refundIdExample2312' diff --git a/test/resources/Balance.spec.js b/test/resources/Balance.spec.js index 4951f9e151..cf6bd6be1a 100644 --- a/test/resources/Balance.spec.js +++ b/test/resources/Balance.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Balance Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Balance Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.balance.retrieve(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -15,7 +15,7 @@ describe('Balance Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.balance.retrieve('aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -27,8 +27,8 @@ describe('Balance Resource', function() { }); }); - describe('listTransactions', function() { - it('Sends the correct request', function() { + describe('listTransactions', () => { + it('Sends the correct request', () => { stripe.balance.listTransactions(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -38,7 +38,7 @@ describe('Balance Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.balance.listTransactions('aGN0bIwXnHdw5645VABjPdSn8nWY7G11'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -50,8 +50,8 @@ describe('Balance Resource', function() { }); }); - describe('retrieveTransaction', function() { - it('Sends the correct request', function() { + describe('retrieveTransaction', () => { + it('Sends the correct request', () => { stripe.balance.retrieveTransaction('transactionIdFoo'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -61,7 +61,7 @@ describe('Balance Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.balance.retrieveTransaction( 'transactionIdFoo', 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11' diff --git a/test/resources/BitcoinReceivers.spec.js b/test/resources/BitcoinReceivers.spec.js index ada4e055db..2b9f38fa38 100644 --- a/test/resources/BitcoinReceivers.spec.js +++ b/test/resources/BitcoinReceivers.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('BitcoinReceivers Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('BitcoinReceivers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.bitcoinReceivers.retrieve('receiverId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('BitcoinReceivers Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.bitcoinReceivers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('BitcoinReceivers Resource', function() { }); }); - describe('listTransactions', function() { - it('Sends the correct request', function() { + describe('listTransactions', () => { + it('Sends the correct request', () => { stripe.bitcoinReceivers.listTransactions('receiverId', { limit: 1, }); diff --git a/test/resources/ChargeRefunds.spec.js b/test/resources/ChargeRefunds.spec.js index 843930073f..6a25fdacc6 100644 --- a/test/resources/ChargeRefunds.spec.js +++ b/test/resources/ChargeRefunds.spec.js @@ -15,9 +15,9 @@ var chargeRefund = new resources.ChargeRefunds(stripe, { // Use spy from existing resource: chargeRefund._request = stripe.customers._request; -describe('ChargeRefund Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('ChargeRefund Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { chargeRefund.retrieve(REFUND_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('ChargeRefund Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { chargeRefund.create({ amount: 100, }); @@ -42,8 +42,8 @@ describe('ChargeRefund Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { chargeRefund.update(REFUND_TEST_ID, { metadata: {key: 'value'}, }); @@ -56,8 +56,8 @@ describe('ChargeRefund Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { chargeRefund.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Charges.spec.js b/test/resources/Charges.spec.js index dc68e835bf..62b12dccc3 100644 --- a/test/resources/Charges.spec.js +++ b/test/resources/Charges.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Charge Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Charge Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.charges.retrieve('chargeIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Charge Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.charges.create({ amount: '1500', currency: 'usd', @@ -44,8 +44,8 @@ describe('Charge Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.charges.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -56,8 +56,8 @@ describe('Charge Resource', function() { }); }); - describe('capture', function() { - it('Sends the correct request', function() { + describe('capture', () => { + it('Sends the correct request', () => { stripe.charges.capture('chargeIdExample3242', {amount: 23}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -68,8 +68,8 @@ describe('Charge Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.charges.update('chargeIdExample3242', {description: 'foo321'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -80,8 +80,8 @@ describe('Charge Resource', function() { }); }); - describe('refund', function() { - it('Sends the correct request', function() { + describe('refund', () => { + it('Sends the correct request', () => { stripe.charges.refund('chargeIdExample3242', {amount: 23}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -91,7 +91,7 @@ describe('Charge Resource', function() { }); }); - it('Incorrect arguments result in an error', function() { + it('Incorrect arguments result in an error', () => { expect( stripe.charges.refund('chargeIdExample123', 39392) ).to.be.eventually.rejectedWith(/unknown arguments/i); @@ -106,8 +106,8 @@ describe('Charge Resource', function() { }); }); - describe('refunds', function() { - it('Sends the correct update request', function() { + describe('refunds', () => { + it('Sends the correct update request', () => { stripe.charges.updateRefund( 'chargeIdExample3242', 'refundIdExample2312', @@ -121,7 +121,7 @@ describe('Charge Resource', function() { }); }); - it('Sends the correct create request', function() { + it('Sends the correct create request', () => { stripe.charges.createRefund('chargeIdExample3242', {amount: 100}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -131,7 +131,7 @@ describe('Charge Resource', function() { }); }); - it('Sends the correct list request', function() { + it('Sends the correct list request', () => { stripe.charges.listRefunds('chargeIdExample3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -141,7 +141,7 @@ describe('Charge Resource', function() { }); }); - it('Sends the correct retrieve request', function() { + it('Sends the correct retrieve request', () => { stripe.charges.retrieveRefund( 'chargeIdExample3242', 'refundIdExample2312' @@ -155,8 +155,8 @@ describe('Charge Resource', function() { }); }); - describe('updateDispute', function() { - it('Sends the correct request', function() { + describe('updateDispute', () => { + it('Sends the correct request', () => { stripe.charges.updateDispute('chargeIdExample3242', {evidence: 'foo'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -167,8 +167,8 @@ describe('Charge Resource', function() { }); }); - describe('closeDispute', function() { - it('Sends the correct request', function() { + describe('closeDispute', () => { + it('Sends the correct request', () => { stripe.charges.closeDispute('chargeIdExample3242', {}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -179,8 +179,8 @@ describe('Charge Resource', function() { }); }); - describe('markAsFraudulent', function() { - it('Sends the correct request', function() { + describe('markAsFraudulent', () => { + it('Sends the correct request', () => { stripe.charges.markAsFraudulent('chargeIdExample3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -191,8 +191,8 @@ describe('Charge Resource', function() { }); }); - describe('markAsSafe', function() { - it('Sends the correct request', function() { + describe('markAsSafe', () => { + it('Sends the correct request', () => { stripe.charges.markAsSafe('chargeIdExample3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Checkout/Sessions.spec.js b/test/resources/Checkout/Sessions.spec.js index 1b071806f0..64850dd3e5 100644 --- a/test/resources/Checkout/Sessions.spec.js +++ b/test/resources/Checkout/Sessions.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Checkout', function() { - describe('Sessions Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Checkout', () => { + describe('Sessions Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { var params = { cancel_url: 'https://stripe.com/cancel', client_reference_id: '1234', @@ -38,8 +38,8 @@ describe('Checkout', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.checkout.sessions.retrieve('cs_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/CountrySpecs.spec.js b/test/resources/CountrySpecs.spec.js index b896cdb91d..1bdc6bd62a 100644 --- a/test/resources/CountrySpecs.spec.js +++ b/test/resources/CountrySpecs.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('CountrySpecs Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('CountrySpecs Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.countrySpecs.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('CountrySpecs Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { var country = 'US'; stripe.countrySpecs.retrieve(country); expect(stripe.LAST_REQUEST).to.deep.equal({ diff --git a/test/resources/Coupons.spec.js b/test/resources/Coupons.spec.js index 199845993e..0f898f1193 100644 --- a/test/resources/Coupons.spec.js +++ b/test/resources/Coupons.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Coupons Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Coupons Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.coupons.retrieve('couponId123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Coupons Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.coupons.del('couponId123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('Coupons Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.coupons.update('couponId123', { metadata: {a: '1234'}, }); @@ -44,8 +44,8 @@ describe('Coupons Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.coupons.create({ percent_off: 25, duration: 'repeating', @@ -65,8 +65,8 @@ describe('Coupons Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.coupons.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/CreditNotes.spec.js b/test/resources/CreditNotes.spec.js index b0343e1eca..561d3a914a 100644 --- a/test/resources/CreditNotes.spec.js +++ b/test/resources/CreditNotes.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('CreditNotes Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('CreditNotes Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.creditNotes.retrieve('cn_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('CreditNotes Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { var data = { amount: 100, invoice: 'in_123', @@ -33,8 +33,8 @@ describe('CreditNotes Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.creditNotes.list({count: 25}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -45,8 +45,8 @@ describe('CreditNotes Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.creditNotes.update('cn_123', {application_fee: 200}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -57,8 +57,8 @@ describe('CreditNotes Resource', function() { }); }); - describe('voidCreditNote', function() { - it('Sends the correct request', function() { + describe('voidCreditNote', () => { + it('Sends the correct request', () => { stripe.creditNotes.voidCreditNote('cn_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/CustomerCards.spec.js b/test/resources/CustomerCards.spec.js index 0354d9fb7e..bc855b56eb 100644 --- a/test/resources/CustomerCards.spec.js +++ b/test/resources/CustomerCards.spec.js @@ -14,9 +14,9 @@ var customerCard = new resources.CustomerCards(stripe, { // Use spy from existing resource: customerCard._request = stripe.customers._request; -describe('CustomerCard Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('CustomerCard Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { customerCard.retrieve('cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -27,8 +27,8 @@ describe('CustomerCard Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { customerCard.create({ number: '123456', exp_month: '12', @@ -42,8 +42,8 @@ describe('CustomerCard Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { customerCard.update('cardIdFoo456', { name: 'Bob M. Baz', }); @@ -56,8 +56,8 @@ describe('CustomerCard Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { customerCard.del('cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -68,8 +68,8 @@ describe('CustomerCard Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { customerCard.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/CustomerSubscriptions.spec.js b/test/resources/CustomerSubscriptions.spec.js index 6d9b71933e..e62d8785a3 100644 --- a/test/resources/CustomerSubscriptions.spec.js +++ b/test/resources/CustomerSubscriptions.spec.js @@ -14,9 +14,9 @@ var customerSubscription = new resources.CustomerSubscriptions(stripe, { // Use spy from existing resource: customerSubscription._request = stripe.customers._request; -describe('CustomerSubscription Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('CustomerSubscription Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { customerSubscription.retrieve('subscriptionIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -30,8 +30,8 @@ describe('CustomerSubscription Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { customerSubscription.create({ plan: 'gold', quantity: '12', @@ -45,8 +45,8 @@ describe('CustomerSubscription Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { customerSubscription.update('subscriptionIdFoo456', { name: 'Bob M. Baz', }); @@ -62,8 +62,8 @@ describe('CustomerSubscription Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { customerSubscription.del('subscriptionIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -77,8 +77,8 @@ describe('CustomerSubscription Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { customerSubscription.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -89,9 +89,9 @@ describe('CustomerSubscription Resource', function() { }); }); - describe('Discount methods', function() { - describe('deleteDiscount', function() { - it('Sends the correct request', function() { + describe('Discount methods', () => { + describe('deleteDiscount', () => { + it('Sends the correct request', () => { customerSubscription.deleteDiscount( 'customerIdFoo321', 'subscriptionIdBar654' diff --git a/test/resources/Customers.spec.js b/test/resources/Customers.spec.js index 3193585e12..96e13ebd99 100644 --- a/test/resources/Customers.spec.js +++ b/test/resources/Customers.spec.js @@ -5,9 +5,9 @@ var expect = require('chai').expect; var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Customers Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Customers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.customers.retrieve('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -17,7 +17,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.retrieve('cus_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -29,8 +29,8 @@ describe('Customers Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.customers.create({description: 'Some customer'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -40,7 +40,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.create({description: 'Some customer'}, TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -51,7 +51,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth and no body]', function() { + it('Sends the correct request [with specified auth and no body]', () => { stripe.customers.create(TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -62,7 +62,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified idempotency_key in options]', function() { + it('Sends the correct request [with specified idempotency_key in options]', () => { stripe.customers.create( {description: 'Some customer'}, {idempotency_key: 'foo'} @@ -75,7 +75,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth in options]', function() { + it('Sends the correct request [with specified auth in options]', () => { stripe.customers.create( {description: 'Some customer'}, {api_key: TEST_AUTH_KEY} @@ -89,7 +89,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth and idempotent key in options]', function() { + it('Sends the correct request [with specified auth and idempotent key in options]', () => { stripe.customers.create( {description: 'Some customer'}, {api_key: TEST_AUTH_KEY, idempotency_key: 'foo'} @@ -103,7 +103,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth in options and no body]', function() { + it('Sends the correct request [with specified auth in options and no body]', () => { stripe.customers.create({api_key: TEST_AUTH_KEY}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -115,8 +115,8 @@ describe('Customers Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.customers.update('cus_123', { description: 'Foo "baz"', }); @@ -129,8 +129,8 @@ describe('Customers Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.customers.del('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -141,8 +141,8 @@ describe('Customers Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.customers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -152,7 +152,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.list(TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -164,9 +164,9 @@ describe('Customers Resource', function() { }); }); - describe('Subscription methods', function() { - describe('updateSubscription', function() { - it('Sends the correct request', function() { + describe('Subscription methods', () => { + describe('updateSubscription', () => { + it('Sends the correct request', () => { stripe.customers.updateSubscription('cus_123', { plan: 'fooPlan', }); @@ -178,7 +178,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.updateSubscription( 'cus_123', { @@ -196,8 +196,8 @@ describe('Customers Resource', function() { }); }); - describe('cancelSubscription', function() { - it('Sends the correct request', function() { + describe('cancelSubscription', () => { + it('Sends the correct request', () => { stripe.customers.cancelSubscription('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -207,7 +207,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.cancelSubscription('cus_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -218,8 +218,8 @@ describe('Customers Resource', function() { }); }); - describe('With at_period_end defined', function() { - it('Sends the correct request', function() { + describe('With at_period_end defined', () => { + it('Sends the correct request', () => { stripe.customers.cancelSubscription('cus_123', {at_period_end: true}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -230,8 +230,8 @@ describe('Customers Resource', function() { }); }); - describe('With at_period_end defined [with specified auth]', function() { - it('Sends the correct request', function() { + describe('With at_period_end defined [with specified auth]', () => { + it('Sends the correct request', () => { stripe.customers.cancelSubscription( 'cus_123', {at_period_end: true}, @@ -249,9 +249,9 @@ describe('Customers Resource', function() { }); }); - describe('Discount methods', function() { - describe('deleteDiscount', function() { - it('Sends the correct request', function() { + describe('Discount methods', () => { + describe('deleteDiscount', () => { + it('Sends the correct request', () => { stripe.customers.deleteDiscount('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -262,8 +262,8 @@ describe('Customers Resource', function() { }); }); - describe('deleteSubscriptionDiscount', function() { - it('Sends the correct request', function() { + describe('deleteSubscriptionDiscount', () => { + it('Sends the correct request', () => { stripe.customers.deleteSubscriptionDiscount('cus_123', 'sub_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -275,10 +275,10 @@ describe('Customers Resource', function() { }); }); - describe('Metadata methods', function() { - describe('setMetadata', function() { - describe('When deleting metadata', function() { - it('Sends the correct request', function() { + describe('Metadata methods', () => { + describe('setMetadata', () => { + describe('When deleting metadata', () => { + it('Sends the correct request', () => { stripe.customers.setMetadata('cus_123', null); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -291,16 +291,16 @@ describe('Customers Resource', function() { }); }); - describe('When setting new metadata', function() { - it('Sends one request to get current, and another to set new data', function() { - return expect( - new Promise(function(resolve, reject) { + describe('When setting new metadata', () => { + it('Sends one request to get current, and another to set new data', () => + expect( + new Promise((resolve, reject) => { stripe.customers .setMetadata('cus_123', { foo: 123, baz: 456, }) - .then(function() { + .then(() => { var reqs = stripe.REQUESTS; resolve([ // Last two requests @@ -326,12 +326,11 @@ describe('Customers Resource', function() { metadata: {foo: 123, baz: 456}, }, }, - ]); - }); + ])); }); - describe('When setting with an auth key', function() { - it('Sends the correct request, including the specified auth key', function() { + describe('When setting with an auth key', () => { + it('Sends the correct request, including the specified auth key', () => { stripe.customers.setMetadata('cus_123', null, TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -367,9 +366,9 @@ describe('Customers Resource', function() { }); }); - describe('Card methods', function() { - describe('retrieveCard', function() { - it('Sends the correct request', function() { + describe('Card methods', () => { + describe('retrieveCard', () => { + it('Sends the correct request', () => { stripe.customers.retrieveCard('cus_123', 'card_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -379,7 +378,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.retrieveCard('cus_123', 'card_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -391,8 +390,8 @@ describe('Customers Resource', function() { }); }); - describe('createCard', function() { - it('Sends the correct request', function() { + describe('createCard', () => { + it('Sends the correct request', () => { stripe.customers.createCard('cus_123', { number: '123456', exp_month: '12', @@ -405,7 +404,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.createCard( 'cus_123', { @@ -424,8 +423,8 @@ describe('Customers Resource', function() { }); }); - describe('updateCard', function() { - it('Sends the correct request', function() { + describe('updateCard', () => { + it('Sends the correct request', () => { stripe.customers.updateCard('cus_123', 'card_123', { name: 'Bob M. Baz', }); @@ -438,8 +437,8 @@ describe('Customers Resource', function() { }); }); - describe('deleteCard', function() { - it('Sends the correct request', function() { + describe('deleteCard', () => { + it('Sends the correct request', () => { stripe.customers.deleteCard('cus_123', 'card_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -449,7 +448,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.deleteCard('cus_123', 'card_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -461,8 +460,8 @@ describe('Customers Resource', function() { }); }); - describe('listCards', function() { - it('Sends the correct request', function() { + describe('listCards', () => { + it('Sends the correct request', () => { stripe.customers.listCards('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -472,7 +471,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.listCards('cus_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -485,9 +484,9 @@ describe('Customers Resource', function() { }); }); - describe('Source methods', function() { - describe('retrieveSource', function() { - it('Sends the correct request', function() { + describe('Source methods', () => { + describe('retrieveSource', () => { + it('Sends the correct request', () => { stripe.customers.retrieveSource('cus_123', 'card_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -497,7 +496,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.retrieveSource('cus_123', 'card_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -509,8 +508,8 @@ describe('Customers Resource', function() { }); }); - describe('createSource', function() { - it('Sends the correct request', function() { + describe('createSource', () => { + it('Sends the correct request', () => { stripe.customers.createSource('cus_123', { object: 'card', number: '123456', @@ -524,7 +523,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.createSource( 'cus_123', { @@ -544,8 +543,8 @@ describe('Customers Resource', function() { }); }); - describe('updateSource', function() { - it('Sends the correct request', function() { + describe('updateSource', () => { + it('Sends the correct request', () => { stripe.customers.updateSource('cus_123', 'card_123', { name: 'Bob M. Baz', }); @@ -558,8 +557,8 @@ describe('Customers Resource', function() { }); }); - describe('deleteSource', function() { - it('Sends the correct request', function() { + describe('deleteSource', () => { + it('Sends the correct request', () => { stripe.customers.deleteSource('cus_123', 'card_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -569,7 +568,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.deleteSource('cus_123', 'card_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -581,8 +580,8 @@ describe('Customers Resource', function() { }); }); - describe('listSources', function() { - it('Sends the correct request', function() { + describe('listSources', () => { + it('Sends the correct request', () => { stripe.customers.listSources('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -592,7 +591,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.listSources('cus_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -604,8 +603,8 @@ describe('Customers Resource', function() { }); }); - describe('verifySource', function() { - it('Sends the correct request', function() { + describe('verifySource', () => { + it('Sends the correct request', () => { var data = {amounts: [32, 45]}; stripe.customers.verifySource( @@ -625,9 +624,9 @@ describe('Customers Resource', function() { }); }); - describe('Subscription methods', function() { - describe('retrieveSubscription', function() { - it('Sends the correct request', function() { + describe('Subscription methods', () => { + describe('retrieveSubscription', () => { + it('Sends the correct request', () => { stripe.customers.retrieveSubscription('cus_123', 'sub_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -637,7 +636,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.retrieveSubscription( 'cus_123', 'sub_123', @@ -653,8 +652,8 @@ describe('Customers Resource', function() { }); }); - describe('createSubscription', function() { - it('Sends the correct request', function() { + describe('createSubscription', () => { + it('Sends the correct request', () => { stripe.customers.createSubscription('cus_123', { plan: 'gold', quantity: '12', @@ -667,7 +666,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.createSubscription( 'cus_123', { @@ -686,8 +685,8 @@ describe('Customers Resource', function() { }); }); - describe('updateSubscription (new-style api)', function() { - it('Sends the correct request', function() { + describe('updateSubscription (new-style api)', () => { + it('Sends the correct request', () => { stripe.customers.updateSubscription('cus_123', 'sub_123', { quantity: '2', }); @@ -699,7 +698,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.updateSubscription( 'cus_123', 'sub_123', @@ -718,8 +717,8 @@ describe('Customers Resource', function() { }); }); - describe('cancelSubscription (new-style api)', function() { - it('Sends the correct request', function() { + describe('cancelSubscription (new-style api)', () => { + it('Sends the correct request', () => { stripe.customers.cancelSubscription('cus_123', 'sub_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -729,7 +728,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.cancelSubscription( 'cus_123', 'sub_123', @@ -744,8 +743,8 @@ describe('Customers Resource', function() { }); }); - describe('With at_period_end defined', function() { - it('Sends the correct request', function() { + describe('With at_period_end defined', () => { + it('Sends the correct request', () => { stripe.customers.cancelSubscription('cus_123', 'sub_123', { at_period_end: true, }); @@ -758,8 +757,8 @@ describe('Customers Resource', function() { }); }); - describe('With at_period_end defined [with specified auth]', function() { - it('Sends the correct request', function() { + describe('With at_period_end defined [with specified auth]', () => { + it('Sends the correct request', () => { stripe.customers.cancelSubscription( 'cus_123', 'sub_123', @@ -777,8 +776,8 @@ describe('Customers Resource', function() { }); }); - describe('listSubscriptions', function() { - it('Sends the correct request', function() { + describe('listSubscriptions', () => { + it('Sends the correct request', () => { stripe.customers.listSubscriptions('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -788,7 +787,7 @@ describe('Customers Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.customers.listSubscriptions('cus_123', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -801,9 +800,9 @@ describe('Customers Resource', function() { }); }); - describe('TaxId methods', function() { - describe('retrieveTaxId', function() { - it('Sends the correct request', function() { + describe('TaxId methods', () => { + describe('retrieveTaxId', () => { + it('Sends the correct request', () => { stripe.customers.retrieveTaxId('cus_123', 'txi_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -814,8 +813,8 @@ describe('Customers Resource', function() { }); }); - describe('createTaxId', function() { - it('Sends the correct request', function() { + describe('createTaxId', () => { + it('Sends the correct request', () => { var data = { type: 'eu_vat', value: '11111', @@ -830,8 +829,8 @@ describe('Customers Resource', function() { }); }); - describe('deleteTaxId', function() { - it('Sends the correct request', function() { + describe('deleteTaxId', () => { + it('Sends the correct request', () => { stripe.customers.deleteTaxId('cus_123', 'txi_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -842,8 +841,8 @@ describe('Customers Resource', function() { }); }); - describe('listTaxIds', function() { - it('Sends the correct request', function() { + describe('listTaxIds', () => { + it('Sends the correct request', () => { stripe.customers.listTaxIds('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Disputes.spec.js b/test/resources/Disputes.spec.js index d227adfe3d..ee06873ab8 100644 --- a/test/resources/Disputes.spec.js +++ b/test/resources/Disputes.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Dispute Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Dispute Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.disputes.retrieve('dp_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Dispute Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.disputes.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('Dispute Resource', function() { }); }); - describe('close', function() { - it('Sends the correct request', function() { + describe('close', () => { + it('Sends the correct request', () => { stripe.disputes.close('dp_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -40,8 +40,8 @@ describe('Dispute Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.disputes.update('dp_123', {evidence: {customer_name: 'Bob'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/EphemeralKeys.spec.js b/test/resources/EphemeralKeys.spec.js index 565a066186..a2f2bc2412 100644 --- a/test/resources/EphemeralKeys.spec.js +++ b/test/resources/EphemeralKeys.spec.js @@ -27,9 +27,9 @@ function sendsCorrectStripeVersion() { }); } -describe('EphemeralKey Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('EphemeralKey Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.ephemeralKeys.create( {customer: 'cus_123'}, {stripe_version: '2017-05-25'} @@ -46,7 +46,7 @@ describe('EphemeralKey Resource', function() { }); }); - describe('when an api version is set', function() { + describe('when an api version is set', () => { beforeEach(function() { this.oldVersion = stripe.getApiField('version'); stripe.setApiVersion('2017-05-25'); @@ -56,16 +56,15 @@ describe('EphemeralKey Resource', function() { stripe.setApiVersion(this.oldVersion); }); - it('Errors if no stripe-version is specified', function() { - return errorsOnNoStripeVersion(); - }); + it('Errors if no stripe-version is specified', () => + errorsOnNoStripeVersion()); - it('Sends the correct stripe-version', function() { + it('Sends the correct stripe-version', () => { sendsCorrectStripeVersion(); }); }); - describe('when no api version is set', function() { + describe('when no api version is set', () => { beforeEach(function() { this.oldVersion = stripe.getApiField('version'); stripe.setApiVersion(null); @@ -75,18 +74,17 @@ describe('EphemeralKey Resource', function() { stripe.setApiVersion(this.oldVersion); }); - it('Errors if no stripe-version is specified', function() { - return errorsOnNoStripeVersion(); - }); + it('Errors if no stripe-version is specified', () => + errorsOnNoStripeVersion()); - it('Sends the correct stripe-version', function() { + it('Sends the correct stripe-version', () => { sendsCorrectStripeVersion(); }); }); }); - describe('delete', function() { - it('Sends the correct request', function() { + describe('delete', () => { + it('Sends the correct request', () => { stripe.ephemeralKeys.del('ephkey_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Events.spec.js b/test/resources/Events.spec.js index c5e77fdfdb..b289c75501 100644 --- a/test/resources/Events.spec.js +++ b/test/resources/Events.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Events Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Events Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.events.retrieve('eventIdBaz'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Events Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.events.list({count: 25}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/ExchangeRates.spec.js b/test/resources/ExchangeRates.spec.js index 9f7108b77f..27597d38c1 100644 --- a/test/resources/ExchangeRates.spec.js +++ b/test/resources/ExchangeRates.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('ExchangeRates Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('ExchangeRates Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.exchangeRates.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('ExchangeRates Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { var currency = 'USD'; stripe.exchangeRates.retrieve(currency); expect(stripe.LAST_REQUEST).to.deep.equal({ diff --git a/test/resources/FileLinks.spec.js b/test/resources/FileLinks.spec.js index 8bf6677b21..b3a93cdabd 100644 --- a/test/resources/FileLinks.spec.js +++ b/test/resources/FileLinks.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('FileLinks Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('FileLinks Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.fileLinks.retrieve('link_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('FileLinks Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.fileLinks.create({file: 'file_123'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -28,8 +28,8 @@ describe('FileLinks Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.fileLinks.update('link_123', {metadata: {key: 'value'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -40,8 +40,8 @@ describe('FileLinks Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.fileLinks.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/FileUploads.spec.js b/test/resources/FileUploads.spec.js index 7cc106e0f5..3c2a8ba995 100644 --- a/test/resources/FileUploads.spec.js +++ b/test/resources/FileUploads.spec.js @@ -7,9 +7,9 @@ var path = require('path'); var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('File Uploads Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('File Uploads Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.fileUploads.retrieve('fil_12345'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -19,7 +19,7 @@ describe('File Uploads Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.fileUploads.retrieve('fil_12345', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -31,8 +31,8 @@ describe('File Uploads Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.fileUploads.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -43,8 +43,8 @@ describe('File Uploads Resource', function() { }); }); - describe('create', function() { - it('Sends the correct file upload request', function() { + describe('create', () => { + it('Sends the correct file upload request', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.readFileSync(testFilename); @@ -63,7 +63,7 @@ describe('File Uploads Resource', function() { expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); }); - it('Sends the correct file upload request [with specified auth]', function() { + it('Sends the correct file upload request [with specified auth]', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.readFileSync(testFilename); @@ -86,7 +86,7 @@ describe('File Uploads Resource', function() { expect(stripe.LAST_REQUEST).to.deep.property('auth', TEST_AUTH_KEY); }); - it('Streams a file and sends the correct file upload request', function() { + it('Streams a file and sends the correct file upload request', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.createReadStream(testFilename); @@ -100,7 +100,7 @@ describe('File Uploads Resource', function() { }, file_link_data: {create: true}, }) - .then(function() { + .then(() => { expect(stripe.LAST_REQUEST).to.deep.property( 'host', 'files.stripe.com' @@ -110,7 +110,7 @@ describe('File Uploads Resource', function() { }); }); - it('Streams a file and sends the correct file upload request [with specified auth]', function() { + it('Streams a file and sends the correct file upload request [with specified auth]', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.createReadStream(testFilename); @@ -127,7 +127,7 @@ describe('File Uploads Resource', function() { }, TEST_AUTH_KEY ) - .then(function() { + .then(() => { expect(stripe.LAST_REQUEST).to.deep.property( 'host', 'files.stripe.com' diff --git a/test/resources/Files.spec.js b/test/resources/Files.spec.js index 280eec92c1..166f9c59ee 100644 --- a/test/resources/Files.spec.js +++ b/test/resources/Files.spec.js @@ -7,9 +7,9 @@ var path = require('path'); var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Files Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Files Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.files.retrieve('fil_12345'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -19,7 +19,7 @@ describe('Files Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.files.retrieve('fil_12345', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -31,8 +31,8 @@ describe('Files Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.files.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -43,8 +43,8 @@ describe('Files Resource', function() { }); }); - describe('create', function() { - it('Sends the correct file upload request', function() { + describe('create', () => { + it('Sends the correct file upload request', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.readFileSync(testFilename); @@ -63,7 +63,7 @@ describe('Files Resource', function() { expect(stripe.LAST_REQUEST).to.deep.property('url', '/v1/files'); }); - it('Sends the correct file upload request [with specified auth]', function() { + it('Sends the correct file upload request [with specified auth]', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.readFileSync(testFilename); @@ -86,7 +86,7 @@ describe('Files Resource', function() { expect(stripe.LAST_REQUEST).to.deep.property('auth', TEST_AUTH_KEY); }); - it('Streams a file and sends the correct file upload request', function() { + it('Streams a file and sends the correct file upload request', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.createReadStream(testFilename); @@ -100,7 +100,7 @@ describe('Files Resource', function() { }, file_link_data: {create: true}, }) - .then(function() { + .then(() => { expect(stripe.LAST_REQUEST).to.deep.property( 'host', 'files.stripe.com' @@ -110,7 +110,7 @@ describe('Files Resource', function() { }); }); - it('Streams a file and sends the correct file upload request [with specified auth]', function() { + it('Streams a file and sends the correct file upload request [with specified auth]', () => { var testFilename = path.join(__dirname, 'data/minimal.pdf'); var f = fs.createReadStream(testFilename); @@ -127,7 +127,7 @@ describe('Files Resource', function() { }, TEST_AUTH_KEY ) - .then(function() { + .then(() => { expect(stripe.LAST_REQUEST).to.deep.property( 'host', 'files.stripe.com' diff --git a/test/resources/InvoiceItems.spec.js b/test/resources/InvoiceItems.spec.js index 6a6352968a..f349ecf323 100644 --- a/test/resources/InvoiceItems.spec.js +++ b/test/resources/InvoiceItems.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('InvoiceItems Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('InvoiceItems Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.invoiceItems.retrieve('invoiceItemIdTesting123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.invoiceItems.create({ customer: 'cust_id_888', }); @@ -30,8 +30,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.invoiceItems.update('invoiceItemId1', { amount: 1900, }); @@ -44,8 +44,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.invoiceItems.del('invoiceItemId2'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -56,8 +56,8 @@ describe('InvoiceItems Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.invoiceItems.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Invoices.spec.js b/test/resources/Invoices.spec.js index cfd8657b2d..6948dab63f 100644 --- a/test/resources/Invoices.spec.js +++ b/test/resources/Invoices.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Invoices Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Invoices Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.invoices.retrieve('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Invoices Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.invoices.create({application_fee: 111}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -28,8 +28,8 @@ describe('Invoices Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.invoices.list({count: 25}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -40,8 +40,8 @@ describe('Invoices Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.invoices.update('in_123', {application_fee: 200}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -52,8 +52,8 @@ describe('Invoices Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.invoices.del('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -64,8 +64,8 @@ describe('Invoices Resource', function() { }); }); - describe('retrieveLines', function() { - it('Sends the correct request', function() { + describe('retrieveLines', () => { + it('Sends the correct request', () => { stripe.invoices.retrieveLines('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -76,9 +76,9 @@ describe('Invoices Resource', function() { }); }); - describe('retrieveUpcoming', function() { - describe('With just a customer ID', function() { - it('Sends the correct request', function() { + describe('retrieveUpcoming', () => { + describe('With just a customer ID', () => { + it('Sends the correct request', () => { stripe.invoices.retrieveUpcoming('cus_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -89,8 +89,8 @@ describe('Invoices Resource', function() { }); }); - describe('With a subscription ID in addition to a customer ID', function() { - it('Sends the correct request', function() { + describe('With a subscription ID in addition to a customer ID', () => { + it('Sends the correct request', () => { stripe.invoices.retrieveUpcoming('cus_123', 'sub_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -101,8 +101,8 @@ describe('Invoices Resource', function() { }); }); - describe('With an options object that includes `subscription_items`', function() { - it('Sends the correct request', function() { + describe('With an options object that includes `subscription_items`', () => { + it('Sends the correct request', () => { stripe.invoices.retrieveUpcoming('cus_123', { subscription_items: [{plan: 'potato'}, {plan: 'rutabaga'}], }); @@ -118,8 +118,8 @@ describe('Invoices Resource', function() { }); }); - describe('Without a customer id but options', function() { - it('Sends the correct request', function() { + describe('Without a customer id but options', () => { + it('Sends the correct request', () => { stripe.invoices.retrieveUpcoming({ customer: 'cus_abc', subscription_items: [{plan: 'potato'}, {plan: 'rutabaga'}], @@ -136,8 +136,8 @@ describe('Invoices Resource', function() { }); }); - describe('With an options object that includes `subscription_items` in addition to a subscription ID', function() { - it('Sends the correct request', function() { + describe('With an options object that includes `subscription_items` in addition to a subscription ID', () => { + it('Sends the correct request', () => { stripe.invoices.retrieveUpcoming('cus_123', 'sub_123', { subscription_items: [ {plan: 'potato'}, @@ -163,8 +163,8 @@ describe('Invoices Resource', function() { }); }); - describe('With a options object in addition to a customer ID', function() { - it('Sends the correct request', function() { + describe('With a options object in addition to a customer ID', () => { + it('Sends the correct request', () => { stripe.invoices.retrieveUpcoming('cus_123', {plan: 'planId123'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -176,8 +176,8 @@ describe('Invoices Resource', function() { }); }); - describe('finalizeInvoice', function() { - it('Sends the correct request', function() { + describe('finalizeInvoice', () => { + it('Sends the correct request', () => { stripe.invoices.finalizeInvoice('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -188,8 +188,8 @@ describe('Invoices Resource', function() { }); }); - describe('mark uncollectible', function() { - it('Sends the correct request', function() { + describe('mark uncollectible', () => { + it('Sends the correct request', () => { stripe.invoices.markUncollectible('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -200,8 +200,8 @@ describe('Invoices Resource', function() { }); }); - describe('pay', function() { - it('Sends the correct request', function() { + describe('pay', () => { + it('Sends the correct request', () => { stripe.invoices.pay('in_123', { source: 'tok_FooBar', }); @@ -214,8 +214,8 @@ describe('Invoices Resource', function() { }); }); - describe('sendInvoice', function() { - it('Sends the correct request', function() { + describe('sendInvoice', () => { + it('Sends the correct request', () => { stripe.invoices.sendInvoice('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -226,8 +226,8 @@ describe('Invoices Resource', function() { }); }); - describe('voidInvoice', function() { - it('Sends the correct request', function() { + describe('voidInvoice', () => { + it('Sends the correct request', () => { stripe.invoices.voidInvoice('in_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/IssuerFraudRecords.spec.js b/test/resources/IssuerFraudRecords.spec.js index 46842348c7..2021c9900a 100644 --- a/test/resources/IssuerFraudRecords.spec.js +++ b/test/resources/IssuerFraudRecords.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('IssuerFraudRecord Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('IssuerFraudRecord Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuerFraudRecords.retrieve('issfr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('IssuerFraudRecord Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuerFraudRecords.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Issuing/Authorization.spec.js b/test/resources/Issuing/Authorization.spec.js index bb3e3d5d01..4cca47093e 100644 --- a/test/resources/Issuing/Authorization.spec.js +++ b/test/resources/Issuing/Authorization.spec.js @@ -3,10 +3,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Issuing', function() { - describe('Authorization Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Issuing', () => { + describe('Authorization Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.retrieve('iauth_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -17,8 +17,8 @@ describe('Issuing', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -29,8 +29,8 @@ describe('Issuing', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.update('iauth_123', { metadata: { thing1: true, @@ -51,8 +51,8 @@ describe('Issuing', function() { }); }); - describe('approve', function() { - it('Sends the correct request', function() { + describe('approve', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.approve('iauth_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -63,8 +63,8 @@ describe('Issuing', function() { }); }); - describe('decline', function() { - it('Sends the correct request', function() { + describe('decline', () => { + it('Sends the correct request', () => { stripe.issuing.authorizations.decline('iauth_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Issuing/Cardholders.spec.js b/test/resources/Issuing/Cardholders.spec.js index 646e735c40..5ab1d3c64d 100644 --- a/test/resources/Issuing/Cardholders.spec.js +++ b/test/resources/Issuing/Cardholders.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Issuing', function() { - describe('Cardholders Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Issuing', () => { + describe('Cardholders Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.retrieve('ich_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Issuing', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.create({ billing: {}, name: 'Tim Testperson', @@ -39,8 +39,8 @@ describe('Issuing', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.update('ich_123', { metadata: { thing1: true, @@ -61,8 +61,8 @@ describe('Issuing', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.cardholders.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Issuing/Cards.spec.js b/test/resources/Issuing/Cards.spec.js index 90e8111ff3..064bd20070 100644 --- a/test/resources/Issuing/Cards.spec.js +++ b/test/resources/Issuing/Cards.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Issuing', function() { - describe('Cards Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Issuing', () => { + describe('Cards Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.cards.retrieve('ic_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Issuing', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.issuing.cards.create({ currency: 'usd', type: 'physical', @@ -37,8 +37,8 @@ describe('Issuing', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.cards.update('ic_123', { metadata: { thing1: true, @@ -59,8 +59,8 @@ describe('Issuing', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.cards.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -72,9 +72,9 @@ describe('Issuing', function() { }); }); - describe('Virtual Cards Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('Virtual Cards Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.cards.retrieveDetails('ic_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ diff --git a/test/resources/Issuing/Disputes.spec.js b/test/resources/Issuing/Disputes.spec.js index 2af1f0cd43..f65437675e 100644 --- a/test/resources/Issuing/Disputes.spec.js +++ b/test/resources/Issuing/Disputes.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Issuing', function() { - describe('Disputes Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Issuing', () => { + describe('Disputes Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.retrieve('idp_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Issuing', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.create({ transaction: 'ipi_123', }); @@ -35,8 +35,8 @@ describe('Issuing', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.update('idp_123', { metadata: { thing1: true, @@ -57,8 +57,8 @@ describe('Issuing', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.disputes.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Issuing/Transactions.spec.js b/test/resources/Issuing/Transactions.spec.js index 89e6ffac5f..342f91d6ac 100644 --- a/test/resources/Issuing/Transactions.spec.js +++ b/test/resources/Issuing/Transactions.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Issuing', function() { - describe('Transactions Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Issuing', () => { + describe('Transactions Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.issuing.transactions.retrieve('ipi_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Issuing', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.issuing.transactions.update('ipi_123', { metadata: { thing1: true, @@ -41,8 +41,8 @@ describe('Issuing', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.issuing.transactions.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/LoginLinks.spec.js b/test/resources/LoginLinks.spec.js index f46361259a..5779a65f76 100644 --- a/test/resources/LoginLinks.spec.js +++ b/test/resources/LoginLinks.spec.js @@ -12,9 +12,9 @@ var loginLink = new resources.LoginLinks(stripe, {accountId: ACCOUNT_ID}); // Use spy from existing resource: loginLink._request = stripe.customers._request; -describe('LoginLink Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('LoginLink Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { loginLink.create(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/OAuth.spec.js b/test/resources/OAuth.spec.js index 7db3345309..00562bbc46 100644 --- a/test/resources/OAuth.spec.js +++ b/test/resources/OAuth.spec.js @@ -6,14 +6,14 @@ var expect = require('chai').expect; var URL = require('url'); var qs = require('qs'); -describe('OAuth', function() { - describe('authorize', function() { - describe('when a default client_id is set', function() { - beforeEach(function() { +describe('OAuth', () => { + describe('authorize', () => { + describe('when a default client_id is set', () => { + beforeEach(() => { stripe.setClientId('default_client_id'); }); - it('Uses the correct host', function() { + it('Uses the correct host', () => { var url = stripe.oauth.authorizeUrl(); var host = URL.parse(url).hostname; @@ -21,7 +21,7 @@ describe('OAuth', function() { expect(host).to.equal('connect.stripe.com'); }); - it('Uses the correct path', function() { + it('Uses the correct path', () => { var url = stripe.oauth.authorizeUrl({state: 'some_state'}); var pathname = URL.parse(url).pathname; @@ -29,7 +29,7 @@ describe('OAuth', function() { expect(pathname).to.equal('/oauth/authorize'); }); - it('Uses the correct query', function() { + it('Uses the correct query', () => { var url = stripe.oauth.authorizeUrl({state: 'some_state'}); var query = qs.parse(URL.parse(url).query); @@ -40,7 +40,7 @@ describe('OAuth', function() { expect(query.state).to.equal('some_state'); }); - it('Uses a provided client_id instead of the default', function() { + it('Uses a provided client_id instead of the default', () => { var url = stripe.oauth.authorizeUrl({client_id: '123abc'}); var query = qs.parse(URL.parse(url).query); @@ -48,8 +48,8 @@ describe('OAuth', function() { expect(query.client_id).to.equal('123abc'); }); - describe('for Express account', function() { - it('Uses the correct path', function() { + describe('for Express account', () => { + it('Uses the correct path', () => { var url = stripe.oauth.authorizeUrl({}, {express: true}); var pathname = URL.parse(url).pathname; @@ -60,8 +60,8 @@ describe('OAuth', function() { }); }); - describe('token', function() { - it('Sends the correct request', function() { + describe('token', () => { + it('Sends the correct request', () => { stripe.oauth.token({ code: '123abc', grant_type: 'authorization_code', @@ -80,12 +80,12 @@ describe('OAuth', function() { }); }); - describe('deauthorize', function() { - beforeEach(function() { + describe('deauthorize', () => { + beforeEach(() => { stripe.setClientId('default_client_id'); }); - it('Sends the correct request without explicit client_id', function() { + it('Sends the correct request without explicit client_id', () => { stripe.oauth.deauthorize({ stripe_user_id: 'some_user_id', }); @@ -102,7 +102,7 @@ describe('OAuth', function() { }); }); - it('Sends the correct request with explicit client_id', function() { + it('Sends the correct request with explicit client_id', () => { stripe.oauth.deauthorize({ stripe_user_id: 'some_user_id', client_id: '123abc', diff --git a/test/resources/OrderReturns.spec.js b/test/resources/OrderReturns.spec.js index 2dff709fe9..b46b562c41 100644 --- a/test/resources/OrderReturns.spec.js +++ b/test/resources/OrderReturns.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('OrderReturn Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('OrderReturn Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.orderReturns.retrieve('orderReturnIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('OrderReturn Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.orderReturns.list({ limit: 3, }); @@ -31,7 +31,7 @@ describe('OrderReturn Resource', function() { }); }); - it('Supports filtering by order', function() { + it('Supports filtering by order', () => { stripe.orderReturns.list({ order: 'orderIdFoo123', }); diff --git a/test/resources/Orders.spec.js b/test/resources/Orders.spec.js index d0d05de51c..1776582ef2 100644 --- a/test/resources/Orders.spec.js +++ b/test/resources/Orders.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Order Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Order Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.orders.retrieve('orderIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Order Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.orders.create({ currency: 'usd', items: [ @@ -58,8 +58,8 @@ describe('Order Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.orders.list({ limit: 3, }); @@ -73,7 +73,7 @@ describe('Order Resource', function() { }); }); - it('Supports filtering by status', function() { + it('Supports filtering by status', () => { stripe.orders.list({ status: 'active', }); @@ -88,8 +88,8 @@ describe('Order Resource', function() { }); }); - describe('pay', function() { - it('Sends the correct request', function() { + describe('pay', () => { + it('Sends the correct request', () => { stripe.orders.pay('orderIdFoo3242', { source: 'tok_FooBar', }); @@ -102,8 +102,8 @@ describe('Order Resource', function() { }); }); - describe('returnOrder', function() { - it('Sends the correct request', function() { + describe('returnOrder', () => { + it('Sends the correct request', () => { stripe.orders.returnOrder('orderIdFoo3242', { items: [{parent: 'sku_123'}], }); @@ -116,8 +116,8 @@ describe('Order Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.orders.update('orderIdFoo3242', {status: 'fulfilled'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/PaymentIntents.spec.js b/test/resources/PaymentIntents.spec.js index 81f8f2c639..6ccff939d6 100644 --- a/test/resources/PaymentIntents.spec.js +++ b/test/resources/PaymentIntents.spec.js @@ -5,9 +5,9 @@ var expect = require('chai').expect; var PAYMENT_INTENT_TEST_ID = 'pi_123'; -describe('Payment Intents Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Payment Intents Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { var params = { amount: 200, currency: 'usd', @@ -23,8 +23,8 @@ describe('Payment Intents Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.paymentIntents.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -35,8 +35,8 @@ describe('Payment Intents Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.paymentIntents.retrieve(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -47,8 +47,8 @@ describe('Payment Intents Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.paymentIntents.update(PAYMENT_INTENT_TEST_ID, { metadata: {key: 'value'}, }); @@ -61,8 +61,8 @@ describe('Payment Intents Resource', function() { }); }); - describe('cancel', function() { - it('Sends the correct request', function() { + describe('cancel', () => { + it('Sends the correct request', () => { stripe.paymentIntents.cancel(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -73,8 +73,8 @@ describe('Payment Intents Resource', function() { }); }); - describe('capture', function() { - it('Sends the correct request', function() { + describe('capture', () => { + it('Sends the correct request', () => { stripe.paymentIntents.capture(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -85,8 +85,8 @@ describe('Payment Intents Resource', function() { }); }); - describe('confirm', function() { - it('Sends the correct request', function() { + describe('confirm', () => { + it('Sends the correct request', () => { stripe.paymentIntents.confirm(PAYMENT_INTENT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/PaymentMethods.spec.js b/test/resources/PaymentMethods.spec.js index bc395521db..128151874a 100644 --- a/test/resources/PaymentMethods.spec.js +++ b/test/resources/PaymentMethods.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('PaymentMethods Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('PaymentMethods Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.paymentMethods.retrieve('pm_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('PaymentMethods Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { var data = { type: 'card', }; @@ -31,8 +31,8 @@ describe('PaymentMethods Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { var data = { customer: 'cus_123', type: 'card', @@ -47,8 +47,8 @@ describe('PaymentMethods Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { var data = { metadata: {key: 'value'}, }; @@ -62,8 +62,8 @@ describe('PaymentMethods Resource', function() { }); }); - describe('attach', function() { - it('Sends the correct request', function() { + describe('attach', () => { + it('Sends the correct request', () => { stripe.paymentMethods.attach('pm_123', {customer: 'cus_123'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -74,8 +74,8 @@ describe('PaymentMethods Resource', function() { }); }); - describe('detach', function() { - it('Sends the correct request', function() { + describe('detach', () => { + it('Sends the correct request', () => { stripe.paymentMethods.detach('pm_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Payouts.spec.js b/test/resources/Payouts.spec.js index 8b19252a64..4abfd78e6f 100644 --- a/test/resources/Payouts.spec.js +++ b/test/resources/Payouts.spec.js @@ -5,9 +5,9 @@ var expect = require('chai').expect; var PAYOUT_TEST_ID = 'po_testid1'; -describe('Payouts Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Payouts Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.payouts.retrieve(PAYOUT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -18,8 +18,8 @@ describe('Payouts Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.payouts.create({ amount: 200, currency: 'usd', @@ -33,8 +33,8 @@ describe('Payouts Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.payouts.update(PAYOUT_TEST_ID, { metadata: {key: 'value'}, }); @@ -47,8 +47,8 @@ describe('Payouts Resource', function() { }); }); - describe('cancel', function() { - it('Sends the correct request', function() { + describe('cancel', () => { + it('Sends the correct request', () => { stripe.payouts.cancel(PAYOUT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -59,8 +59,8 @@ describe('Payouts Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.payouts.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -71,8 +71,8 @@ describe('Payouts Resource', function() { }); }); - describe('listTransactions', function() { - it('Sends the correct request', function() { + describe('listTransactions', () => { + it('Sends the correct request', () => { stripe.payouts.listTransactions(PAYOUT_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Persons.spec.js b/test/resources/Persons.spec.js index 8d7112dbce..6db7c29c49 100644 --- a/test/resources/Persons.spec.js +++ b/test/resources/Persons.spec.js @@ -13,9 +13,9 @@ var person = new resources.Persons(stripe, {accountId: ACCOUNT_TEST_ID}); // Use spy from existing resource: person._request = stripe.customers._request; -describe('Person Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Person Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { person.create({ first_name: 'John', }); @@ -28,8 +28,8 @@ describe('Person Resource', function() { }); }); - describe('delete', function() { - it('Sends the correct request', function() { + describe('delete', () => { + it('Sends the correct request', () => { person.del(PERSON_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -40,8 +40,8 @@ describe('Person Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { person.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -52,8 +52,8 @@ describe('Person Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { person.retrieve(PERSON_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -64,8 +64,8 @@ describe('Person Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { person.update(PERSON_TEST_ID, { first_name: 'John', }); diff --git a/test/resources/Plans.spec.js b/test/resources/Plans.spec.js index 6468c95f46..b9bbd8325f 100644 --- a/test/resources/Plans.spec.js +++ b/test/resources/Plans.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Plans Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Plans Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.plans.retrieve('planId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Plans Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.plans.create({ amount: 200, currency: 'usd', @@ -30,7 +30,7 @@ describe('Plans Resource', function() { }); }); - it('Sends the correct request for metered', function() { + it('Sends the correct request for metered', () => { stripe.plans.create({ amount: 200, currency: 'usd', @@ -44,7 +44,7 @@ describe('Plans Resource', function() { }); }); - it('Sends the correct request for tiered plans', function() { + it('Sends the correct request for tiered plans', () => { stripe.plans.create({ currency: 'usd', billing_scheme: 'tiered', @@ -64,7 +64,7 @@ describe('Plans Resource', function() { }); }); - it('Sends the correct request for transform usage plans', function() { + it('Sends the correct request for transform usage plans', () => { stripe.plans.create({ amount: 200, currency: 'usd', @@ -83,8 +83,8 @@ describe('Plans Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.plans.update('planId3', { amount: 1900, currency: 'usd', @@ -98,8 +98,8 @@ describe('Plans Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.plans.del('planId4'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -110,8 +110,8 @@ describe('Plans Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.plans.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Products.spec.js b/test/resources/Products.spec.js index 9efb4ec49e..7c1aa18391 100644 --- a/test/resources/Products.spec.js +++ b/test/resources/Products.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Product Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Product Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.products.retrieve('productIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Product Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.products.create({ name: 'Llamas', active: true, @@ -36,8 +36,8 @@ describe('Product Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.products.list({ limit: 3, }); @@ -51,7 +51,7 @@ describe('Product Resource', function() { }); }); - it('Supports filtering by shippable', function() { + it('Supports filtering by shippable', () => { stripe.products.list({ shippable: true, }); @@ -66,8 +66,8 @@ describe('Product Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.products.update('productIdFoo3242', {caption: 'test'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -78,8 +78,8 @@ describe('Product Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.products.del('productIdFoo3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Radar/ValueListItems.spec.js b/test/resources/Radar/ValueListItems.spec.js index ee414a1e77..5d2ceefb8d 100644 --- a/test/resources/Radar/ValueListItems.spec.js +++ b/test/resources/Radar/ValueListItems.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Radar', function() { - describe('ValueLists Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Radar', () => { + describe('ValueLists Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.retrieve('rsli_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Radar', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.create({ value_list: 'rsl_123', value: 'value', @@ -37,8 +37,8 @@ describe('Radar', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.list({ value_list: 'rsl_123', }); @@ -53,8 +53,8 @@ describe('Radar', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.radar.valueListItems.del('rsli_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Radar/ValueLists.spec.js b/test/resources/Radar/ValueLists.spec.js index 1acaf6dc53..341752029d 100644 --- a/test/resources/Radar/ValueLists.spec.js +++ b/test/resources/Radar/ValueLists.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Radar', function() { - describe('ValueLists Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Radar', () => { + describe('ValueLists Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.retrieve('rsl_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Radar', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.create({ alias: 'alias', name: 'name', @@ -37,8 +37,8 @@ describe('Radar', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -49,8 +49,8 @@ describe('Radar', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.del('rsl_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -61,8 +61,8 @@ describe('Radar', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.radar.valueLists.update('rsl_123', { metadata: {a: '1234'}, }); diff --git a/test/resources/RecipientCards.spec.js b/test/resources/RecipientCards.spec.js index abd4007442..54f02b58ef 100644 --- a/test/resources/RecipientCards.spec.js +++ b/test/resources/RecipientCards.spec.js @@ -14,9 +14,9 @@ var recipientCard = new resources.RecipientCards(stripe, { // Use spy from existing resource: recipientCard._request = stripe.recipients._request; -describe('RecipientCard Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('RecipientCard Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { recipientCard.retrieve('cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -27,8 +27,8 @@ describe('RecipientCard Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { recipientCard.create({ number: '123456', exp_month: '12', @@ -42,8 +42,8 @@ describe('RecipientCard Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { recipientCard.update('cardIdFoo456', { name: 'Bob M. Baz', }); @@ -56,8 +56,8 @@ describe('RecipientCard Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { recipientCard.del('cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -68,8 +68,8 @@ describe('RecipientCard Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { recipientCard.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Recipients.spec.js b/test/resources/Recipients.spec.js index 3c428b1ff5..1323679c06 100644 --- a/test/resources/Recipients.spec.js +++ b/test/resources/Recipients.spec.js @@ -5,9 +5,9 @@ var expect = require('chai').expect; var TEST_AUTH_KEY = 'aGN0bIwXnHdw5645VABjPdSn8nWY7G11'; -describe('Recipients Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Recipients Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.recipients.retrieve('recipientId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -18,8 +18,8 @@ describe('Recipients Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.recipients.create({ name: 'Bob', type: 'individual', @@ -33,8 +33,8 @@ describe('Recipients Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.recipients.update('recipientId3', { name: 'Bob Smith', }); @@ -47,8 +47,8 @@ describe('Recipients Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.recipients.del('recipientId4'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -59,8 +59,8 @@ describe('Recipients Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.recipients.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -71,9 +71,9 @@ describe('Recipients Resource', function() { }); }); - describe('Card methods', function() { - describe('retrieveCard', function() { - it('Sends the correct request', function() { + describe('Card methods', () => { + describe('retrieveCard', () => { + it('Sends the correct request', () => { stripe.recipients.retrieveCard('recipientIdFoo321', 'cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -83,7 +83,7 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.recipients.retrieveCard( 'recipientIdFoo321', 'cardIdFoo456', @@ -99,8 +99,8 @@ describe('Recipients Resource', function() { }); }); - describe('createCard', function() { - it('Sends the correct request', function() { + describe('createCard', () => { + it('Sends the correct request', () => { stripe.recipients.createCard('recipientIdFoo321', { number: '123456', exp_month: '12', @@ -113,7 +113,7 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.recipients.createCard( 'recipientIdFoo321', { @@ -132,8 +132,8 @@ describe('Recipients Resource', function() { }); }); - describe('updateCard', function() { - it('Sends the correct request', function() { + describe('updateCard', () => { + it('Sends the correct request', () => { stripe.recipients.updateCard('recipientIdFoo321', 'cardIdFoo456', { name: 'Bob M. Baz', }); @@ -146,8 +146,8 @@ describe('Recipients Resource', function() { }); }); - describe('deleteCard', function() { - it('Sends the correct request', function() { + describe('deleteCard', () => { + it('Sends the correct request', () => { stripe.recipients.deleteCard('recipientIdFoo321', 'cardIdFoo456'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -157,7 +157,7 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.recipients.deleteCard( 'recipientIdFoo321', 'cardIdFoo456', @@ -173,8 +173,8 @@ describe('Recipients Resource', function() { }); }); - describe('listCards', function() { - it('Sends the correct request', function() { + describe('listCards', () => { + it('Sends the correct request', () => { stripe.recipients.listCards('recipientIdFoo321'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -184,7 +184,7 @@ describe('Recipients Resource', function() { }); }); - it('Sends the correct request [with specified auth]', function() { + it('Sends the correct request [with specified auth]', () => { stripe.recipients.listCards('recipientIdFoo321', TEST_AUTH_KEY); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Refunds.spec.js b/test/resources/Refunds.spec.js index fd8a32b104..d535a4be55 100644 --- a/test/resources/Refunds.spec.js +++ b/test/resources/Refunds.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Refund Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Refund Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.refunds.create({ amount: '300', charge: 'ch_123', @@ -23,8 +23,8 @@ describe('Refund Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.refunds.retrieve('re_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -35,8 +35,8 @@ describe('Refund Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.refunds.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -47,8 +47,8 @@ describe('Refund Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.refunds.update('re_123', {metadata: {key: 'abcd'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Reporting/ReportRuns.spec.js b/test/resources/Reporting/ReportRuns.spec.js index a9f04c6692..655c691938 100644 --- a/test/resources/Reporting/ReportRuns.spec.js +++ b/test/resources/Reporting/ReportRuns.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Reporting', function() { - describe('ReportRuns Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Reporting', () => { + describe('ReportRuns Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.reporting.reportRuns.retrieve('frr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Reporting', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.reporting.reportRuns.create({ parameters: { connected_account: 'acct_123', @@ -41,8 +41,8 @@ describe('Reporting', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.reporting.reportRuns.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Reporting/ReportTypes.spec.js b/test/resources/Reporting/ReportTypes.spec.js index a13c2db4b3..cde91fb0b6 100644 --- a/test/resources/Reporting/ReportTypes.spec.js +++ b/test/resources/Reporting/ReportTypes.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Reporting', function() { - describe('ReportTypes Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Reporting', () => { + describe('ReportTypes Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.reporting.reportTypes.retrieve('activity.summary.1'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Reporting', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.reporting.reportTypes.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Reviews.spec.js b/test/resources/Reviews.spec.js index 850473afec..cdaf990215 100644 --- a/test/resources/Reviews.spec.js +++ b/test/resources/Reviews.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Review Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Review Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.reviews.retrieve('prv_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Review Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.reviews.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('Review Resource', function() { }); }); - describe('approve', function() { - it('Sends the correct request', function() { + describe('approve', () => { + it('Sends the correct request', () => { stripe.reviews.approve('prv_123', {amount: 23}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/SKUs.spec.js b/test/resources/SKUs.spec.js index fc9d1f27e7..0ced2630fb 100644 --- a/test/resources/SKUs.spec.js +++ b/test/resources/SKUs.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('SKU Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('SKU Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.skus.retrieve('skuIdFoo123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('SKU Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.skus.create({ currency: 'usd', inventory: {type: 'finite', quantity: 500}, @@ -40,8 +40,8 @@ describe('SKU Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.skus.list({ limit: 3, }); @@ -55,7 +55,7 @@ describe('SKU Resource', function() { }); }); - it('Supports filtering by product', function() { + it('Supports filtering by product', () => { stripe.skus.list({ product: 'prodId123', }); @@ -70,8 +70,8 @@ describe('SKU Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.skus.update('skuIdFoo3242', {caption: 'test'}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -82,8 +82,8 @@ describe('SKU Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.skus.del('skuIdFoo3242'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/Sigma/ScheduledQueryRuns.spec.js b/test/resources/Sigma/ScheduledQueryRuns.spec.js index 857fee694e..585ed856a4 100644 --- a/test/resources/Sigma/ScheduledQueryRuns.spec.js +++ b/test/resources/Sigma/ScheduledQueryRuns.spec.js @@ -3,10 +3,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Sigma', function() { - describe('ScheduledQueryRun Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Sigma', () => { + describe('ScheduledQueryRun Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.sigma.scheduledQueryRuns.retrieve('sqr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -17,8 +17,8 @@ describe('Sigma', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.sigma.scheduledQueryRuns.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Sources.spec.js b/test/resources/Sources.spec.js index 51d7111539..2e54d088ac 100644 --- a/test/resources/Sources.spec.js +++ b/test/resources/Sources.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Sources Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Sources Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.sources.retrieve('sourceId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Sources Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.sources.create({ amount: 200, currency: 'usd', @@ -46,8 +46,8 @@ describe('Sources Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.sources.update('src_foo', { metadata: {foo: 'bar'}, }); @@ -60,8 +60,8 @@ describe('Sources Resource', function() { }); }); - describe('listSourceTransactions', function() { - it('Sends the correct request', function() { + describe('listSourceTransactions', () => { + it('Sends the correct request', () => { stripe.sources.listSourceTransactions('src_foo'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -72,8 +72,8 @@ describe('Sources Resource', function() { }); }); - describe('verify', function() { - it('Sends the correct request', function() { + describe('verify', () => { + it('Sends the correct request', () => { stripe.sources.verify('src_foo', {values: [32, 45]}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/SubscriptionItems.spec.js b/test/resources/SubscriptionItems.spec.js index 76b1c598b3..b86319d5b3 100644 --- a/test/resources/SubscriptionItems.spec.js +++ b/test/resources/SubscriptionItems.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('SubscriptionItems Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('SubscriptionItems Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.retrieve('test_sub_item'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.del('test_sub_item'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.update('test_sub_item', { plan: 'gold', }); @@ -44,8 +44,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.create({ subscription: 'test_sub', plan: 'gold', @@ -63,8 +63,8 @@ describe('SubscriptionItems Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.subscriptionItems.list({ limit: 3, subscription: 'test_sub', diff --git a/test/resources/SubscriptionSchedule.spec.js b/test/resources/SubscriptionSchedule.spec.js index 9e07b182a2..8334c1ae40 100644 --- a/test/resources/SubscriptionSchedule.spec.js +++ b/test/resources/SubscriptionSchedule.spec.js @@ -6,9 +6,9 @@ var expect = require('chai').expect; var SCHEDULE_TEST_ID = 'sub_sched_123'; var REVISION_TEST_ID = 'sub_sched_rev_123'; -describe('Subscription Schedule Resource', function() { - describe('cancel', function() { - it('Sends the correct request', function() { +describe('Subscription Schedule Resource', () => { + describe('cancel', () => { + it('Sends the correct request', () => { var data = { invoice_now: true, }; @@ -22,8 +22,8 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { var data = { customer: 'cus_123', }; @@ -37,8 +37,8 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.subscriptionSchedules.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -49,8 +49,8 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('release', function() { - it('Sends the correct request', function() { + describe('release', () => { + it('Sends the correct request', () => { var data = { preserve_cancel_date: true, }; @@ -64,8 +64,8 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.subscriptionSchedules.retrieve(SCHEDULE_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -76,8 +76,8 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { var data = {metadata: {key: 'value'}}; stripe.subscriptionSchedules.update(SCHEDULE_TEST_ID, data); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -89,9 +89,9 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('Revision methods', function() { - describe('retrieveRevision', function() { - it('Sends the correct request', function() { + describe('Revision methods', () => { + describe('retrieveRevision', () => { + it('Sends the correct request', () => { stripe.subscriptionSchedules.retrieveRevision( SCHEDULE_TEST_ID, REVISION_TEST_ID @@ -109,8 +109,8 @@ describe('Subscription Schedule Resource', function() { }); }); - describe('listRevisions', function() { - it('Sends the correct request', function() { + describe('listRevisions', () => { + it('Sends the correct request', () => { stripe.subscriptionSchedules.listRevisions(SCHEDULE_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/SubscriptionScheduleRevision.spec.js b/test/resources/SubscriptionScheduleRevision.spec.js index 58adf867cf..4eb7454096 100644 --- a/test/resources/SubscriptionScheduleRevision.spec.js +++ b/test/resources/SubscriptionScheduleRevision.spec.js @@ -15,9 +15,9 @@ var revision = new resources.SubscriptionScheduleRevisions(stripe, { // Use spy from existing resource: revision._request = stripe.customers._request; -describe('SubscriptionScheduleRevision Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('SubscriptionScheduleRevision Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { revision.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -28,8 +28,8 @@ describe('SubscriptionScheduleRevision Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { revision.retrieve(REVISION_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Subscriptions.spec.js b/test/resources/Subscriptions.spec.js index 31b1e876f5..f038275f58 100644 --- a/test/resources/Subscriptions.spec.js +++ b/test/resources/Subscriptions.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('subscriptions Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('subscriptions Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.subscriptions.retrieve('test_sub'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('subscriptions Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.subscriptions.del('test_sub'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('subscriptions Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.subscriptions.update('test_sub', { metadata: {a: '1234'}, }); @@ -44,8 +44,8 @@ describe('subscriptions Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.subscriptions.create({ customer: 'test_cus', plan: 'gold', @@ -63,8 +63,8 @@ describe('subscriptions Resource', function() { }); }); - describe('update with items array', function() { - it('Sends the correct request', function() { + describe('update with items array', () => { + it('Sends the correct request', () => { stripe.subscriptions.update('test_sub', { items: [ { @@ -89,8 +89,8 @@ describe('subscriptions Resource', function() { }); }); - describe('create with items array', function() { - it('Sends the correct request', function() { + describe('create with items array', () => { + it('Sends the correct request', () => { stripe.subscriptions.create({ items: [ { @@ -116,8 +116,8 @@ describe('subscriptions Resource', function() { }); }); - describe('update with items object', function() { - it('Sends the correct request', function() { + describe('update with items object', () => { + it('Sends the correct request', () => { stripe.subscriptions.update('test_sub', { items: { '0': { @@ -142,8 +142,8 @@ describe('subscriptions Resource', function() { }); }); - describe('create with items object', function() { - it('Sends the correct request', function() { + describe('create with items object', () => { + it('Sends the correct request', () => { stripe.subscriptions.create({ items: { '0': { @@ -169,8 +169,8 @@ describe('subscriptions Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.subscriptions.list({ limit: 3, customer: 'test_cus', @@ -189,9 +189,9 @@ describe('subscriptions Resource', function() { }); }); - describe('Discount methods', function() { - describe('deleteDiscount', function() { - it('Sends the correct request', function() { + describe('Discount methods', () => { + describe('deleteDiscount', () => { + it('Sends the correct request', () => { stripe.subscriptions.deleteDiscount('test_sub'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', diff --git a/test/resources/TaxIds.spec.js b/test/resources/TaxIds.spec.js index 773400e030..909ac2abc0 100644 --- a/test/resources/TaxIds.spec.js +++ b/test/resources/TaxIds.spec.js @@ -12,9 +12,9 @@ var taxId = new resources.TaxIds(stripe, {customerId: CUSTOMER_TEST_ID}); // Use spy from existing resource: taxId._request = stripe.customers._request; -describe('TaxId Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('TaxId Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { var data = { type: 'eu_vat', value: '11111', @@ -29,8 +29,8 @@ describe('TaxId Resource', function() { }); }); - describe('delete', function() { - it('Sends the correct request', function() { + describe('delete', () => { + it('Sends the correct request', () => { taxId.del(TAX_ID_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -41,8 +41,8 @@ describe('TaxId Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { taxId.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -53,8 +53,8 @@ describe('TaxId Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { taxId.retrieve(TAX_ID_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/TaxRates.spec.js b/test/resources/TaxRates.spec.js index 74e931b29b..c95d186c9f 100644 --- a/test/resources/TaxRates.spec.js +++ b/test/resources/TaxRates.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('TaxRates Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('TaxRates Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.taxRates.retrieve('txr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('TaxRates Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { var data = { metadata: {a: '1234'}, }; @@ -31,8 +31,8 @@ describe('TaxRates Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { var data = { display_name: 'name', inclusive: false, @@ -49,8 +49,8 @@ describe('TaxRates Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.taxRates.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Terminal/ConnectionTokens.spec.js b/test/resources/Terminal/ConnectionTokens.spec.js index 75dd800361..f0b78e79b4 100644 --- a/test/resources/Terminal/ConnectionTokens.spec.js +++ b/test/resources/Terminal/ConnectionTokens.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Terminal', function() { - describe('ConnectionToken Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Terminal', () => { + describe('ConnectionToken Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.terminal.connectionTokens.create({}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/Terminal/Locations.spec.js b/test/resources/Terminal/Locations.spec.js index 335beb55b9..3c5aa7d71e 100644 --- a/test/resources/Terminal/Locations.spec.js +++ b/test/resources/Terminal/Locations.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Terminal', function() { - describe('Locations Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Terminal', () => { + describe('Locations Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.terminal.locations.retrieve('loc_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Terminal', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.terminal.locations.create({ display_name: 'name', address: { @@ -49,8 +49,8 @@ describe('Terminal', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.terminal.locations.del('loc_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -61,8 +61,8 @@ describe('Terminal', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.terminal.locations.update('loc_123', { display_name: 'name', }); @@ -77,8 +77,8 @@ describe('Terminal', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.terminal.locations.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Terminal/Readers.spec.js b/test/resources/Terminal/Readers.spec.js index ab6f60451f..189fb1a444 100644 --- a/test/resources/Terminal/Readers.spec.js +++ b/test/resources/Terminal/Readers.spec.js @@ -4,10 +4,10 @@ var stripe = require('../../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Terminal', function() { - describe('Readers Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Terminal', () => { + describe('Readers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.terminal.readers.retrieve('rdr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -19,8 +19,8 @@ describe('Terminal', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.terminal.readers.create({ registration_code: 'a-b-c', label: 'name', @@ -37,8 +37,8 @@ describe('Terminal', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.terminal.readers.del('rdr_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -49,8 +49,8 @@ describe('Terminal', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.terminal.readers.update('rdr_123', { label: 'name', }); @@ -65,8 +65,8 @@ describe('Terminal', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.terminal.readers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/ThreeDSecure.spec.js b/test/resources/ThreeDSecure.spec.js index 9efc67b1e6..af0f46a13f 100644 --- a/test/resources/ThreeDSecure.spec.js +++ b/test/resources/ThreeDSecure.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('ThreeDSecure Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('ThreeDSecure Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.threeDSecure.retrieve('tdsrc_id'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('ThreeDSecure Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.threeDSecure.create({ card: 'tok_test', amount: 1500, diff --git a/test/resources/Tokens.spec.js b/test/resources/Tokens.spec.js index 397168f002..fda037ef6d 100644 --- a/test/resources/Tokens.spec.js +++ b/test/resources/Tokens.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Tokens Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('Tokens Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.tokens.create({ card: {number: 123}, }); @@ -18,8 +18,8 @@ describe('Tokens Resource', function() { }); }); - describe('retrieve', function() { - it('Sends the correct request', function() { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.tokens.retrieve('tokenId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Topups.spec.js b/test/resources/Topups.spec.js index 7c1d1c2b94..bffb3a4f49 100644 --- a/test/resources/Topups.spec.js +++ b/test/resources/Topups.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Topup Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Topup Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.topups.retrieve('tu_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Topup Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.topups.create({ source: 'src_123', amount: '1500', @@ -40,8 +40,8 @@ describe('Topup Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.topups.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -52,8 +52,8 @@ describe('Topup Resource', function() { }); }); - describe('cancel', function() { - it('Sends the correct request', function() { + describe('cancel', () => { + it('Sends the correct request', () => { stripe.topups.cancel('tu_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -64,8 +64,8 @@ describe('Topup Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.topups.update('tu_123', {metadata: {key: 'value'}}); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', diff --git a/test/resources/TransferReversals.spec.js b/test/resources/TransferReversals.spec.js index 5f06d8c0e9..41c2b1743d 100644 --- a/test/resources/TransferReversals.spec.js +++ b/test/resources/TransferReversals.spec.js @@ -15,9 +15,9 @@ var transferReversal = new resources.TransferReversals(stripe, { // Use spy from existing resource: transferReversal._request = stripe.customers._request; -describe('TransferReversal Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('TransferReversal Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { transferReversal.retrieve(REVERSAL_TEST_ID); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -32,8 +32,8 @@ describe('TransferReversal Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { transferReversal.create({ amount: 100, }); @@ -46,8 +46,8 @@ describe('TransferReversal Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { transferReversal.update(REVERSAL_TEST_ID, { metadata: {key: 'value'}, }); @@ -64,8 +64,8 @@ describe('TransferReversal Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { transferReversal.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/Transfers.spec.js b/test/resources/Transfers.spec.js index f00ba9defb..208cf85e9a 100644 --- a/test/resources/Transfers.spec.js +++ b/test/resources/Transfers.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('Transfers Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('Transfers Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.transfers.retrieve('transferId1'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('Transfers Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.transfers.create({ amount: 200, currency: 'usd', @@ -32,8 +32,8 @@ describe('Transfers Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.transfers.update('transferId6654', { amount: 300, }); @@ -46,8 +46,8 @@ describe('Transfers Resource', function() { }); }); - describe('cancel', function() { - it('Sends the correct request', function() { + describe('cancel', () => { + it('Sends the correct request', () => { stripe.transfers.cancel('transferId4'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -58,8 +58,8 @@ describe('Transfers Resource', function() { }); }); - describe('reverse', function() { - it('Sends the correct request', function() { + describe('reverse', () => { + it('Sends the correct request', () => { stripe.transfers.reverse('transferId4'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', @@ -70,8 +70,8 @@ describe('Transfers Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.transfers.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -82,8 +82,8 @@ describe('Transfers Resource', function() { }); }); - describe('listTransactions', function() { - it('Sends the correct request', function() { + describe('listTransactions', () => { + it('Sends the correct request', () => { stripe.transfers.listTransactions('tr_14222'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/resources/UsageRecordSummaries.spec.js b/test/resources/UsageRecordSummaries.spec.js index 436dd580d7..ed779d9f8b 100644 --- a/test/resources/UsageRecordSummaries.spec.js +++ b/test/resources/UsageRecordSummaries.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('UsageRecordSummaries Resource', function() { - describe('list', function() { - it('Sends the correct request', function() { +describe('UsageRecordSummaries Resource', () => { + describe('list', () => { + it('Sends the correct request', () => { stripe.usageRecordSummaries.list('si_123', {}); expect(stripe.LAST_REQUEST).to.deep.equal({ @@ -16,7 +16,7 @@ describe('UsageRecordSummaries Resource', function() { }); }); - it('Includes any options that were provided', function(done) { + it('Includes any options that were provided', (done) => { stripe.usageRecordSummaries .list( 'si_123', @@ -25,7 +25,7 @@ describe('UsageRecordSummaries Resource', function() { stripe_account: 'acct_456', } ) - .then(function(record) { + .then((record) => { expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', url: '/v1/subscription_items/si_123/usage_record_summaries', @@ -39,8 +39,8 @@ describe('UsageRecordSummaries Resource', function() { }); }); - it('Calls a given callback', function(done) { - stripe.usageRecordSummaries.list('si_123', {}, function(error, record) { + it('Calls a given callback', (done) => { + stripe.usageRecordSummaries.list('si_123', {}, (error, record) => { done(error); }); }); diff --git a/test/resources/UsageRecords.spec.js b/test/resources/UsageRecords.spec.js index 0bd5f0b04f..f161ee535e 100644 --- a/test/resources/UsageRecords.spec.js +++ b/test/resources/UsageRecords.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('UsageRecords Resource', function() { - describe('create', function() { - it('Sends the correct request', function() { +describe('UsageRecords Resource', () => { + describe('create', () => { + it('Sends the correct request', () => { stripe.usageRecords.create('si_123', { quantity: 123, timestamp: 123321, @@ -24,7 +24,7 @@ describe('UsageRecords Resource', function() { }); }); - it('Includes any options that were provided', function(done) { + it('Includes any options that were provided', (done) => { stripe.usageRecords .create( 'si_123', @@ -37,7 +37,7 @@ describe('UsageRecords Resource', function() { stripe_account: 'acct_456', } ) - .then(function(record) { + .then((record) => { expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'POST', url: '/v1/subscription_items/si_123/usage_records', @@ -55,7 +55,7 @@ describe('UsageRecords Resource', function() { }); }); - it('Calls a given callback', function(done) { + it('Calls a given callback', (done) => { stripe.usageRecords.create( 'si_123', { @@ -63,7 +63,7 @@ describe('UsageRecords Resource', function() { timestamp: 123321, action: 'increment', }, - function(error, record) { + (error, record) => { done(error); } ); diff --git a/test/resources/WebhookEndpoints.spec.js b/test/resources/WebhookEndpoints.spec.js index a2ac60b390..e6c0109e8c 100644 --- a/test/resources/WebhookEndpoints.spec.js +++ b/test/resources/WebhookEndpoints.spec.js @@ -3,9 +3,9 @@ var stripe = require('../../testUtils').getSpyableStripe(); var expect = require('chai').expect; -describe('WebhookEndpoints Resource', function() { - describe('retrieve', function() { - it('Sends the correct request', function() { +describe('WebhookEndpoints Resource', () => { + describe('retrieve', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.retrieve('we_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', @@ -16,8 +16,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('del', function() { - it('Sends the correct request', function() { + describe('del', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.del('we_123'); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'DELETE', @@ -28,8 +28,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('update', function() { - it('Sends the correct request', function() { + describe('update', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.update('we_123', { enabled_events: ['charge.succeeded'], }); @@ -44,8 +44,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('create', function() { - it('Sends the correct request', function() { + describe('create', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.create({ enabled_events: ['charge.succeeded'], url: 'https://stripe.com', @@ -63,8 +63,8 @@ describe('WebhookEndpoints Resource', function() { }); }); - describe('list', function() { - it('Sends the correct request', function() { + describe('list', () => { + it('Sends the correct request', () => { stripe.webhookEndpoints.list(); expect(stripe.LAST_REQUEST).to.deep.equal({ method: 'GET', diff --git a/test/stripe.spec.js b/test/stripe.spec.js index 5b1328ffde..c81dd15935 100644 --- a/test/stripe.spec.js +++ b/test/stripe.spec.js @@ -17,78 +17,77 @@ describe('Stripe Module', function() { var cleanup = new testUtils.CleanupUtility(); this.timeout(20000); - describe('setApiKey', function() { - it('uses Bearer auth', function() { + describe('setApiKey', () => { + it('uses Bearer auth', () => { expect(stripe.getApiField('auth')).to.equal( 'Bearer ' + testUtils.getUserStripeKey() ); }); }); - describe('GetClientUserAgent', function() { - it('Should return a user-agent serialized JSON object', function() { - return expect( - new Promise(function(resolve, reject) { - stripe.getClientUserAgent(function(c) { + describe('GetClientUserAgent', () => { + it('Should return a user-agent serialized JSON object', () => + expect( + new Promise((resolve, reject) => { + stripe.getClientUserAgent((c) => { resolve(JSON.parse(c)); }); }) - ).to.eventually.have.property('lang', 'node'); - }); + ).to.eventually.have.property('lang', 'node')); }); - describe('GetClientUserAgentSeeded', function() { - it('Should return a user-agent serialized JSON object', function() { + describe('GetClientUserAgentSeeded', () => { + it('Should return a user-agent serialized JSON object', () => { var userAgent = {lang: 'node'}; return expect( - new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded(userAgent, function(c) { + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded(userAgent, (c) => { resolve(JSON.parse(c)); }); }) ).to.eventually.have.property('lang', 'node'); }); - it('Should URI-encode user-agent fields', function() { + it('Should URI-encode user-agent fields', () => { var userAgent = {lang: 'ï'}; return expect( - new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded(userAgent, function(c) { + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded(userAgent, (c) => { resolve(JSON.parse(c)); }); }) ).to.eventually.have.property('lang', '%C3%AF'); }); - describe('uname', function() { + describe('uname', () => { var origExec; - beforeEach(function() { + beforeEach(() => { origExec = utils.safeExec; }); - afterEach(function() { + afterEach(() => { utils.safeExec = origExec; }); - it('gets added to the user-agent', function() { - utils.safeExec = function(cmd, cb) { + it('gets added to the user-agent', () => { + utils.safeExec = (cmd, cb) => { cb(null, 'foøname'); }; return expect( - new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded({lang: 'node'}, function(c) { + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded({lang: 'node'}, (c) => { resolve(JSON.parse(c)); }); }) ).to.eventually.have.property('uname', 'fo%C3%B8name'); }); - it('sets uname to UNKOWN in case of an error', function() { - utils.safeExec = function(cmd, cb) { + it('sets uname to UNKOWN in case of an error', () => { + utils.safeExec = (cmd, cb) => { cb(new Error('security'), null); }; return expect( - new Promise(function(resolve, reject) { - stripe.getClientUserAgentSeeded({lang: 'node'}, function(c) { + new Promise((resolve, reject) => { + stripe.getClientUserAgentSeeded({lang: 'node'}, (c) => { resolve(JSON.parse(c)); }); }) @@ -97,17 +96,17 @@ describe('Stripe Module', function() { }); }); - describe('setTimeout', function() { - it('Should define a default equal to the node default', function() { + describe('setTimeout', () => { + it('Should define a default equal to the node default', () => { expect(stripe.getApiField('timeout')).to.equal( http.createServer().timeout ); }); - it('Should allow me to set a custom timeout', function() { + it('Should allow me to set a custom timeout', () => { stripe.setTimeout(900); expect(stripe.getApiField('timeout')).to.equal(900); }); - it('Should allow me to set null, to reset to the default', function() { + it('Should allow me to set null, to reset to the default', () => { stripe.setTimeout(null); expect(stripe.getApiField('timeout')).to.equal( http.createServer().timeout @@ -115,27 +114,27 @@ describe('Stripe Module', function() { }); }); - describe('setAppInfo', function() { - describe('when given nothing or an empty object', function() { - it('should unset stripe._appInfo', function() { + describe('setAppInfo', () => { + describe('when given nothing or an empty object', () => { + it('should unset stripe._appInfo', () => { stripe.setAppInfo(); expect(stripe._appInfo).to.be.undefined; }); }); - describe('when given an object with no `name`', function() { - it('should throw an error', function() { - expect(function() { + describe('when given an object with no `name`', () => { + it('should throw an error', () => { + expect(() => { stripe.setAppInfo({}); }).to.throw(/AppInfo.name is required/); - expect(function() { + expect(() => { stripe.setAppInfo({ version: '1.2.3', }); }).to.throw(/AppInfo.name is required/); - expect(function() { + expect(() => { stripe.setAppInfo({ cats: '42', }); @@ -143,8 +142,8 @@ describe('Stripe Module', function() { }); }); - describe('when given at least a `name`', function() { - it('should set name, partner ID, url, and version of stripe._appInfo', function() { + describe('when given at least a `name`', () => { + it('should set name, partner ID, url, and version of stripe._appInfo', () => { stripe.setAppInfo({ name: 'MyAwesomeApp', }); @@ -180,7 +179,7 @@ describe('Stripe Module', function() { }); }); - it('should ignore any invalid properties', function() { + it('should ignore any invalid properties', () => { stripe.setAppInfo({ name: 'MyAwesomeApp', partner_id: 'partner_1234', @@ -197,7 +196,7 @@ describe('Stripe Module', function() { }); }); - it('should be included in the ClientUserAgent and be added to the UserAgent String', function(done) { + it('should be included in the ClientUserAgent and be added to the UserAgent String', (done) => { var appInfo = { name: testUtils.getRandomString(), version: '1.2.345', @@ -206,7 +205,7 @@ describe('Stripe Module', function() { stripe.setAppInfo(appInfo); - stripe.getClientUserAgent(function(uaString) { + stripe.getClientUserAgent((uaString) => { expect(JSON.parse(uaString).application).to.eql(appInfo); expect(stripe.getAppInfoAsString()).to.eql( @@ -218,23 +217,22 @@ describe('Stripe Module', function() { }); }); - describe('Callback support', function() { - describe('Any given endpoint', function() { - it('Will call a callback if successful', function() { - return expect( - new Promise(function(resolve, reject) { - stripe.customers.create(CUSTOMER_DETAILS, function(err, customer) { + describe('Callback support', () => { + describe('Any given endpoint', () => { + it('Will call a callback if successful', () => + expect( + new Promise((resolve, reject) => { + stripe.customers.create(CUSTOMER_DETAILS, (err, customer) => { cleanup.deleteCustomer(customer.id); resolve('Called!'); }); }) - ).to.eventually.equal('Called!'); - }); + ).to.eventually.equal('Called!')); - it('Will expose HTTP response object', function() { - return expect( - new Promise(function(resolve, reject) { - stripe.customers.create(CUSTOMER_DETAILS, function(err, customer) { + it('Will expose HTTP response object', () => + expect( + new Promise((resolve, reject) => { + stripe.customers.create(CUSTOMER_DETAILS, (err, customer) => { cleanup.deleteCustomer(customer.id); var headers = customer.lastResponse.headers; @@ -246,16 +244,15 @@ describe('Stripe Module', function() { resolve('Called!'); }); }) - ).to.eventually.equal('Called!'); - }); + ).to.eventually.equal('Called!')); - it('Given an error the callback will receive it', function() { - return expect( - new Promise(function(resolve, reject) { + it('Given an error the callback will receive it', () => + expect( + new Promise((resolve, reject) => { stripe.customers.createCard( 'nonExistentCustId', {card: {}}, - function(err, customer) { + (err, customer) => { if (err) { resolve('ErrorWasPassed'); } else { @@ -264,13 +261,12 @@ describe('Stripe Module', function() { } ); }) - ).to.eventually.become('ErrorWasPassed'); - }); + ).to.eventually.become('ErrorWasPassed')); }); }); - describe('errors', function() { - it('Exports errors as types', function() { + describe('errors', () => { + it('Exports errors as types', () => { var Stripe = require('../lib/stripe'); expect( new Stripe.errors.StripeInvalidRequestError({ @@ -280,14 +276,14 @@ describe('Stripe Module', function() { }); }); - describe('setMaxNetworkRetries', function() { - describe('when given an empty or non-number variable', function() { - it('should error', function() { - expect(function() { + describe('setMaxNetworkRetries', () => { + describe('when given an empty or non-number variable', () => { + it('should error', () => { + expect(() => { stripe.setMaxNetworkRetries('foo'); }).to.throw(/maxNetworkRetries must be a number/); - expect(function() { + expect(() => { stripe.setMaxNetworkRetries(); }).to.throw(/maxNetworkRetries must be a number/); }); diff --git a/test/telemetry.spec.js b/test/telemetry.spec.js index cc62a61a86..7232250637 100644 --- a/test/telemetry.spec.js +++ b/test/telemetry.spec.js @@ -8,7 +8,7 @@ var testServer = null; function createTestServer(handlerFunc, cb) { var host = '127.0.0.1'; - testServer = http.createServer(function(req, res) { + testServer = http.createServer((req, res) => { try { handlerFunc(req, res); } catch (e) { @@ -20,25 +20,25 @@ function createTestServer(handlerFunc, cb) { ); } }); - testServer.listen(0, host, function() { + testServer.listen(0, host, () => { var port = testServer.address().port; cb(host, port); }); } -describe('Client Telemetry', function() { - afterEach(function() { +describe('Client Telemetry', () => { + afterEach(() => { if (testServer) { testServer.close(); testServer = null; } }); - it('Does not send telemetry when disabled', function(done) { + it('Does not send telemetry when disabled', (done) => { var numRequests = 0; createTestServer( - function(req, res) { + (req, res) => { numRequests += 1; var telemetry = req.headers['x-stripe-client-telemetry']; @@ -56,7 +56,7 @@ describe('Client Telemetry', function() { res.writeHead(200, {'Content-Type': 'application/json'}); res.end('{}'); }, - function(host, port) { + (host, port) => { const stripe = require('../lib/stripe')( 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' ); @@ -64,10 +64,8 @@ describe('Client Telemetry', function() { stripe.balance .retrieve() - .then(function(res) { - return stripe.balance.retrieve(); - }) - .then(function(res) { + .then((res) => stripe.balance.retrieve()) + .then((res) => { expect(numRequests).to.equal(2); done(); }) @@ -76,11 +74,11 @@ describe('Client Telemetry', function() { ); }); - it('Sends client telemetry on the second request when enabled', function(done) { + it('Sends client telemetry on the second request when enabled', (done) => { var numRequests = 0; createTestServer( - function(req, res) { + (req, res) => { numRequests += 1; var telemetry = req.headers['x-stripe-client-telemetry']; @@ -103,7 +101,7 @@ describe('Client Telemetry', function() { res.writeHead(200, {'Content-Type': 'application/json'}); res.end('{}'); }, - function(host, port) { + (host, port) => { const stripe = require('../lib/stripe')( 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' ); @@ -112,10 +110,8 @@ describe('Client Telemetry', function() { stripe.balance .retrieve() - .then(function(res) { - return stripe.balance.retrieve(); - }) - .then(function(res) { + .then((res) => stripe.balance.retrieve()) + .then((res) => { expect(numRequests).to.equal(2); done(); }) @@ -124,11 +120,11 @@ describe('Client Telemetry', function() { ); }); - it('Buffers metrics on concurrent requests', function(done) { + it('Buffers metrics on concurrent requests', (done) => { var numRequests = 0; createTestServer( - function(req, res) { + (req, res) => { numRequests += 1; var telemetry = req.headers['x-stripe-client-telemetry']; @@ -153,7 +149,7 @@ describe('Client Telemetry', function() { res.writeHead(200, {'Content-Type': 'application/json'}); res.end('{}'); }, - function(host, port) { + (host, port) => { const stripe = require('../lib/stripe')( 'sk_test_FEiILxKZwnmmocJDUjUNO6pa' ); @@ -161,13 +157,10 @@ describe('Client Telemetry', function() { stripe.setHost(host, port, 'http'); Promise.all([stripe.balance.retrieve(), stripe.balance.retrieve()]) - .then(function() { - return Promise.all([ - stripe.balance.retrieve(), - stripe.balance.retrieve(), - ]); - }) - .then(function() { + .then(() => + Promise.all([stripe.balance.retrieve(), stripe.balance.retrieve()]) + ) + .then(() => { expect(numRequests).to.equal(4); done(); }) diff --git a/test/utils.spec.js b/test/utils.spec.js index d9ae8a6d54..eed75c83d2 100644 --- a/test/utils.spec.js +++ b/test/utils.spec.js @@ -6,9 +6,9 @@ var utils = require('../lib/utils'); var expect = require('chai').expect; var Buffer = require('safe-buffer').Buffer; -describe('utils', function() { - describe('makeURLInterpolator', function() { - it('Interpolates values into a prepared template', function() { +describe('utils', () => { + describe('makeURLInterpolator', () => { + it('Interpolates values into a prepared template', () => { var template = utils.makeURLInterpolator('/some/url/{foo}/{baz}?ok=1'); expect(template({foo: 1, baz: 2})).to.equal('/some/url/1/2?ok=1'); @@ -22,8 +22,8 @@ describe('utils', function() { }); }); - describe('stringifyRequestData', function() { - it('Handles basic types', function() { + describe('stringifyRequestData', () => { + it('Handles basic types', () => { expect( utils.stringifyRequestData({ a: 1, @@ -32,7 +32,7 @@ describe('utils', function() { ).to.equal('a=1&b=foo'); }); - it('Handles Dates', function() { + it('Handles Dates', () => { expect( utils.stringifyRequestData({ date: new Date('2009-02-13T23:31:30Z'), @@ -50,7 +50,7 @@ describe('utils', function() { ); }); - it('Handles deeply nested object', function() { + it('Handles deeply nested object', () => { expect( utils.stringifyRequestData({ a: { @@ -64,7 +64,7 @@ describe('utils', function() { ).to.equal('a[b][c][d]=2'); }); - it('Handles arrays of objects', function() { + it('Handles arrays of objects', () => { expect( utils.stringifyRequestData({ a: [{b: 'c'}, {b: 'd'}], @@ -72,7 +72,7 @@ describe('utils', function() { ).to.equal('a[0][b]=c&a[1][b]=d'); }); - it('Handles indexed arrays', function() { + it('Handles indexed arrays', () => { expect( utils.stringifyRequestData({ a: { @@ -83,7 +83,7 @@ describe('utils', function() { ).to.equal('a[0][b]=c&a[1][b]=d'); }); - it('Creates a string from an object, handling shallow nested objects', function() { + it('Creates a string from an object, handling shallow nested objects', () => { expect( utils.stringifyRequestData({ test: 1, @@ -106,8 +106,8 @@ describe('utils', function() { }); }); - describe('protoExtend', function() { - it('Provides an extension mechanism', function() { + describe('protoExtend', () => { + it('Provides an extension mechanism', () => { function A() {} A.extend = utils.protoExtend; var B = A.extend({ @@ -122,38 +122,38 @@ describe('utils', function() { }); }); - describe('getDataFromArgs', function() { - it('handles an empty list', function() { + describe('getDataFromArgs', () => { + it('handles an empty list', () => { expect(utils.getDataFromArgs([])).to.deep.equal({}); }); - it('handles a list with no object', function() { + it('handles a list with no object', () => { var args = [1, 3]; expect(utils.getDataFromArgs(args)).to.deep.equal({}); expect(args.length).to.equal(2); }); - it('ignores a hash with only options', function(done) { + it('ignores a hash with only options', (done) => { var args = [{api_key: 'foo'}]; handleWarnings( - function() { + () => { expect(utils.getDataFromArgs(args)).to.deep.equal({}); expect(args.length).to.equal(1); done(); }, - function(message) { + (message) => { throw new Error('Should not have warned, but did: ' + message); } ); }); - it('warns if the hash contains both data and options', function(done) { + it('warns if the hash contains both data and options', (done) => { var args = [{foo: 'bar', api_key: 'foo', idempotency_key: 'baz'}]; handleWarnings( - function() { + () => { utils.getDataFromArgs(args); }, - function(message) { + (message) => { expect(message).to.equal( 'Stripe: Options found in arguments (api_key, idempotency_key).' + ' Did you mean to pass an options object? See https://github.com/stripe/stripe-node/wiki/Passing-Options.' @@ -163,21 +163,21 @@ describe('utils', function() { } ); }); - it('finds the data', function() { + it('finds the data', () => { var args = [{foo: 'bar'}, {api_key: 'foo'}]; expect(utils.getDataFromArgs(args)).to.deep.equal({foo: 'bar'}); expect(args.length).to.equal(1); }); }); - describe('getOptsFromArgs', function() { - it('handles an empty list', function() { + describe('getOptsFromArgs', () => { + it('handles an empty list', () => { expect(utils.getOptionsFromArgs([])).to.deep.equal({ auth: null, headers: {}, }); }); - it('handles an list with no object', function() { + it('handles an list with no object', () => { var args = [1, 3]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, @@ -185,7 +185,7 @@ describe('utils', function() { }); expect(args.length).to.equal(2); }); - it('ignores a non-options object', function() { + it('ignores a non-options object', () => { var args = [{foo: 'bar'}]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, @@ -193,7 +193,7 @@ describe('utils', function() { }); expect(args.length).to.equal(1); }); - it('parses an api key', function() { + it('parses an api key', () => { var args = ['sk_test_iiiiiiiiiiiiiiiiiiiiiiii']; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', @@ -201,7 +201,7 @@ describe('utils', function() { }); expect(args.length).to.equal(0); }); - it('parses an idempotency key', function() { + it('parses an idempotency key', () => { var args = [{foo: 'bar'}, {idempotency_key: 'foo'}]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, @@ -209,7 +209,7 @@ describe('utils', function() { }); expect(args.length).to.equal(1); }); - it('parses an api version', function() { + it('parses an api version', () => { var args = [{foo: 'bar'}, {stripe_version: '2003-03-30'}]; expect(utils.getOptionsFromArgs(args)).to.deep.equal({ auth: null, @@ -217,7 +217,7 @@ describe('utils', function() { }); expect(args.length).to.equal(1); }); - it('parses an idempotency key and api key and api version (with data)', function() { + it('parses an idempotency key and api key and api version (with data)', () => { var args = [ {foo: 'bar'}, { @@ -235,7 +235,7 @@ describe('utils', function() { }); expect(args.length).to.equal(1); }); - it('parses an idempotency key and api key and api version', function() { + it('parses an idempotency key and api key and api version', () => { var args = [ { api_key: 'sk_test_iiiiiiiiiiiiiiiiiiiiiiii', @@ -252,7 +252,7 @@ describe('utils', function() { }); expect(args.length).to.equal(0); }); - it('warns if the hash contains something that does not belong', function(done) { + it('warns if the hash contains something that does not belong', (done) => { var args = [ {foo: 'bar'}, { @@ -265,10 +265,10 @@ describe('utils', function() { ]; handleWarnings( - function() { + () => { utils.getOptionsFromArgs(args); }, - function(message) { + (message) => { expect(message).to.equal( 'Stripe: Invalid options found (fishsticks, custard); ignoring.' ); @@ -279,24 +279,24 @@ describe('utils', function() { }); }); - describe('secureCompare', function() { - it('returns true given two equal things', function() { + describe('secureCompare', () => { + it('returns true given two equal things', () => { expect(utils.secureCompare('potato', 'potato')).to.equal(true); }); - it('returns false given two unequal things', function() { + it('returns false given two unequal things', () => { expect(utils.secureCompare('potato', 'tomato')).to.equal(false); }); - it('throws an error if not given two things to compare', function() { - expect(function() { + it('throws an error if not given two things to compare', () => { + expect(() => { utils.secureCompare('potato'); }).to.throw(); }); }); - describe('removeEmpty', function() { - it('removes empty properties and leaves non-empty ones', function() { + describe('removeEmpty', () => { + it('removes empty properties and leaves non-empty ones', () => { expect( utils.removeEmpty({ cat: 3, @@ -310,25 +310,25 @@ describe('utils', function() { }); }); - it('throws an error if not given two things to compare', function() { - expect(function() { + it('throws an error if not given two things to compare', () => { + expect(() => { utils.removeEmpty('potato'); }).to.throw(); }); }); - describe('safeExec', function() { + describe('safeExec', () => { var origExec; - beforeEach(function() { + beforeEach(() => { origExec = utils._exec; }); - afterEach(function() { + afterEach(() => { utils._exec = origExec; }); - it('runs exec', function() { + it('runs exec', () => { var calls = []; - utils._exec = function(cmd, cb) { + utils._exec = (cmd, cb) => { calls.push([cmd, cb]); }; @@ -337,9 +337,9 @@ describe('utils', function() { expect(calls).to.deep.equal([['hello', myCb]]); }); - it('passes along normal errors', function() { + it('passes along normal errors', () => { var myErr = Error('hi'); - utils._exec = function(cmd, cb) { + utils._exec = (cmd, cb) => { cb(myErr, null); }; @@ -351,9 +351,9 @@ describe('utils', function() { expect(calls).to.deep.equal([[myErr, null]]); }); - it('passes along thrown errors as normal callback errors', function() { + it('passes along thrown errors as normal callback errors', () => { var myErr = Error('hi'); - utils._exec = function(cmd, cb) { + utils._exec = (cmd, cb) => { throw myErr; }; @@ -366,8 +366,8 @@ describe('utils', function() { }); }); - describe('flattenAndStringify', function() { - it('Stringifies primitive types', function() { + describe('flattenAndStringify', () => { + it('Stringifies primitive types', () => { expect( utils.flattenAndStringify({ a: 1, @@ -378,7 +378,7 @@ describe('utils', function() { ).to.eql({a: '1', b: 'foo', c: 'true', d: 'null'}); }); - it('Flattens nested values', function() { + it('Flattens nested values', () => { expect( utils.flattenAndStringify({ x: { @@ -389,7 +389,7 @@ describe('utils', function() { ).to.eql({'x[a]': '1', 'x[b]': 'foo'}); }); - it('Does not flatten File objects', function() { + it('Does not flatten File objects', () => { expect( utils.flattenAndStringify({ file: { @@ -402,7 +402,7 @@ describe('utils', function() { ).to.eql({file: {data: 'foo'}, 'x[a]': '1'}); }); - it('Does not flatten Buffer objects', function() { + it('Does not flatten Buffer objects', () => { var buf = Buffer.from('Hi!'); var flattened = utils.flattenAndStringify({ buf: buf, @@ -442,7 +442,7 @@ function handleWarnings(doWithShimmedConsoleWarn, onWarn) { doWithShimmedConsoleWarn(); - process.nextTick(function() { + process.nextTick(() => { process.removeListener('warning', onProcessWarn); }); } diff --git a/testUtils/index.js b/testUtils/index.js index 443b2c4655..8a8474fd36 100644 --- a/testUtils/index.js +++ b/testUtils/index.js @@ -68,7 +68,7 @@ var utils = (module.exports = { * CleanupUtility will automatically register on the mocha afterEach hook, * ensuring its called after each descendent-describe block. */ - CleanupUtility: (function() { + CleanupUtility: (() => { CleanupUtility.DEFAULT_TIMEOUT = 20000; function CleanupUtility(timeout) { @@ -98,14 +98,14 @@ var utils = (module.exports = { ); } promise.then( - function() { + () => { // cleanup successful completed += 1; if (completed === total) { done(); } }, - function(err) { + (err) => { // not successful throw err; }