397777089e
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
24 lines
1.4 KiB
JavaScript
24 lines
1.4 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { consumeDecision } from './floor-escape-consume.mjs';
|
|
describe('floor-escape-consume', () => {
|
|
const now = 1000;
|
|
it('исполненное действие с непогашенным пропуском → отметка', () => {
|
|
const r = consumeDecision({ action: 'bash:reset --hard',
|
|
grants: [{ action: 'bash:reset --hard', ts: now - 5 }], consumed: [], now });
|
|
expect(r).toEqual({ action: 'bash:reset --hard', ts: now - 5 });
|
|
});
|
|
it('уже погашено → null', () => {
|
|
const r = consumeDecision({ action: 'bash:x', grants: [{ action: 'bash:x', ts: 1 }], consumed: [{ action: 'bash:x', ts: 1 }], now });
|
|
expect(r).toBe(null);
|
|
});
|
|
it('нет совпадающего пропуска → null', () => {
|
|
expect(consumeDecision({ action: 'bash:y', grants: [{ action: 'bash:x', ts: 1 }], consumed: [], now })).toBe(null);
|
|
});
|
|
// floor-escape-consume.mjs FIX-2: гасить ИМЕННО открывший грант (единый findOpenGrant)
|
|
it('при дублях гасит свежий открывший грант, не future-ts', () => {
|
|
const r = consumeDecision({ action: 'bash:x',
|
|
grants: [{ action: 'bash:x', ts: now + 1000 }, { action: 'bash:x', ts: now - 5 }], consumed: [], now });
|
|
expect(r).toEqual({ action: 'bash:x', ts: now - 5 });
|
|
});
|
|
});
|