ngssm-store 21.1.6 → 21.1.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.
@@ -40,6 +40,8 @@ class StoreMock {
40
40
  * with a `StoreMock` instance, allowing for isolated and controlled testing of components or services
41
41
  * that depend on the `Store`.
42
42
  *
43
+ * This function registers the `Store` and the `StoreMock` with the same value.
44
+ *
43
45
  * @param action Optional callback function that receives the mock `Store` instance. Can be used to configure
44
46
  * or manipulate the mock store before it is provided to the testing environment.
45
47
  * @returns The environment providers configured with the `StoreMock`.
@@ -49,7 +51,10 @@ const provideNgssmStoreTesting = (action) => {
49
51
  if (action) {
50
52
  action(store);
51
53
  }
52
- return makeEnvironmentProviders([{ provide: Store, useValue: store }]);
54
+ return makeEnvironmentProviders([
55
+ { provide: Store, useValue: store },
56
+ { provide: StoreMock, useValue: store }
57
+ ]);
53
58
  };
54
59
 
55
60
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"ngssm-store-testing.mjs","sources":["../../../projects/ngssm-store/testing/src/store-mock.ts","../../../projects/ngssm-store/testing/src/provide-ngssm-store-testing.ts","../../../projects/ngssm-store/testing/ngssm-store-testing.ts"],"sourcesContent":["import { WritableSignal, signal } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\n\nimport { Action, ActionDispatcher, State } from 'ngssm-store';\n\nexport class StoreMock implements ActionDispatcher {\n public readonly state$: BehaviorSubject<State>;\n public readonly state: WritableSignal<State>;\n public logsEnabled = false;\n public processedAction = signal<Action>({ type: '' });\n\n private _stateValue: State = {};\n\n constructor(initialState: State) {\n this.state$ = new BehaviorSubject<State>(this._stateValue);\n this.state = signal<State>(this._stateValue);\n this.stateValue = initialState;\n }\n\n public get stateValue(): State {\n return this._stateValue;\n }\n\n public set stateValue(value: State) {\n this._stateValue = value;\n this.state$.next(value);\n this.state.set(value);\n }\n\n public dispatchAction(action: Action): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchAction]', action);\n }\n }\n\n public dispatchActionType(type: string): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchActionType]', type);\n }\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport { Store } from 'ngssm-store';\n\nimport { StoreMock } from './store-mock';\n\n/**\n * Provides a testing environment provider for the `Store` service using a mock implementation.\n *\n * This function returns Angular environment providers that replace the actual `Store` service\n * with a `StoreMock` instance, allowing for isolated and controlled testing of components or services\n * that depend on the `Store`.\n *\n * @param action Optional callback function that receives the mock `Store` instance. Can be used to configure\n * or manipulate the mock store before it is provided to the testing environment.\n * @returns The environment providers configured with the `StoreMock`.\n */\nexport const provideNgssmStoreTesting = (action?: (store: Store) => void): EnvironmentProviders => {\n const store = new StoreMock({});\n if (action) {\n action(store as unknown as Store);\n }\n return makeEnvironmentProviders([{ provide: Store, useValue: store }]);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAKa,SAAS,CAAA;AACJ,IAAA,MAAM;AACN,IAAA,KAAK;IACd,WAAW,GAAG,KAAK;IACnB,eAAe,GAAG,MAAM,CAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,iBAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;IAE7C,WAAW,GAAU,EAAE;AAE/B,IAAA,WAAA,CAAY,YAAmB,EAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,IAAI,eAAe,CAAQ,IAAI,CAAC,WAAW,CAAC;QAC1D,IAAI,CAAC,KAAK,GAAG,MAAM,CAAQ,IAAI,CAAC,WAAW,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,OAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;AAC5C,QAAA,IAAI,CAAC,UAAU,GAAG,YAAY;IAChC;AAEA,IAAA,IAAW,UAAU,GAAA;QACnB,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,IAAW,UAAU,CAAC,KAAY,EAAA;AAChC,QAAA,IAAI,CAAC,WAAW,GAAG,KAAK;AACxB,QAAA,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;AACvB,QAAA,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC;IACvB;AAEO,IAAA,cAAc,CAAC,MAAc,EAAA;AAClC,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AACpB,YAAA,OAAO,CAAC,GAAG,CAAC,8BAA8B,EAAE,MAAM,CAAC;QACrD;IACF;AAEO,IAAA,kBAAkB,CAAC,IAAY,EAAA;AACpC,QAAA,IAAI,IAAI,CAAC,WAAW,EAAE;AACpB,YAAA,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,IAAI,CAAC;QACvD;IACF;AACD;;AClCD;;;;;;;;;;AAUG;AACI,MAAM,wBAAwB,GAAG,CAAC,MAA+B,KAA0B;AAChG,IAAA,MAAM,KAAK,GAAG,IAAI,SAAS,CAAC,EAAE,CAAC;IAC/B,IAAI,MAAM,EAAE;QACV,MAAM,CAAC,KAAyB,CAAC;IACnC;AACA,IAAA,OAAO,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;AACxE;;ACvBA;;AAEG;;;;"}
1
+ {"version":3,"file":"ngssm-store-testing.mjs","sources":["../../../projects/ngssm-store/testing/src/store-mock.ts","../../../projects/ngssm-store/testing/src/provide-ngssm-store-testing.ts","../../../projects/ngssm-store/testing/ngssm-store-testing.ts"],"sourcesContent":["import { WritableSignal, signal } from '@angular/core';\nimport { BehaviorSubject } from 'rxjs';\n\nimport { Action, ActionDispatcher, State } from 'ngssm-store';\n\nexport class StoreMock implements ActionDispatcher {\n public readonly state$: BehaviorSubject<State>;\n public readonly state: WritableSignal<State>;\n public logsEnabled = false;\n public processedAction = signal<Action>({ type: '' });\n\n private _stateValue: State = {};\n\n constructor(initialState: State) {\n this.state$ = new BehaviorSubject<State>(this._stateValue);\n this.state = signal<State>(this._stateValue);\n this.stateValue = initialState;\n }\n\n public get stateValue(): State {\n return this._stateValue;\n }\n\n public set stateValue(value: State) {\n this._stateValue = value;\n this.state$.next(value);\n this.state.set(value);\n }\n\n public dispatchAction(action: Action): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchAction]', action);\n }\n }\n\n public dispatchActionType(type: string): void {\n if (this.logsEnabled) {\n console.log('[StoreMock - dispatchActionType]', type);\n }\n }\n}\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\n\nimport { Store } from 'ngssm-store';\n\nimport { StoreMock } from './store-mock';\n\n/**\n * Provides a testing environment provider for the `Store` service using a mock implementation.\n *\n * This function returns Angular environment providers that replace the actual `Store` service\n * with a `StoreMock` instance, allowing for isolated and controlled testing of components or services\n * that depend on the `Store`.\n *\n * This function registers the `Store` and the `StoreMock` with the same value.\n *\n * @param action Optional callback function that receives the mock `Store` instance. Can be used to configure\n * or manipulate the mock store before it is provided to the testing environment.\n * @returns The environment providers configured with the `StoreMock`.\n */\nexport const provideNgssmStoreTesting = (action?: (store: StoreMock) => void): EnvironmentProviders => {\n const store = new StoreMock({});\n if (action) {\n action(store);\n }\n return makeEnvironmentProviders([\n { provide: Store, useValue: store },\n { provide: StoreMock, useValue: store }\n ]);\n};\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public_api';\n"],"names":[],"mappings":";;;;MAKa,SAAS,CAAA;AACJ,IAAA,MAAM;AACN,IAAA,KAAK;IACd,WAAW,GAAG,KAAK;IACnB,eAAe,GAAG,MAAM,CAAS,EAAE,IAAI,EAAE,EAAE,EAAE,EAAA,IAAA,SAAA,GAAA,CAAA,EAAA,SAAA,EAAA,iBAAA,EAAA,CAAA,8BAAA,EAAA,CAAA,CAAC;IAE7C,WAAW,GAAU,EAAE;AAE/B,IAAA,WAAA,CAAY,YAAmB,EAAA;QAC7B,IAAI,CAAC,MAA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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ngssm-store",
3
- "version": "21.1.6",
3
+ "version": "21.1.8",
4
4
  "description": "NgSsm - Simple state management implementation.",
5
5
  "author": "Lion Marc",
6
6
  "license": "MIT",
@@ -1,6 +1,6 @@
1
1
  import { WritableSignal, EnvironmentProviders } from '@angular/core';
2
2
  import { BehaviorSubject } from 'rxjs';
3
- import { ActionDispatcher, State, Action, Store } from 'ngssm-store';
3
+ import { ActionDispatcher, State, Action } from 'ngssm-store';
4
4
 
5
5
  declare class StoreMock implements ActionDispatcher {
6
6
  readonly state$: BehaviorSubject<State>;
@@ -22,10 +22,12 @@ declare class StoreMock implements ActionDispatcher {
22
22
  * with a `StoreMock` instance, allowing for isolated and controlled testing of components or services
23
23
  * that depend on the `Store`.
24
24
  *
25
+ * This function registers the `Store` and the `StoreMock` with the same value.
26
+ *
25
27
  * @param action Optional callback function that receives the mock `Store` instance. Can be used to configure
26
28
  * or manipulate the mock store before it is provided to the testing environment.
27
29
  * @returns The environment providers configured with the `StoreMock`.
28
30
  */
29
- declare const provideNgssmStoreTesting: (action?: (store: Store) => void) => EnvironmentProviders;
31
+ declare const provideNgssmStoreTesting: (action?: (store: StoreMock) => void) => EnvironmentProviders;
30
32
 
31
33
  export { StoreMock, provideNgssmStoreTesting };