import assert from 'node:assert/strict'
import { describe, it } from 'node:test'
import {
isIosBrowser,
isStandaloneDisplay,
shouldShowInstallButton,
shouldShowIosInstallHint,
} from './install-state.ts'
describe('install presentation', () => {
it('hides install chrome once Lineage is on the home screen', () => {
assert.equal(
shouldShowInstallButton({
standalone: true,
ios: false,
}),
false,
)
assert.equal(
isStandaloneDisplay({
displayModeStandalone: false,
navigatorStandalone: true,
}),
true,
)
})
it('shows Install on Brave and Chromium even before beforeinstallprompt', () => {
assert.equal(
shouldShowInstallButton({
standalone: false,
ios: false,
}),
true,
)
assert.equal(
shouldShowInstallButton({
standalone: false,
ios: true,
}),
false,
)
})
it('uses the iOS Share hint instead of a fake install prompt', () => {
assert.equal(
isIosBrowser({
userAgent: 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_0 like Mac OS X)',
}),
true,
)
assert.equal(
isIosBrowser({
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)',
platform: 'MacIntel',
maxTouchPoints: 5,
}),
true,
)
assert.equal(
shouldShowIosInstallHint({
standalone: false,
ios: true,
safariFamily: true,
dismissed: false,
}),
true,
)
assert.equal(
shouldShowIosInstallHint({
standalone: false,
ios: true,
safariFamily: true,
dismissed: true,
}),
false,
)
})
})