Skip to content

Instantly share code, notes, and snippets.

@KTruong008
Created October 1, 2017 15:20
Show Gist options
  • Save KTruong008/9514d1900a1ef4eb743fcbf7fd73c25a to your computer and use it in GitHub Desktop.
Save KTruong008/9514d1900a1ef4eb743fcbf7fd73c25a to your computer and use it in GitHub Desktop.
// selectors.js
export const selectLogin = (state: AppStateT) => state.login;
export const selectAuthenticated = createSelector(
selectLogin,
(loginState: LoginStateT) => loginState.authenticated
);
// selectors.test.js
import { type } from 'ramda';
import {
selectAuthenticated,
} from '../login.selectors';
describe('Login Selectors', () => {
describe('selectAuthenticated', () => {
it('should return login.authenticated as boolean', () => {
mockParameters = {
login: {
authenticated: false,
authenticating: false,
},
};
const selected = selectAuthenticated.resultFunc(mockParameters.login);
expect(type(selected)).toEqual('Boolean');
});
});
});
@jasonleibowitz
Copy link

In this example what are the type definitions for AppStateT and LoginStateT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment