From 8b9072fa7ea3f09e6da3218c0251fc438482f249 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 25 Dec 2025 14:00:43 +0100 Subject: [PATCH] test: cover auto engine behavior --- tests/engine.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tests/engine.test.ts diff --git a/tests/engine.test.ts b/tests/engine.test.ts new file mode 100644 index 0000000..cf5f614 --- /dev/null +++ b/tests/engine.test.ts @@ -0,0 +1,22 @@ +import { describe, expect, it } from 'vitest'; +import { resolveEngineMode, shouldUseSweetistics } from '../src/lib/engine.js'; + +describe('engine', () => { + it('normalizes engine values and defaults to auto', () => { + expect(resolveEngineMode()).toBe('auto'); + expect(resolveEngineMode('graphql')).toBe('graphql'); + expect(resolveEngineMode('sweetistics')).toBe('sweetistics'); + expect(resolveEngineMode('AUTO')).toBe('auto'); + expect(resolveEngineMode('nope')).toBe('auto'); + }); + + it('uses GraphQL as primary in auto mode', () => { + expect(shouldUseSweetistics('auto', false)).toBe(false); + expect(shouldUseSweetistics('auto', true)).toBe(false); + }); + + it('forces engine selection when explicitly set', () => { + expect(shouldUseSweetistics('sweetistics', false)).toBe(true); + expect(shouldUseSweetistics('graphql', true)).toBe(false); + }); +});