|
|
@@ -334,86 +334,6 @@ describe('RecurlyWrapper', function () {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe('cancelSubscription', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
- this.recurlySubscriptionId = 'subscription-id-123'
|
|
|
- this.apiRequest = sinon
|
|
|
- .stub(this.RecurlyWrapper, 'apiRequest')
|
|
|
- .callsFake((options, callback) => {
|
|
|
- options.url.should.equal(
|
|
|
- `subscriptions/${this.recurlySubscriptionId}/cancel`
|
|
|
- )
|
|
|
- options.method.should.equal('put')
|
|
|
- return callback()
|
|
|
- })
|
|
|
- return this.RecurlyWrapper.cancelSubscription(
|
|
|
- this.recurlySubscriptionId,
|
|
|
- done
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- afterEach(function () {
|
|
|
- return this.RecurlyWrapper.apiRequest.restore()
|
|
|
- })
|
|
|
-
|
|
|
- it('should send a cancel request to the API', function () {
|
|
|
- return this.apiRequest.called.should.equal(true)
|
|
|
- })
|
|
|
-
|
|
|
- describe('when the subscription is already cancelled', function () {
|
|
|
- beforeEach(function () {
|
|
|
- this.RecurlyWrapper.apiRequest.restore()
|
|
|
- this.recurlySubscriptionId = 'subscription-id-123'
|
|
|
- return (this.apiRequest = sinon
|
|
|
- .stub(this.RecurlyWrapper, 'apiRequest')
|
|
|
- .callsFake((options, callback) => {
|
|
|
- return callback(
|
|
|
- new Error('woops'),
|
|
|
- {},
|
|
|
- "<error><description>A canceled subscription can't transition to canceled</description></error>"
|
|
|
- )
|
|
|
- }))
|
|
|
- })
|
|
|
-
|
|
|
- it('should not produce an error', function (done) {
|
|
|
- return this.RecurlyWrapper.cancelSubscription(
|
|
|
- this.recurlySubscriptionId,
|
|
|
- err => {
|
|
|
- expect(err).to.equal(null)
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
- })
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
- describe('reactivateSubscription', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
- this.recurlySubscriptionId = 'subscription-id-123'
|
|
|
- this.apiRequest = sinon
|
|
|
- .stub(this.RecurlyWrapper, 'apiRequest')
|
|
|
- .callsFake((options, callback) => {
|
|
|
- options.url.should.equal(
|
|
|
- `subscriptions/${this.recurlySubscriptionId}/reactivate`
|
|
|
- )
|
|
|
- options.method.should.equal('put')
|
|
|
- return callback()
|
|
|
- })
|
|
|
- return this.RecurlyWrapper.reactivateSubscription(
|
|
|
- this.recurlySubscriptionId,
|
|
|
- done
|
|
|
- )
|
|
|
- })
|
|
|
-
|
|
|
- afterEach(function () {
|
|
|
- return this.RecurlyWrapper.apiRequest.restore()
|
|
|
- })
|
|
|
-
|
|
|
- it('should send a cancel request to the API', function () {
|
|
|
- return this.apiRequest.called.should.equal(true)
|
|
|
- })
|
|
|
- })
|
|
|
-
|
|
|
describe('redeemCoupon', function () {
|
|
|
beforeEach(function (done) {
|
|
|
this.recurlyAccountId = 'account-id-123'
|