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

Simple Schema Returning null #8

Closed
drewmoore opened this issue Oct 3, 2016 · 3 comments
Closed

Simple Schema Returning null #8

drewmoore opened this issue Oct 3, 2016 · 3 comments

Comments

@drewmoore
Copy link

Hi, this covers a usage case when using either the aldeed:collection2 or aldeed:simple-schema package. Although this doesn't usually affect functionality, when there is client-side code referencing a property on the schema, the schema is null, and therefore there is an error.

For example, for a given collection Dogs:
Dogs.simpleSchema()._schema would throw TypeError: Cannot read property '_schema' of null. This doesn't happen outside of running tests. Would it be possible to include the schema in the collection stub? If I'm doing something wrong, please let me know. Thanks!

@hwillson
Copy link
Owner

hwillson commented Oct 4, 2016

Great catch - makes sense to me. Thanks for the PR!

@hwillson hwillson closed this as completed Oct 4, 2016
@hwillson
Copy link
Owner

hwillson commented Oct 4, 2016

v1.0.2 has been published with your changes - thanks again!

@eric-burel
Copy link

eric-burel commented Nov 9, 2016

Hi,
I have a short question about the interactions between stub-collections and 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 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.

Is that an expected behaviour ? Since stub-collections is meant for unit test, I could understand that it does not apply collection2, but I am not sure.
It seems to be related to this issue, but I don't clearly understand all implications here.

Thanks !

Edit : even if the test does not pass, my code works fine, the clean function is correctly triggered on insert

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

3 participants