Convert files to ES modules
GitOrigin-RevId: 713430521d60f37ee20906bb2d5d0a56849a729d
This commit is contained in:
@@ -1,38 +1,40 @@
|
|||||||
// Metrics must be initialized before importing anything else
|
// Metrics must be initialized before importing anything else
|
||||||
require('@overleaf/metrics/initialize')
|
import '@overleaf/metrics/initialize.js'
|
||||||
|
import metrics from '@overleaf/metrics'
|
||||||
|
import Settings from '@overleaf/settings'
|
||||||
|
import logger from '@overleaf/logger'
|
||||||
|
import express from 'express'
|
||||||
|
import methodOverride from 'method-override'
|
||||||
|
import { mongoClient } from './app/js/mongodb.js'
|
||||||
|
import NotificationsController from './app/js/NotificationsController.js'
|
||||||
|
import HealthCheckController from './app/js/HealthCheckController.js'
|
||||||
|
|
||||||
const metrics = require('@overleaf/metrics')
|
|
||||||
const Settings = require('@overleaf/settings')
|
|
||||||
const logger = require('@overleaf/logger')
|
|
||||||
logger.initialize('notifications')
|
|
||||||
const express = require('express')
|
|
||||||
const app = express()
|
const app = express()
|
||||||
const methodOverride = require('method-override')
|
|
||||||
const bodyParser = require('body-parser')
|
logger.initialize('notifications')
|
||||||
const { mongoClient } = require('./app/js/mongodb')
|
|
||||||
const controller = require('./app/js/NotificationsController')
|
|
||||||
|
|
||||||
metrics.memory.monitor(logger)
|
metrics.memory.monitor(logger)
|
||||||
metrics.open_sockets.monitor()
|
metrics.open_sockets.monitor()
|
||||||
|
|
||||||
const HealthCheckController = require('./app/js/HealthCheckController')
|
|
||||||
|
|
||||||
app.use(methodOverride())
|
app.use(methodOverride())
|
||||||
app.use(bodyParser())
|
app.use(express.json())
|
||||||
app.use(metrics.http.monitor(logger))
|
app.use(metrics.http.monitor(logger))
|
||||||
|
|
||||||
metrics.injectMetricsRoute(app)
|
metrics.injectMetricsRoute(app)
|
||||||
|
|
||||||
app.post('/user/:user_id', controller.addNotification)
|
app.post('/user/:user_id', NotificationsController.addNotification)
|
||||||
app.get('/user/:user_id', controller.getUserNotifications)
|
app.get('/user/:user_id', NotificationsController.getUserNotifications)
|
||||||
app.delete(
|
app.delete(
|
||||||
'/user/:user_id/notification/:notification_id',
|
'/user/:user_id/notification/:notification_id',
|
||||||
controller.removeNotificationId
|
NotificationsController.removeNotificationId
|
||||||
|
)
|
||||||
|
app.delete('/user/:user_id', NotificationsController.removeNotificationKey)
|
||||||
|
app.delete('/key/:key', NotificationsController.removeNotificationByKeyOnly)
|
||||||
|
app.get('/key/:key/count', NotificationsController.countNotificationsByKeyOnly)
|
||||||
|
app.delete(
|
||||||
|
'/key/:key/bulk',
|
||||||
|
NotificationsController.deleteUnreadNotificationsByKeyOnlyBulk
|
||||||
)
|
)
|
||||||
app.delete('/user/:user_id', controller.removeNotificationKey)
|
|
||||||
app.delete('/key/:key', controller.removeNotificationByKeyOnly)
|
|
||||||
app.get('/key/:key/count', controller.countNotificationsByKeyOnly)
|
|
||||||
app.delete('/key/:key/bulk', controller.deleteUnreadNotificationsByKeyOnlyBulk)
|
|
||||||
|
|
||||||
app.get('/status', (req, res) => res.send('notifications is up'))
|
app.get('/status', (req, res) => res.send('notifications is up'))
|
||||||
|
|
||||||
@@ -49,17 +51,15 @@ app.get('/health_check', (req, res) =>
|
|||||||
|
|
||||||
app.get('*', (req, res) => res.sendStatus(404))
|
app.get('*', (req, res) => res.sendStatus(404))
|
||||||
|
|
||||||
const host = Settings.internal?.notifications?.host || '127.0.0.1'
|
const host = Settings.internal.notifications?.host || '127.0.0.1'
|
||||||
const port = Settings.internal?.notifications?.port || 3042
|
const port = Settings.internal.notifications?.port || 3042
|
||||||
|
try {
|
||||||
|
await mongoClient.connect()
|
||||||
|
} catch (err) {
|
||||||
|
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
mongoClient
|
app.listen(port, host, () =>
|
||||||
.connect()
|
logger.debug({}, `notifications starting up, listening on ${host}:${port}`)
|
||||||
.then(() => {
|
)
|
||||||
app.listen(port, host, () =>
|
|
||||||
logger.debug(`notifications starting up, listening on ${host}:${port}`)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
logger.fatal({ err }, 'Cannot connect to mongo. Exiting.')
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
/* eslint-disable
|
|
||||||
no-dupe-keys,
|
|
||||||
*/
|
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
// TODO: This file was created by bulk-decaffeinate.
|
||||||
// Fix any style issues and re-enable lint.
|
// Fix any style issues and re-enable lint.
|
||||||
/*
|
/*
|
||||||
@@ -9,14 +6,15 @@
|
|||||||
* DS207: Consider shorter variations of null checks
|
* DS207: Consider shorter variations of null checks
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
*/
|
*/
|
||||||
const { db, ObjectId } = require('./mongodb')
|
import { db, ObjectId } from './mongodb.js'
|
||||||
const request = require('request')
|
import request from 'request'
|
||||||
const async = require('async')
|
import async from 'async'
|
||||||
const settings = require('@overleaf/settings')
|
import settings from '@overleaf/settings'
|
||||||
const { port } = settings.internal.notifications
|
import logger from '@overleaf/logger'
|
||||||
const logger = require('@overleaf/logger')
|
|
||||||
|
|
||||||
module.exports = {
|
const { port } = settings.internal.notifications
|
||||||
|
|
||||||
|
export default {
|
||||||
check(callback) {
|
check(callback) {
|
||||||
const userId = new ObjectId()
|
const userId = new ObjectId()
|
||||||
const cleanupNotifications = callback =>
|
const cleanupNotifications = callback =>
|
||||||
@@ -28,7 +26,7 @@ module.exports = {
|
|||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
})
|
})
|
||||||
logger.debug(
|
logger.debug(
|
||||||
{ userId, opts: getOpts(), key: notificationKey, userId },
|
{ opts: getOpts(), key: notificationKey, userId },
|
||||||
'Health Check: running'
|
'Health Check: running'
|
||||||
)
|
)
|
||||||
const jobs = [
|
const jobs = [
|
||||||
|
|||||||
@@ -1,18 +1,7 @@
|
|||||||
/* eslint-disable
|
import logger from '@overleaf/logger'
|
||||||
no-unused-vars,
|
import { db, ObjectId } from './mongodb.js'
|
||||||
*/
|
|
||||||
// TODO: This file was created by bulk-decaffeinate.
|
|
||||||
// Fix any style issues and re-enable lint.
|
|
||||||
/*
|
|
||||||
* decaffeinate suggestions:
|
|
||||||
* DS102: Remove unnecessary code created because of implicit returns
|
|
||||||
* DS207: Consider shorter variations of null checks
|
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
||||||
*/
|
|
||||||
const logger = require('@overleaf/logger')
|
|
||||||
const { db, ObjectId } = require('./mongodb')
|
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
getUserNotifications(userId, callback) {
|
getUserNotifications(userId, callback) {
|
||||||
if (callback == null) {
|
if (callback == null) {
|
||||||
callback = function () {}
|
callback = function () {}
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
* DS207: Consider shorter variations of null checks
|
* DS207: Consider shorter variations of null checks
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
*/
|
*/
|
||||||
const Notifications = require('./Notifications')
|
import logger from '@overleaf/logger'
|
||||||
const logger = require('@overleaf/logger')
|
import metrics from '@overleaf/metrics'
|
||||||
const metrics = require('@overleaf/metrics')
|
import Notifications from './Notifications.js'
|
||||||
|
|
||||||
module.exports = {
|
export default {
|
||||||
getUserNotifications(req, res, next) {
|
getUserNotifications(req, res, next) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
{ userId: req.params.user_id },
|
{ userId: req.params.user_id },
|
||||||
|
|||||||
@@ -1,26 +1,22 @@
|
|||||||
// @ts-check
|
import Metrics from '@overleaf/metrics'
|
||||||
|
import MongoUtils from '@overleaf/mongo-utils'
|
||||||
|
import Settings from '@overleaf/settings'
|
||||||
|
import mongodb from 'mongodb-legacy'
|
||||||
|
|
||||||
const Metrics = require('@overleaf/metrics')
|
export const mongoClient = new mongodb.MongoClient(
|
||||||
const MongoUtils = require('@overleaf/mongo-utils')
|
Settings.mongo.url,
|
||||||
const Settings = require('@overleaf/settings')
|
Settings.mongo.options
|
||||||
const { MongoClient, ObjectId } = require('mongodb-legacy')
|
)
|
||||||
|
|
||||||
const mongoClient = new MongoClient(Settings.mongo.url, Settings.mongo.options)
|
|
||||||
const mongoDb = mongoClient.db()
|
const mongoDb = mongoClient.db()
|
||||||
|
|
||||||
const db = {
|
export const db = {
|
||||||
notifications: mongoDb.collection('notifications'),
|
notifications: mongoDb.collection('notifications'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const ObjectId = mongodb.ObjectId
|
||||||
|
|
||||||
Metrics.mongodb.monitor(mongoClient)
|
Metrics.mongodb.monitor(mongoClient)
|
||||||
|
|
||||||
async function cleanupTestDatabase() {
|
export async function cleanupTestDatabase() {
|
||||||
await MongoUtils.cleanupTestDatabase(mongoClient)
|
await MongoUtils.cleanupTestDatabase(mongoClient)
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
db,
|
|
||||||
mongoClient,
|
|
||||||
ObjectId,
|
|
||||||
cleanupTestDatabase,
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"description": "An API to handle user notifications",
|
"description": "An API to handle user notifications",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "app.js",
|
"main": "app.js",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node app.js",
|
"start": "node app.js",
|
||||||
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
"test:acceptance:_run": "mocha --recursive --reporter spec --timeout 15000 --exit $@ test/acceptance/js",
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
*/
|
*/
|
||||||
const sinon = require('sinon')
|
import { stub } from 'sinon'
|
||||||
const modulePath = '../../../app/js/NotificationsController.js'
|
import { require as _require } from 'sandboxed-module'
|
||||||
const SandboxedModule = require('sandboxed-module')
|
import assert from 'node:assert'
|
||||||
const assert = require('node:assert')
|
|
||||||
|
|
||||||
|
const modulePath = '../../../app/js/NotificationsController.js'
|
||||||
const userId = '51dc93e6fb625a261300003b'
|
const userId = '51dc93e6fb625a261300003b'
|
||||||
const notificationId = 'fb625a26f09d'
|
const notificationId = 'fb625a26f09d'
|
||||||
const notificationKey = 'my-notification-key'
|
const notificationKey = 'my-notification-key'
|
||||||
@@ -22,11 +22,11 @@ describe('Notifications Controller', function () {
|
|||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
const self = this
|
const self = this
|
||||||
this.notifications = {}
|
this.notifications = {}
|
||||||
this.controller = SandboxedModule.require(modulePath, {
|
this.controller = _require(modulePath, {
|
||||||
requires: {
|
requires: {
|
||||||
'./Notifications': this.notifications,
|
'./Notifications': this.notifications,
|
||||||
'@overleaf/metrics': {
|
'@overleaf/metrics': {
|
||||||
inc: sinon.stub(),
|
inc: stub(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@@ -42,9 +42,11 @@ describe('Notifications Controller', function () {
|
|||||||
|
|
||||||
describe('getUserNotifications', function () {
|
describe('getUserNotifications', function () {
|
||||||
return it('should ask the notifications for the users notifications', function (done) {
|
return it('should ask the notifications for the users notifications', function (done) {
|
||||||
this.notifications.getUserNotifications = sinon
|
this.notifications.getUserNotifications = stub().callsArgWith(
|
||||||
.stub()
|
1,
|
||||||
.callsArgWith(1, null, this.stubbedNotification)
|
null,
|
||||||
|
this.stubbedNotification
|
||||||
|
)
|
||||||
const req = {
|
const req = {
|
||||||
params: {
|
params: {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
@@ -64,7 +66,7 @@ describe('Notifications Controller', function () {
|
|||||||
|
|
||||||
describe('addNotification', function () {
|
describe('addNotification', function () {
|
||||||
return it('should tell the notifications to add the notification for the user', function (done) {
|
return it('should tell the notifications to add the notification for the user', function (done) {
|
||||||
this.notifications.addNotification = sinon.stub().callsArgWith(2)
|
this.notifications.addNotification = stub().callsArgWith(2)
|
||||||
const req = {
|
const req = {
|
||||||
params: {
|
params: {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
@@ -85,7 +87,7 @@ describe('Notifications Controller', function () {
|
|||||||
|
|
||||||
describe('removeNotificationId', function () {
|
describe('removeNotificationId', function () {
|
||||||
return it('should tell the notifications to mark the notification Id as read', function (done) {
|
return it('should tell the notifications to mark the notification Id as read', function (done) {
|
||||||
this.notifications.removeNotificationId = sinon.stub().callsArgWith(2)
|
this.notifications.removeNotificationId = stub().callsArgWith(2)
|
||||||
const req = {
|
const req = {
|
||||||
params: {
|
params: {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
@@ -106,7 +108,7 @@ describe('Notifications Controller', function () {
|
|||||||
|
|
||||||
describe('removeNotificationKey', function () {
|
describe('removeNotificationKey', function () {
|
||||||
return it('should tell the notifications to mark the notification Key as read', function (done) {
|
return it('should tell the notifications to mark the notification Key as read', function (done) {
|
||||||
this.notifications.removeNotificationKey = sinon.stub().callsArgWith(2)
|
this.notifications.removeNotificationKey = stub().callsArgWith(2)
|
||||||
const req = {
|
const req = {
|
||||||
params: {
|
params: {
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
@@ -127,9 +129,7 @@ describe('Notifications Controller', function () {
|
|||||||
|
|
||||||
return describe('removeNotificationByKeyOnly', function () {
|
return describe('removeNotificationByKeyOnly', function () {
|
||||||
return it('should tell the notifications to mark the notification Key as read', function (done) {
|
return it('should tell the notifications to mark the notification Key as read', function (done) {
|
||||||
this.notifications.removeNotificationByKeyOnly = sinon
|
this.notifications.removeNotificationByKeyOnly = stub().callsArgWith(1)
|
||||||
.stub()
|
|
||||||
.callsArgWith(1)
|
|
||||||
const req = {
|
const req = {
|
||||||
params: {
|
params: {
|
||||||
key: notificationKey,
|
key: notificationKey,
|
||||||
|
|||||||
@@ -10,24 +10,24 @@
|
|||||||
* DS102: Remove unnecessary code created because of implicit returns
|
* DS102: Remove unnecessary code created because of implicit returns
|
||||||
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
||||||
*/
|
*/
|
||||||
const sinon = require('sinon')
|
import { stub, assert as _assert } from 'sinon'
|
||||||
const { expect } = require('chai')
|
import { expect } from 'chai'
|
||||||
const modulePath = '../../../app/js/Notifications.js'
|
import { require as _require } from 'sandboxed-module'
|
||||||
const SandboxedModule = require('sandboxed-module')
|
import { deepEqual } from 'node:assert'
|
||||||
const assert = require('node:assert')
|
import { ObjectId } from 'mongodb-legacy'
|
||||||
const { ObjectId } = require('mongodb-legacy')
|
|
||||||
|
|
||||||
|
const modulePath = '../../../app/js/Notifications.js'
|
||||||
const userId = '51dc93e6fb625a261300003b'
|
const userId = '51dc93e6fb625a261300003b'
|
||||||
const notificationId = '574ee8d6f40c3a244e704249'
|
const notificationId = '574ee8d6f40c3a244e704249'
|
||||||
const notificationKey = 'notification-key'
|
const notificationKey = 'notification-key'
|
||||||
|
|
||||||
describe('Notifications Tests', function () {
|
describe('Notifications Tests', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
this.findToArrayStub = sinon.stub()
|
this.findToArrayStub = stub()
|
||||||
this.findStub = sinon.stub().returns({ toArray: this.findToArrayStub })
|
this.findStub = stub().returns({ toArray: this.findToArrayStub })
|
||||||
this.countStub = sinon.stub()
|
this.countStub = stub()
|
||||||
this.updateOneStub = sinon.stub()
|
this.updateOneStub = stub()
|
||||||
this.deleteOneStub = sinon.stub()
|
this.deleteOneStub = stub()
|
||||||
this.db = {
|
this.db = {
|
||||||
notifications: {
|
notifications: {
|
||||||
find: this.findStub,
|
find: this.findStub,
|
||||||
@@ -37,7 +37,7 @@ describe('Notifications Tests', function () {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
this.notifications = SandboxedModule.require(modulePath, {
|
this.notifications = _require(modulePath, {
|
||||||
requires: {
|
requires: {
|
||||||
'@overleaf/settings': {},
|
'@overleaf/settings': {},
|
||||||
'./mongodb': { db: this.db, ObjectId },
|
'./mongodb': { db: this.db, ObjectId },
|
||||||
@@ -61,7 +61,7 @@ describe('Notifications Tests', function () {
|
|||||||
(err, notifications) => {
|
(err, notifications) => {
|
||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
notifications.should.equal(this.stubbedNotificationArray)
|
notifications.should.equal(this.stubbedNotificationArray)
|
||||||
assert.deepEqual(this.findStub.args[0][0], {
|
deepEqual(this.findStub.args[0][0], {
|
||||||
user_id: new ObjectId(userId),
|
user_id: new ObjectId(userId),
|
||||||
templateKey: { $exists: true },
|
templateKey: { $exists: true },
|
||||||
})
|
})
|
||||||
@@ -99,7 +99,7 @@ describe('Notifications Tests', function () {
|
|||||||
this.stubbedNotification,
|
this.stubbedNotification,
|
||||||
err => {
|
err => {
|
||||||
expect(err).not.to.exist
|
expect(err).not.to.exist
|
||||||
sinon.assert.calledWith(
|
_assert.calledWith(
|
||||||
this.updateOneStub,
|
this.updateOneStub,
|
||||||
this.expectedQuery,
|
this.expectedQuery,
|
||||||
{ $set: this.expectedDocument },
|
{ $set: this.expectedDocument },
|
||||||
@@ -121,7 +121,7 @@ describe('Notifications Tests', function () {
|
|||||||
this.stubbedNotification,
|
this.stubbedNotification,
|
||||||
err => {
|
err => {
|
||||||
expect(err).not.to.exist
|
expect(err).not.to.exist
|
||||||
sinon.assert.notCalled(this.updateOneStub)
|
_assert.notCalled(this.updateOneStub)
|
||||||
return done()
|
return done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -134,7 +134,7 @@ describe('Notifications Tests', function () {
|
|||||||
this.stubbedNotification,
|
this.stubbedNotification,
|
||||||
err => {
|
err => {
|
||||||
expect(err).not.to.exist
|
expect(err).not.to.exist
|
||||||
sinon.assert.calledWith(
|
_assert.calledWith(
|
||||||
this.updateOneStub,
|
this.updateOneStub,
|
||||||
this.expectedQuery,
|
this.expectedQuery,
|
||||||
{ $set: this.expectedDocument },
|
{ $set: this.expectedDocument },
|
||||||
@@ -174,7 +174,7 @@ describe('Notifications Tests', function () {
|
|||||||
this.stubbedNotification,
|
this.stubbedNotification,
|
||||||
err => {
|
err => {
|
||||||
expect(err).not.to.exist
|
expect(err).not.to.exist
|
||||||
sinon.assert.calledWith(
|
_assert.calledWith(
|
||||||
this.updateOneStub,
|
this.updateOneStub,
|
||||||
this.expectedQuery,
|
this.expectedQuery,
|
||||||
{ $set: this.expectedDocument },
|
{ $set: this.expectedDocument },
|
||||||
@@ -210,7 +210,7 @@ describe('Notifications Tests', function () {
|
|||||||
this.stubbedNotification,
|
this.stubbedNotification,
|
||||||
err => {
|
err => {
|
||||||
;(err instanceof Error).should.equal(true)
|
;(err instanceof Error).should.equal(true)
|
||||||
sinon.assert.notCalled(this.updateOneStub)
|
_assert.notCalled(this.updateOneStub)
|
||||||
return done()
|
return done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -234,8 +234,8 @@ describe('Notifications Tests', function () {
|
|||||||
const updateOperation = {
|
const updateOperation = {
|
||||||
$unset: { templateKey: true, messageOpts: true },
|
$unset: { templateKey: true, messageOpts: true },
|
||||||
}
|
}
|
||||||
assert.deepEqual(this.updateOneStub.args[0][0], searchOps)
|
deepEqual(this.updateOneStub.args[0][0], searchOps)
|
||||||
assert.deepEqual(this.updateOneStub.args[0][1], updateOperation)
|
deepEqual(this.updateOneStub.args[0][1], updateOperation)
|
||||||
return done()
|
return done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -258,8 +258,8 @@ describe('Notifications Tests', function () {
|
|||||||
const updateOperation = {
|
const updateOperation = {
|
||||||
$unset: { templateKey: true },
|
$unset: { templateKey: true },
|
||||||
}
|
}
|
||||||
assert.deepEqual(this.updateOneStub.args[0][0], searchOps)
|
deepEqual(this.updateOneStub.args[0][0], searchOps)
|
||||||
assert.deepEqual(this.updateOneStub.args[0][1], updateOperation)
|
deepEqual(this.updateOneStub.args[0][1], updateOperation)
|
||||||
return done()
|
return done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -276,8 +276,8 @@ describe('Notifications Tests', function () {
|
|||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
const searchOps = { key: notificationKey }
|
const searchOps = { key: notificationKey }
|
||||||
const updateOperation = { $unset: { templateKey: true } }
|
const updateOperation = { $unset: { templateKey: true } }
|
||||||
assert.deepEqual(this.updateOneStub.args[0][0], searchOps)
|
deepEqual(this.updateOneStub.args[0][0], searchOps)
|
||||||
assert.deepEqual(this.updateOneStub.args[0][1], updateOperation)
|
deepEqual(this.updateOneStub.args[0][1], updateOperation)
|
||||||
return done()
|
return done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -293,7 +293,7 @@ describe('Notifications Tests', function () {
|
|||||||
err => {
|
err => {
|
||||||
if (err) return done(err)
|
if (err) return done(err)
|
||||||
const searchOps = { key: notificationKey }
|
const searchOps = { key: notificationKey }
|
||||||
assert.deepEqual(this.deleteOneStub.args[0][0], searchOps)
|
deepEqual(this.deleteOneStub.args[0][0], searchOps)
|
||||||
return done()
|
return done()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
const { defineConfig } = require('vitest/config')
|
||||||
|
|
||||||
|
module.exports = defineConfig({
|
||||||
|
test: {
|
||||||
|
include: ['test/unit/js/**/*.test.js'],
|
||||||
|
setupFiles: ['./test/setup.js'],
|
||||||
|
isolate: false,
|
||||||
|
},
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user