@livestore/livestore 0.4.0-dev.6 → 0.4.0-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,103 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { StoreAlreadyShutdownError } from '@livestore/common';
3
- // Mock a minimal store interface for testing
4
- class MockStore {
5
- isShutdown = false;
6
- storeId = 'test-store';
7
- checkShutdown = (operation) => {
8
- if (this.isShutdown) {
9
- throw new StoreAlreadyShutdownError({ operation, storeId: this.storeId });
10
- }
11
- };
12
- shutdown = () => {
13
- this.isShutdown = true;
14
- };
15
- // Mock public methods that should throw after shutdown
16
- subscribe = () => {
17
- this.checkShutdown('subscribe');
18
- return () => { }; // mock unsubscribe
19
- };
20
- query = () => {
21
- this.checkShutdown('query');
22
- return {};
23
- };
24
- commit = () => {
25
- this.checkShutdown('commit');
26
- };
27
- setSignal = () => {
28
- this.checkShutdown('setSignal');
29
- };
30
- manualRefresh = () => {
31
- this.checkShutdown('manualRefresh');
32
- };
33
- events = () => {
34
- this.checkShutdown('events');
35
- return [];
36
- };
37
- eventsStream = () => {
38
- this.checkShutdown('eventsStream');
39
- return [];
40
- };
41
- }
42
- describe('Store shutdown behavior', () => {
43
- it('should allow operations before shutdown', () => {
44
- const store = new MockStore();
45
- // All operations should work before shutdown
46
- expect(() => store.subscribe()).not.toThrow();
47
- expect(() => store.query()).not.toThrow();
48
- expect(() => store.commit()).not.toThrow();
49
- expect(() => store.setSignal()).not.toThrow();
50
- expect(() => store.manualRefresh()).not.toThrow();
51
- expect(() => store.events()).not.toThrow();
52
- expect(() => store.eventsStream()).not.toThrow();
53
- });
54
- it('should throw StoreAlreadyShutdownError for all operations after shutdown', () => {
55
- const store = new MockStore();
56
- store.shutdown();
57
- // All operations should throw after shutdown
58
- expect(() => store.subscribe()).toThrow(StoreAlreadyShutdownError);
59
- expect(() => store.query()).toThrow(StoreAlreadyShutdownError);
60
- expect(() => store.commit()).toThrow(StoreAlreadyShutdownError);
61
- expect(() => store.setSignal()).toThrow(StoreAlreadyShutdownError);
62
- expect(() => store.manualRefresh()).toThrow(StoreAlreadyShutdownError);
63
- expect(() => store.events()).toThrow(StoreAlreadyShutdownError);
64
- expect(() => store.eventsStream()).toThrow(StoreAlreadyShutdownError);
65
- });
66
- it('should include operation name and storeId in error', () => {
67
- const store = new MockStore();
68
- store.shutdown();
69
- try {
70
- store.subscribe();
71
- expect.fail('Should have thrown');
72
- }
73
- catch (error) {
74
- expect(error).toBeInstanceOf(StoreAlreadyShutdownError);
75
- expect(error.operation).toBe('subscribe');
76
- expect(error.storeId).toBe('test-store');
77
- }
78
- });
79
- it('should include correct operation name for different methods', () => {
80
- const store = new MockStore();
81
- store.shutdown();
82
- const operations = [
83
- ['subscribe', () => store.subscribe()],
84
- ['query', () => store.query()],
85
- ['commit', () => store.commit()],
86
- ['setSignal', () => store.setSignal()],
87
- ['manualRefresh', () => store.manualRefresh()],
88
- ['events', () => store.events()],
89
- ['eventsStream', () => store.eventsStream()],
90
- ];
91
- for (const [expectedOperation, fn] of operations) {
92
- try {
93
- fn();
94
- expect.fail(`Should have thrown for ${expectedOperation}`);
95
- }
96
- catch (error) {
97
- expect(error).toBeInstanceOf(StoreAlreadyShutdownError);
98
- expect(error.operation).toBe(expectedOperation);
99
- }
100
- }
101
- });
102
- });
103
- //# sourceMappingURL=store-shutdown.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store-shutdown.test.js","sourceRoot":"","sources":["../../src/store/store-shutdown.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAA;AAE7D,6CAA6C;AAC7C,MAAM,SAAS;IACL,UAAU,GAAG,KAAK,CAAA;IACjB,OAAO,GAAG,YAAY,CAAA;IAEvB,aAAa,GAAG,CAAC,SAAiB,EAA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