Extract admin dashboard from ghabilee-frontend2 into a dedicated Next.js app for backoffice.ghabilee.ir (no SEO indexing / Clarity).
30 lines
964 B
TypeScript
30 lines
964 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { isPlainPrimaryClick } from '@/lib/isPlainPrimaryClick'
|
|
|
|
const click = (overrides: Partial<MouseEvent> = {}) =>
|
|
({
|
|
button: 0,
|
|
metaKey: false,
|
|
ctrlKey: false,
|
|
shiftKey: false,
|
|
altKey: false,
|
|
defaultPrevented: false,
|
|
...overrides,
|
|
}) as MouseEvent
|
|
|
|
describe('isPlainPrimaryClick', () => {
|
|
it('accepts a normal left click', () => {
|
|
expect(isPlainPrimaryClick(click())).toBe(true)
|
|
})
|
|
|
|
it('rejects modified or non-primary clicks', () => {
|
|
expect(isPlainPrimaryClick(click({ metaKey: true }))).toBe(false)
|
|
expect(isPlainPrimaryClick(click({ ctrlKey: true }))).toBe(false)
|
|
expect(isPlainPrimaryClick(click({ shiftKey: true }))).toBe(false)
|
|
expect(isPlainPrimaryClick(click({ altKey: true }))).toBe(false)
|
|
expect(isPlainPrimaryClick(click({ button: 1 }))).toBe(false)
|
|
expect(isPlainPrimaryClick(click({ defaultPrevented: true }))).toBe(false)
|
|
})
|
|
})
|