mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
4f9eb281b7
Upgrade test dependencies GitOrigin-RevId: 0bda49dea086f525211836b6008f67bafa2bbe48
49 lines
1.5 KiB
JavaScript
49 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.exist
|
|
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
|