Skip to content

Commit

Permalink
fix testrs
Browse files Browse the repository at this point in the history
  • Loading branch information
xnerhu committed Nov 26, 2023
1 parent c627f4e commit 1a51978
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions playground/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
isDesktopWebKit,
isIPad,
} from '../src/utils/browser'
import { getBrowserVersion } from '../tests/utils'
import './style.css'

type DetectionResult =
Expand Down Expand Up @@ -41,6 +42,7 @@ const runDetection = async (): Promise<DetectionResult> => {
const debugData = {
browserEngineKind: getBrowserEngineKind(),
browserKind: getBrowserKind(),
browserVersion: getBrowserVersion(),
documentFocus: getDocumentFocus(),
mozAppearanceSupport: getMozAppearanceSupport(),
isAndroid: isAndroid(),
Expand Down
14 changes: 11 additions & 3 deletions src/sources/notification_permissions.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { getBrowserMajorVersion, getBrowserVersion, isHeadlessChrome, isMobile, isWebKit } from '../../tests/utils'
import { BotdError, BrowserKind } from '../types'
import { getBrowserKind, isDesktopWebKit } from '../utils/browser'
import { BotdError, BrowserEngineKind, BrowserKind } from '../types'
import { getBrowserEngineKind, getBrowserKind, isDesktopWebKit } from '../utils/browser'
import getNotificationPermissions from './notification_permissions'

describe('Sources', () => {
describe('notificaionPermissions', () => {
it('returns an expected value or throws', async () => {
if (
getBrowserKind() === BrowserKind.Safari &&
getBrowserEngineKind() === BrowserEngineKind.Webkit &&
!isDesktopWebKit()
) {
return
}

const { major, minor } = getBrowserVersion() ?? { major: 0, minor: 0 }
if (isWebKit() && (major < 16 || (major === 16 && minor < 5))) {
await expectAsync(getNotificationPermissions()).toBeRejectedWithError(
Expand All @@ -21,7 +29,7 @@ describe('Sources', () => {

const result = await getNotificationPermissions()

if (isHeadlessChrome() || (isWebKit() && !isDesktopWebKit() && getBrowserKind() !== BrowserKind.Safari)) {
if (isHeadlessChrome() || isWebKit()) {
// It's true because HeadlessChrome returns "denied" and not "default".
expect(result).toBeTrue()
return
Expand Down

0 comments on commit 1a51978

Please sign in to comment.