mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
50 lines
1.5 KiB
JavaScript
50 lines
1.5 KiB
JavaScript
|
const { expect } = require('chai')
|
||
|
const MockSubscription = require('./Subscription')
|
||
|
const SubscriptionUpdater = require('../../../../app/src/Features/Subscription/SubscriptionUpdater')
|
||
|
const SubscriptionModel = require('../../../../app/src/models/Subscription')
|
||
|
.Subscription
|
||
|
const DeletedSubscriptionModel = require(`../../../../app/src/models/DeletedSubscription`)
|
||
|
.DeletedSubscription
|
||
|
|
||
|
class DeletedSubscription {
|
||
|
constructor(options = {}) {
|
||
|
this.subscription = new MockSubscription(options)
|
||
|
}
|
||
|
|
||
|
ensureExists(callback) {
|
||
|
this.subscription.ensureExists(error => {
|
||
|
if (error) {
|
||
|
return callback(error)
|
||
|
}
|
||
|
SubscriptionUpdater.deleteSubscription(this.subscription, {}, callback)
|
||
|
})
|
||
|
}
|
||
|
|
||
|
expectRestored(callback) {
|
||
|
DeletedSubscriptionModel.findOne(
|
||
|
{ 'subscription._id': this.subscription._id },
|
||
|
(error, deletedSubscription) => {
|
||
|
if (error) {
|
||
|
return callback(error)
|
||
|
}
|
||
|
expect(deletedSubscription).to.be.null
|
||
|
SubscriptionModel.findById(
|
||
|
this.subscription._id,
|
||
|
(error, subscription) => {
|
||
|
expect(subscription).to.exists
|
||
|
expect(subscription._id.toString()).to.equal(
|
||
|
this.subscription._id.toString()
|
||
|
)
|
||
|
expect(subscription.admin_id.toString()).to.equal(
|
||
|
this.subscription.admin_id.toString()
|
||
|
)
|
||
|
callback(error)
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
module.exports = DeletedSubscription
|