From 87dd00feceedab859010f754170ecae6eccbad38 Mon Sep 17 00:00:00 2001 From: geoffsee <> Date: Fri, 30 May 2025 22:29:49 -0400 Subject: [PATCH] add ui store tests --- src/stores/__tests__/UIStore.test.ts | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/stores/__tests__/UIStore.test.ts diff --git a/src/stores/__tests__/UIStore.test.ts b/src/stores/__tests__/UIStore.test.ts new file mode 100644 index 0000000..73bf4a5 --- /dev/null +++ b/src/stores/__tests__/UIStore.test.ts @@ -0,0 +1,55 @@ +import { describe, it, expect, beforeEach } from 'vitest'; +import { UIStore } from '../UIStore'; + +describe('UIStore', () => { + let uiStore; + + beforeEach(() => { + // Create a new instance of the store before each test + uiStore = UIStore.create(); + }); + + describe('Initial state', () => { + it('should have input set to empty string initially', () => { + expect(uiStore.input).toBe(''); + }); + + it('should have isLoading set to false initially', () => { + expect(uiStore.isLoading).toBe(false); + }); + }); + + describe('setInput', () => { + it('should update the input value', () => { + uiStore.setInput('Hello, world!'); + expect(uiStore.input).toBe('Hello, world!'); + }); + + it('should handle empty string', () => { + // First set to non-empty + uiStore.setInput('Hello'); + expect(uiStore.input).toBe('Hello'); + + // Then set to empty + uiStore.setInput(''); + expect(uiStore.input).toBe(''); + }); + }); + + describe('setIsLoading', () => { + it('should update the isLoading value to true', () => { + uiStore.setIsLoading(true); + expect(uiStore.isLoading).toBe(true); + }); + + it('should update the isLoading value to false', () => { + // First set to true + uiStore.setIsLoading(true); + expect(uiStore.isLoading).toBe(true); + + // Then set to false + uiStore.setIsLoading(false); + expect(uiStore.isLoading).toBe(false); + }); + }); +}); \ No newline at end of file