62 lines
1.3 KiB
TypeScript
62 lines
1.3 KiB
TypeScript
import { describe, test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
|
|
import {
|
|
parseBetJobFields,
|
|
BET_CONSUMER_GROUP,
|
|
} from '../realtime/streams/betQueue';
|
|
|
|
describe('betQueue', () => {
|
|
test('parseBetJobFields round-trips job payload', () => {
|
|
const fields = [
|
|
'userId',
|
|
'user-1',
|
|
'direction',
|
|
'long',
|
|
'stakeDisplay',
|
|
'25.5',
|
|
'intervalMinutes',
|
|
'1',
|
|
'stakeAccountKind',
|
|
'bonus',
|
|
'idempotencyKey',
|
|
'key-abc',
|
|
'source',
|
|
'http',
|
|
'requestedAt',
|
|
'1710000000000',
|
|
];
|
|
const job = parseBetJobFields(fields);
|
|
assert.deepEqual(job, {
|
|
userId: 'user-1',
|
|
direction: 'long',
|
|
stakeDisplay: 25.5,
|
|
intervalMinutes: 1,
|
|
stakeAccountKind: 'bonus',
|
|
idempotencyKey: 'key-abc',
|
|
source: 'http',
|
|
requestedAt: 1710000000000,
|
|
});
|
|
});
|
|
|
|
test('parseBetJobFields rejects invalid direction', () => {
|
|
const job = parseBetJobFields([
|
|
'userId',
|
|
'u1',
|
|
'direction',
|
|
'up',
|
|
'stakeDisplay',
|
|
'10',
|
|
'intervalMinutes',
|
|
'1',
|
|
'idempotencyKey',
|
|
'k1',
|
|
]);
|
|
assert.equal(job, null);
|
|
});
|
|
|
|
test('consumer group name is stable', () => {
|
|
assert.equal(BET_CONSUMER_GROUP, 'prediqo-bet-workers');
|
|
});
|
|
});
|