Closer/functions/dist/couples/onCoupleKeyRotated.test.js

24 lines
1.5 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const onCoupleKeyRotated_1 = require("./onCoupleKeyRotated");
describe('isKeyGenerationIncrease', () => {
it('fires on a genuine rotation (0 → 1, and every later bump)', () => {
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(undefined, 1)).toBe(true);
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(0, 1)).toBe(true);
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(3, 4)).toBe(true);
});
it('ignores every non-rotation update to the couple doc', () => {
// The trigger watches the whole couple doc — streaks, rhythm, recovery re-wraps all pass through here.
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(undefined, undefined)).toBe(false);
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(2, 2)).toBe(false);
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(0, undefined)).toBe(false);
});
it('never fires on a downgrade — rules forbid it, but a redelivered stale event must not alert either', () => {
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(5, 4)).toBe(false);
});
it('treats junk as zero rather than alerting on garbage', () => {
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)('x', 'y')).toBe(false);
expect((0, onCoupleKeyRotated_1.isKeyGenerationIncrease)(null, 'high')).toBe(false);
});
});
//# sourceMappingURL=onCoupleKeyRotated.test.js.map