Skip to content

Commit 2d674d9

Browse files
committed
test: add useDispatch test
1 parent d366987 commit 2d674d9

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { createStore } from 'redux'
2+
import {
3+
injectDispatch, provideRedux
4+
} from '../public-api'
5+
import {Component} from "@angular/core";
6+
import {render} from "@testing-library/angular";
7+
8+
const store = createStore((c: number = 1): number => c + 1)
9+
const store2 = createStore((c: number = 1): number => c + 2)
10+
11+
describe('injectDispatch', () => {
12+
it("returns the store's dispatch function", async () => {
13+
@Component({
14+
selector: "app-root",
15+
standalone: true,
16+
template: "<p></p>"
17+
})
18+
class Testing {
19+
dispatch = injectDispatch();
20+
}
21+
22+
const result = await render(Testing, {
23+
providers: [provideRedux({store})]
24+
})
25+
26+
expect(result.fixture.componentRef.instance.dispatch).toBe(store.dispatch)
27+
})
28+
})

0 commit comments

Comments
 (0)