Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tests #6

Open
jimbol opened this issue Aug 16, 2017 · 1 comment
Open

Allow tests #6

jimbol opened this issue Aug 16, 2017 · 1 comment

Comments

@jimbol
Copy link
Owner

jimbol commented Aug 16, 2017

Testing

const sel = composableSelector(getSelectedFooIds)
  .populate(getFooHash)
  .filter(getBaz, (baz, foo = {}) => foo.id === baz.fooId)
  .getEach('name')
  .create();
it('gets the names for each selected foo on baz', () => {
  const obj = { name: 'Jam' };

  sel.test([1])
    .populate({ 1: obj })
    .filter({
      fooId: 1,
    })
    // Skips over static transformers
    .returns(['Jam']);
});
@jimbol
Copy link
Owner Author

jimbol commented Aug 23, 2017

Instead of a test method on a selector, a separate testComposableSelector function could be exported.

import { testComposableSelector } from 'comp-select';

testComposableSelector(sel, [1])
  .populate({ 1: obj })
  // ...

This is better because we don't have this public method on each selector. Instead, we just have to store the steps (which we store anyway, right?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant