59 lines
1.4 KiB
TypeScript
59 lines
1.4 KiB
TypeScript
import { describe, it } from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import { shouldAddKeepAliveExclude } from './keep-alive-exclude'
|
|
|
|
describe('shouldAddKeepAliveExclude', () => {
|
|
it('returns false when tab has no name or keepAlive is off', () => {
|
|
assert.equal(
|
|
shouldAddKeepAliveExclude({
|
|
tabName: undefined,
|
|
keepAlive: true,
|
|
openedHasSameName: false
|
|
}),
|
|
false
|
|
)
|
|
assert.equal(
|
|
shouldAddKeepAliveExclude({
|
|
tabName: 'CellStorageProtocolAudit',
|
|
keepAlive: false,
|
|
openedHasSameName: false
|
|
}),
|
|
false
|
|
)
|
|
})
|
|
|
|
it('skips exclude when same-name tab still open (close / worktabMulti guard)', () => {
|
|
assert.equal(
|
|
shouldAddKeepAliveExclude({
|
|
tabName: 'CellStorageProtocolAudit',
|
|
keepAlive: true,
|
|
openedHasSameName: true
|
|
}),
|
|
false
|
|
)
|
|
})
|
|
|
|
it('allows exclude when no same-name tab remains open', () => {
|
|
assert.equal(
|
|
shouldAddKeepAliveExclude({
|
|
tabName: 'ProductionPreTransitSample',
|
|
keepAlive: true,
|
|
openedHasSameName: false
|
|
}),
|
|
true
|
|
)
|
|
})
|
|
|
|
it('force=true excludes even when the tab is still in opened (tab click reload)', () => {
|
|
assert.equal(
|
|
shouldAddKeepAliveExclude({
|
|
tabName: 'CellStorageProtocolAudit',
|
|
keepAlive: true,
|
|
openedHasSameName: true,
|
|
force: true
|
|
}),
|
|
true
|
|
)
|
|
})
|
|
})
|