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

Work with aldeed:collection2 #12

Open
eric-burel opened this Issue Nov 10, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@eric-burel
Copy link

eric-burel commented Nov 10, 2016

Hi,

This issue may refer to #8 , however I open a new one here since it seems to be a different issue.

I am using aldeed:simple-schema together with aldeed:collection2. Here is a piece of test I created:

it("Should create a clean UserState object on signup", function(){
     const userId = Meteor.call('user.signup', dummyUser.email, dummyUser.password)
     const userState = UserState.findOne({userId})

     assert.deepEqual(userState, UserState.schema.clean({userId}))
   })

UserState collection has been stubbed, and the idea of the test is that the userState object in the stub collection should have been created and cleaned.
However it is not, and userState equals {userId:"foobar"} where it should equal something similar to {userId:"foobar", someAutoGeneratedValue: {...} }.
It seems that collection2 is not applied on the stubbed collection. When I don't stub the collection, my test is passing as simple-schema clean method is applied thanks to collection2.

Is that an expected behaviour ? The problem is that I use collection2 to auto generate some value. I can't apply clean manually to my object inside my test, since I am testing the method that wraps the insert call.

Thanks !

@thebarty

This comment has been minimized.

Copy link

thebarty commented Feb 15, 2017

same question here - any answers?

Check out this topic #14

@hwillson

This comment has been minimized.

Copy link
Owner

hwillson commented Feb 15, 2017

Hi guys - I've been a bit swamped on other things lately; I'll try to look at this (and the other outstanding issues) shortly, but in the meantime, I love PR's. 🙂 If you have a chance to take a look at this yourself, and can supply a fix (with tests), that would be awesome! Thanks - and sorry for the delay!

@Floriferous

This comment has been minimized.

Copy link
Contributor

Floriferous commented Aug 14, 2017

Wow, it took me a while to identify this package as the one preventing simple schema and collection2 to do their job.

This does not stub (without errors):

    StubCollections.add(Collection);
    StubCollections.stub();

This does stub:

    StubCollections.add([Collection]);
    StubCollections.stub();

And weirdly, this does stub too:

    StubCollections.stub(Collection);

Whereas this is the documented variant (which obviously works):

    StubCollections.stub([Collection]);

Maybe it would be helpful to clarify that stub() can take a single collection, but add() can't ? (Or maybe something else is happening that I don't understand)

@hwillson

This comment has been minimized.

Copy link
Owner

hwillson commented Nov 23, 2017

@Floriferous I've merged your PR (#18), so that should help with this issue. I'm publishing a new version later today - thanks!

@hwillson hwillson closed this Nov 23, 2017

@Floriferous

This comment has been minimized.

Copy link
Contributor

Floriferous commented Jul 11, 2018

This issue should actually be reopened, #18 did not address the fact that this library still does not cooperate with simple schema and collection2.

@hwillson

This comment has been minimized.

Copy link
Owner

hwillson commented Jul 16, 2018

Thanks @Floriferous - re-opening.

@hwillson hwillson reopened this Jul 16, 2018

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