Skip to content

Commit

Permalink
more eslint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReadWriteError committed Mar 13, 2024
1 parent 6341e93 commit 5de47d7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion tests/constants/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const USER_DELETED = 'user-deleted'

export const GLOBAL_CREATED = 'global-created'
export const GLOBAL_UPDATED = 'global-updated'
export const GLOBAL_DELETED = 'global-deleted'
export const GLOBAL_DELETED = 'global-deleted'
26 changes: 13 additions & 13 deletions tests/plugin-global.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('plugin - global', () => {
eventCreated: GLOBAL_CREATED,
eventUpdated: GLOBAL_UPDATED,
eventDeleted: GLOBAL_DELETED,
omit: ['__v', 'createdAt', 'updatedAt']
omit: ['__v', 'createdAt', 'updatedAt'],
})

const Product = mongoose.model('Product', ProductSchema)
Expand Down Expand Up @@ -50,7 +50,7 @@ describe('plugin - global', () => {
expect(history).toHaveLength(3)

const [first, second, third] = history

// 1 create
expect(first.version).toBe(0)
expect(first.op).toBe('create')
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('plugin - global', () => {
expect(second.patch).toHaveLength(2)
expect(second.patch).toMatchObject([
{ op: 'test', path: '/description/summary', value: 'test1' },
{ op: 'replace', path: '/description/summary', value: 'test2' }
{ op: 'replace', path: '/description/summary', value: 'test2' },
])

// 3 update
Expand All @@ -93,20 +93,20 @@ describe('plugin - global', () => {
expect(third.patch).toHaveLength(2)
expect(third.patch).toMatchObject([
{ op: 'test', path: '/description/summary', value: 'test2' },
{ op: 'replace', path: '/description/summary', value: 'test3' }
{ op: 'replace', path: '/description/summary', value: 'test3' },
])

expect(em.emit).toHaveBeenCalledTimes(3)
expect(em.emit).toHaveBeenCalledWith(GLOBAL_CREATED, { doc: first.doc })
expect(em.emit).toHaveBeenCalledWith(GLOBAL_UPDATED, {
oldDoc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test1' } }),
doc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test2' } }),
patch: second.patch
patch: second.patch,
})
expect(em.emit).toHaveBeenCalledWith(GLOBAL_UPDATED, {
oldDoc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test2' } }),
doc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test3' } }),
patch: third.patch
patch: third.patch,
})
})

Expand All @@ -115,18 +115,18 @@ describe('plugin - global', () => {
expect(product.name).toBe('paper')

await product.updateOne({
description: { summary: 'test2' }
description: { summary: 'test2' },
}).exec()

await product.updateOne({
$set: { 'description.summary': 'test3' }
$set: { 'description.summary': 'test3' },
}).exec()

const history = await History.find({})
expect(history).toHaveLength(3)

const [first, second, third] = history

// 1 create
expect(first.version).toBe(0)
expect(first.op).toBe('create')
Expand Down Expand Up @@ -154,7 +154,7 @@ describe('plugin - global', () => {
expect(second.patch).toHaveLength(2)
expect(second.patch).toMatchObject([
{ op: 'test', path: '/description/summary', value: 'test1' },
{ op: 'replace', path: '/description/summary', value: 'test2' }
{ op: 'replace', path: '/description/summary', value: 'test2' },
])

// 3 update
Expand All @@ -169,20 +169,20 @@ describe('plugin - global', () => {
expect(third.patch).toHaveLength(2)
expect(third.patch).toMatchObject([
{ op: 'test', path: '/description/summary', value: 'test2' },
{ op: 'replace', path: '/description/summary', value: 'test3' }
{ op: 'replace', path: '/description/summary', value: 'test3' },
])

expect(em.emit).toHaveBeenCalledTimes(3)
expect(em.emit).toHaveBeenCalledWith(GLOBAL_CREATED, { doc: first.doc })
expect(em.emit).toHaveBeenCalledWith(GLOBAL_UPDATED, {
oldDoc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test1' } }),
doc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test2' } }),
patch: second.patch
patch: second.patch,
})
expect(em.emit).toHaveBeenCalledWith(GLOBAL_UPDATED, {
oldDoc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test2' } }),
doc: expect.objectContaining({ _id: product._id, name: 'paper', description: { summary: 'test3' } }),
patch: third.patch
patch: third.patch,
})
})
})
4 changes: 2 additions & 2 deletions tests/schemas/DescriptionSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type IDescription from '../interfaces/IDescription'
const DescriptionSchema = new Schema<IDescription>({
summary: {
type: String,
required: true
}
required: true,
},
}, { timestamps: false, _id: false })

export default DescriptionSchema
6 changes: 3 additions & 3 deletions tests/schemas/ProductSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ import type IProduct from '../interfaces/IProduct'
const ProductSchema = new Schema<IProduct>({
name: {
type: String,
required: true
required: true,
},
description: {
type: DescriptionSchema,
required: false
}
required: false,
},
}, { timestamps: true })

export default ProductSchema

0 comments on commit 5de47d7

Please sign in to comment.