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

Snapshot record in any of Store mocks is empty #409

Closed
cinkonaap opened this issue Nov 14, 2019 · 3 comments
Closed

Snapshot record in any of Store mocks is empty #409

cinkonaap opened this issue Nov 14, 2019 · 3 comments

Comments

@cinkonaap
Copy link
Contributor

I've been writing a test for a model with adapter that requires snapshot.record model instance in multiple urlFor* methods. I couldn't make it work, because record was always empty.

After looking at the source code, it seems like this.model is never set. Maybe I am overlooking something, but still would be glad to discuss and help to fix that.

https://github.com/danielspaniel/ember-data-factory-guy/blob/5bd3a4b6122a5e172fac3492d9ed02351be8224a/addon/mocks/mock-store-request.js#L48

@danielspaniel
Copy link
Collaborator

the => this.model is the model that you are mocking so it might be empty .. it just depends how you do the mock. so if you do

let user = make('user');
mockUpdate(user);

than this.model will be that user you are mocking

whereas if you just do

mockUpdate('user');

this.model will be nil

you are welcome to try and fix it. I just can't think of how to do a fix when you have no real model.

@cinkonaap
Copy link
Contributor Author

cinkonaap commented Nov 14, 2019

I am using a model created with a make method, so we are talking about such scenario:

let user = make('user');
mockFindRecord(user);

However, I think model instance is never passed to any of MockRequest classes (only modelName), so it's not available even if full model is used:

https://github.com/danielspaniel/ember-data-factory-guy/blob/master/addon/mocks/exposed-request-functions.js#L87

@danielspaniel
Copy link
Collaborator

Ok, interesting .. I think you can fix that then. Can you make the PR with the fix ? ( and make a test for that ).

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

2 participants