mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
Adapted from https://github.com/NousResearch/hermes-agent/pull/51893 (a70b0991b2).
Co-authored-by: brooklyn! <[email protected]>
22 lines
904 B
TypeScript
22 lines
904 B
TypeScript
import assert from 'node:assert/strict'
|
|
|
|
import { test } from 'vitest'
|
|
|
|
import { resolveNotificationAction } from './notification-actions'
|
|
|
|
const actions = [
|
|
{ id: 'approve', text: 'Approve' },
|
|
{ id: 'reject', text: 'Reject' }
|
|
]
|
|
|
|
test('prefers Electron event details and supports the legacy positional index', () => {
|
|
assert.deepEqual(resolveNotificationAction(actions, { actionIndex: 1 }, undefined), actions[1])
|
|
assert.deepEqual(resolveNotificationAction(actions, {}, 0), actions[0])
|
|
assert.deepEqual(resolveNotificationAction(actions, { actionIndex: 1 }, 0), actions[1])
|
|
})
|
|
|
|
test('ignores missing and out-of-range action indexes', () => {
|
|
assert.equal(resolveNotificationAction(actions, {}, undefined), null)
|
|
assert.equal(resolveNotificationAction(actions, { actionIndex: -1 }, undefined), null)
|
|
assert.equal(resolveNotificationAction(actions, { actionIndex: 2 }, undefined), null)
|
|
})
|