-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DS.Store type presence checks #4178
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {module} from 'qunit'; | ||
import testInDebug from 'dummy/tests/helpers/test-in-debug'; | ||
import {createStore} from 'dummy/tests/helpers/store'; | ||
|
||
module("unit/store/asserts - DS.Store methods produce useful assertion messages"); | ||
|
||
const MODEL_NAME_METHODS = [ | ||
'createRecord', | ||
'findRecord', | ||
'findByIds', | ||
'peekRecord', | ||
'hasRecordForId', | ||
'recordForId', | ||
'query', | ||
'queryRecord', | ||
'findAll', | ||
'peekAll', | ||
'filter', | ||
'recordIsLoaded', | ||
'modelFor', | ||
'modelFactoryFor', | ||
'normalize', | ||
'adapterFor', | ||
'serializerFor' | ||
]; | ||
|
||
testInDebug("Calling Store methods with no type asserts", function(assert) { | ||
assert.expect(MODEL_NAME_METHODS.length); | ||
let store = createStore(); | ||
|
||
MODEL_NAME_METHODS.forEach(function(methodName) { | ||
assert.expectAssertion(function() { | ||
store[methodName](null); | ||
}, new RegExp(`You need to pass a model name to the store's ${methodName} method`)); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
recordIsLoaded
is marked as private in the API docs;modelFactoryFor
currently has no public documentation (though the name suggests it is public).Tiny nitpick: I wonder if those methods should be excluded from the assertion tests here, since they are not public API?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at a few existing asserts and saw
type
so I matched that. I'll change tomodelName
and take a look for existing asserts that would be good to change as well.I think asserts in private API can still be useful occasionally when bad values (erroneously) sneak through into internal code. If they're usually avoided in ED though I can remove them.
https://github.com/emberjs/data/pull/4178/files#r55129914
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to leave the asserts on private APIs. If these methods were ever marked public in the future its unlikely they someone would remember to come back and update this test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍