Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/scrambles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ details so Vite can consume it as a stable default export.
Provider selection is explicit in `index.js`:

- cubing.js is preferred for the events listed in `cubingEventIds`;
- Scrambow handles custom practice events such as PLL, ZBLL, LSE, RU, and
optimal Clock; and
- Scrambow handles 2x2 and Clock to preserve R/U/F 2x2 notation and the
conventional WCA Clock pin order, as well as custom practice events such as
PLL, ZBLL, LSE, RU, and optimal Clock; and
- unknown event IDs are rejected.

Do not treat Scrambow as a fallback for arbitrary cubing.js failures. A provider
Expand Down
2 changes: 0 additions & 2 deletions packages/scrambles/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const { generateCubingScramble } = require('./providers/cubing');
const { generateScrambowScramble } = require('./providers/scrambow');

const cubingEventIds = new Set([
'222',
'333',
'333bf',
'333oh',
Expand All @@ -16,7 +15,6 @@ const cubingEventIds = new Set([
'777',
'minx',
'pyram',
'clock',
'skewb',
'sq1',
'fto',
Expand Down
21 changes: 8 additions & 13 deletions packages/scrambles/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ const { generateCubingScramble } = require('./providers/cubing');
const { generateScrambowScramble } = require('./providers/scrambow');

const cubingEventIds = [
'222',
'333',
'333bf',
'333oh',
Expand All @@ -26,7 +25,6 @@ const cubingEventIds = [
'777',
'minx',
'pyram',
'clock',
'skewb',
'sq1',
'fto',
Expand All @@ -46,18 +44,13 @@ describe('generateScramble', () => {
expect(generateScrambowScramble).not.toHaveBeenCalled();
});

it('uses Scrambow for the custom practice events', async () => {
await expect(generateScramble('clock-optimal')).resolves.toBe('scrambow scramble');
await expect(generateScramble('pll')).resolves.toBe('scrambow scramble');
await expect(generateScramble('zbll')).resolves.toBe('scrambow scramble');
await expect(generateScramble('lse')).resolves.toBe('scrambow scramble');
await expect(generateScramble('ru')).resolves.toBe('scrambow scramble');
it('uses Scrambow for conventional Clock and 2x2 notation and custom practice events', async () => {
const scrambowEvents = ['222', 'clock', 'clock-optimal', 'pll', 'zbll', 'lse', 'ru'];

expect(generateScrambowScramble).toHaveBeenNthCalledWith(1, 'clock-optimal');
expect(generateScrambowScramble).toHaveBeenNthCalledWith(2, 'pll');
expect(generateScrambowScramble).toHaveBeenNthCalledWith(3, 'zbll');
expect(generateScrambowScramble).toHaveBeenNthCalledWith(4, 'lse');
expect(generateScrambowScramble).toHaveBeenNthCalledWith(5, 'ru');
await Promise.all(scrambowEvents.map((eventId) => expect(generateScramble(eventId)).resolves.toBe('scrambow scramble')));

expect(generateCubingScramble).not.toHaveBeenCalled();
expect(generateScrambowScramble.mock.calls.map(([eventId]) => eventId)).toEqual(scrambowEvents);
});

it('rejects events that are not in the shared catalog', async () => {
Expand All @@ -80,6 +73,8 @@ describe('events', () => {
it('contains every event supported by the generator', () => {
expect(events.map(({ id }) => id)).toEqual(expect.arrayContaining([
...cubingEventIds,
'222',
'clock',
'clock-optimal',
'pll',
'zbll',
Expand Down
Loading