XuqmGroup-RNSDK/packages/update/tests/update-availability.test.ts

26 行
754 B
TypeScript

import assert from 'node:assert/strict'
import test from 'node:test'
import { assertUpdateEnabled, UpdateDisabledError } from '../src/updateAvailability'
test('disabled update rejects before any network operation', () => {
let networkCalls = 0
const operation = () => {
assertUpdateEnabled(false)
networkCalls += 1
}
assert.throws(operation, (error: unknown) => {
assert.equal(error instanceof UpdateDisabledError, true)
assert.equal((error as UpdateDisabledError).code, 'UPDATE_DISABLED')
return true
})
assert.equal(networkCalls, 0)
})
test('explicitly enabled update allows the operation to continue', () => {
let networkCalls = 0
assertUpdateEnabled(true)
networkCalls += 1
assert.equal(networkCalls, 1)
})