Skip to content

Commit

Permalink
Add withStoreType test
Browse files Browse the repository at this point in the history
  • Loading branch information
augustjk committed Apr 9, 2024
1 parent 2205b85 commit dbc5692
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/labs/redux/src/test/connector_test.ts
Expand Up @@ -7,7 +7,7 @@
import {assert} from '@esm-bundle/chai';
import {html, LitElement} from 'lit';
import {ContextProvider} from '@lit/context';
import {store, increment, toggle, reset} from './store.js';
import {store, increment, toggle, reset, AppStore} from './store.js';

import {storeContext, Connector} from '@lit-labs/redux';

Expand Down Expand Up @@ -266,3 +266,21 @@ suite('Connector without provider', () => {
document.body.removeChild(div);
});
});

suite('Connector.withStoreType', () => {
test('returns itself', () => {
assert.equal(Connector, Connector.withStoreType());
});

// type only test to be checked at compile time
test('correctly type checks selector with provided store type', () => {
const TypedConnector = Connector.withStoreType<AppStore>();
class WithTypedSelector extends LitElement {
connector = new TypedConnector(this, {
// @ts-expect-error `foo` does not exist on state
selector: (state) => state.foo,
});
}
return WithTypedSelector;
});
});

0 comments on commit dbc5692

Please sign in to comment.