Merge pull request #29659 from overleaf/revert-29656-revert-29521-ar-models-es-conversion
Revert "Revert "[web] Convert models and self-referential test files to ESM "" GitOrigin-RevId: f64000ae31d298b075a8722dfc51f294c71bc021
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import { expect } from 'vitest'
|
||||
import mongodb from 'mongodb-legacy'
|
||||
import CooldownManager from '../../../../app/src/Features/Cooldown/CooldownManager.mjs'
|
||||
import { cleanupTestRedis } from '../../../../app/src/infrastructure/RedisWrapper.js'
|
||||
|
||||
const { ObjectId } = mongodb
|
||||
|
||||
describe('CooldownManager', function () {
|
||||
beforeEach(cleanupTestRedis)
|
||||
|
||||
beforeEach(function (ctx) {
|
||||
ctx.project1Id = new ObjectId().toString()
|
||||
ctx.project2Id = new ObjectId().toString()
|
||||
})
|
||||
|
||||
describe('_buildKey', function () {
|
||||
it('should build a properly formatted redis key', function () {
|
||||
expect(CooldownManager._buildKey('ABC')).to.equal('Cooldown:{ABC}')
|
||||
})
|
||||
})
|
||||
|
||||
describe('isProjectOnCooldown', function () {
|
||||
describe('when no project is on cooldown', function () {
|
||||
it('returns false for project 1', async function (ctx) {
|
||||
const result = await CooldownManager.promises.isProjectOnCooldown(
|
||||
ctx.project1Id
|
||||
)
|
||||
expect(result).to.be.false
|
||||
})
|
||||
|
||||
it('returns false for project 2', async function (ctx) {
|
||||
const result = await CooldownManager.promises.isProjectOnCooldown(
|
||||
ctx.project2Id
|
||||
)
|
||||
expect(result).to.be.false
|
||||
})
|
||||
})
|
||||
describe('when project 1 is on cooldown', function () {
|
||||
beforeEach(async function (ctx) {
|
||||
await CooldownManager.promises.putProjectOnCooldown(ctx.project1Id)
|
||||
})
|
||||
|
||||
it('returns true for project 1', async function (ctx) {
|
||||
const result = await CooldownManager.promises.isProjectOnCooldown(
|
||||
ctx.project1Id
|
||||
)
|
||||
expect(result).to.be.true
|
||||
})
|
||||
|
||||
it('returns false for project 2', async function (ctx) {
|
||||
const result = await CooldownManager.promises.isProjectOnCooldown(
|
||||
ctx.project2Id
|
||||
)
|
||||
expect(result).to.be.false
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user