wbxcallprov/test/greetingSelector.test.js
jmcqueen 6de5392e90
Some checks are pending
CI / verify (push) Waiting to run
Add node:test suite and Gitea Actions CI
- 30-test suite (node --test, no framework) covering the exact functions
  that have regressed in previous rounds:
    * parseStoreArg / parseStoreNumber / storeEmail (helpers)
    * greetingForBrand (brand fallback)
    * formatE911Address / formatSuite (google response reducer)
    * parseNextLink (RFC-5988 pagination — now exported)
    * runStep success / non-critical / critical / no-bot paths
- test/setup.js stubs required env vars so any src/ module can be
  imported cleanly; loaded via --import once per test process
- npm run test wired up; directory form works on Node 20 + 22
- .gitea/workflows/ci.yml runs lint + format:check + test on push/PR
  to main, on Node 22 to match the runtime image
- Exclude test/ and .gitea/ from the Docker build context
- Exclude docker/ from bot Prettier scope (remote-agent is its own
  sub-project with its own tooling)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 16:07:02 -04:00

29 lines
1.2 KiB
JavaScript

import { describe, it } from 'node:test';
import assert from 'node:assert/strict';
import { greetingForBrand } from '../src/flows/greetingSelector.js';
import { GREETINGS } from '../src/constants.js';
describe('greetingForBrand', () => {
it('returns the correct file+label for a known brand', () => {
const result = greetingForBrand({ brand: 'Aerie', storeNumber: 792 });
assert.equal(result.file, GREETINGS.Aerie.file);
assert.equal(result.fileName, '792 - Aerie Greeting.wav');
});
it('picks the American Eagle greeting for the AE brand', () => {
const result = greetingForBrand({
brand: 'American Eagle Outfitters',
storeNumber: 499,
});
assert.equal(result.file, GREETINGS['American Eagle Outfitters'].file);
assert.equal(result.fileName, '499 - AE Greeting.wav');
});
it('falls back to the AE greeting for unknown brands', () => {
const result = greetingForBrand({ brand: 'MysteryBrand', storeNumber: 42 });
assert.equal(result.file, GREETINGS['American Eagle Outfitters'].file);
// Filename still reflects the caller's storeNumber and the AE label.
assert.equal(result.fileName, '42 - AE Greeting.wav');
});
});