Stores

There is no reason to test the built-in Akita's methods because they have been well tested. The only tests you should add are for custom methods. For example:

todos.store.ts
export interface TodosState extends EntityState<Todo> {
ui: {
filter: string;
};
}
@StoreConfig({ name: 'todos' })
export class TodosStore extends EntityStore<TodosState> {
constructor() {
super({ ui: { filter: 'active' } });
}
customUpdateMethod(condition) {
if (condition) {
this.set([]);
}
}
}

In the above example, we can test the customUpdateMethod method.

todos.store.spec.ts
describe('TodosStore', () => {
let store: TodosStore;
beforeEach(() => {
store = new TodosStore();
});
it('should create an instance', () => {
expect(store).toBeTruthy();
});
it('should test custom method', () => {
spyOn(store, 'set');
store.customUpdateMethod(false);
expect(store.set).not.toHaveBeenCalled();
store.customUpdateMethod(true);
expect(store.set).toHaveBeenCalled();
});
});

The same principles also apply to the Query.