mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-11 07:00:47 +02:00
129d748405
GitOrigin-RevId: 00b8128aed7727e7a1b6f8d2d92a5fbc3a7775fb
47 lines
1.4 KiB
JavaScript
47 lines
1.4 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,
|
|
})
|
|
.then(deletedSubscription => {
|
|
expect(deletedSubscription).to.be.null
|
|
SubscriptionModel.findById(this.subscription._id)
|
|
.then(subscription => {
|
|
expect(subscription).to.exist
|
|
expect(subscription._id.toString()).to.equal(
|
|
this.subscription._id.toString()
|
|
)
|
|
expect(subscription.admin_id.toString()).to.equal(
|
|
this.subscription.admin_id.toString()
|
|
)
|
|
callback()
|
|
})
|
|
.catch(callback)
|
|
})
|
|
.catch(callback)
|
|
}
|
|
}
|
|
|
|
module.exports = DeletedSubscription
|