Files
nimbus/resources/js/tests/stores/useConfigStore.test.ts
Mazen Touati 2895a0ddc6 feat(export): add shareable links (#41)
* feat(export): add shareable links

* chore: reconfigure PW

* test: fix namespace

* style: apply prettier

* chore: reduce workers count in CI for PW

tests are running slower (to the point some time out) and flaky

* fix: initialize pending request from store immediately

* chore: apply rector
2026-01-24 03:01:32 +01:00

47 lines
1.4 KiB
TypeScript

import { useConfigStore } from '@/stores/core/useConfigStore';
import { createPinia, setActivePinia } from 'pinia';
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
import { NimbusConfig } from '../../../types/global';
declare global {
interface Window {
Nimbus: NimbusConfig;
}
}
describe('useConfigStore', () => {
const originalNimbus = window.Nimbus;
beforeEach(() => {
setActivePinia(createPinia());
});
afterEach(() => {
window.Nimbus = originalNimbus;
});
it('reads configuration from Nimbus global', () => {
window.Nimbus = {
apiBaseUrl: 'https://example.com',
basePath: '/nimbus',
isVersioned: true,
headers: JSON.stringify([{ header: 'X-Test', type: 'raw', value: '123' }]),
currentUser: JSON.stringify({ id: 99 }),
routes: '',
routeExtractorException: null,
applications: JSON.stringify({ main: 'Main API' }),
activeApplication: 'main',
sharedState: null,
};
const store = useConfigStore();
expect(store.apiUrl).toBe('https://example.com');
expect(store.appBasePath).toBe('/nimbus');
expect(store.headers).toEqual([{ header: 'X-Test', type: 'raw', value: '123' }]);
expect(store.isVersioned).toBe(true);
expect(store.isLoggedIn).toBe(true);
expect(store.userId).toBe(99);
});
});