-
Notifications
You must be signed in to change notification settings - Fork 26
Test Coverage (fetch, updateMany/createMany, addAction(s)) #56
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
Conversation
@@ -1064,7 +1064,7 @@ Adapter.extend({ | |||
* | |||
* // GET /reports/schools/:school_id/teachers | |||
* addAction('getTeacherReports', { | |||
* basePath: 'reports/schools', | |||
* endppoint: 'reports/schools', |
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.
because endpoint
is always appended to basePath
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.
endppoint
=> endpoint
Another point - should the action return an object if a getTeacherReports(reportId) {
return adapter.GET(`reports/schools/${reportId}/teachers`)
.then((response) => {
/* instantiate a record from response.data*/
})
}, |
I personally just add my own functions to mappers, but a lot of people clamored for this declarative HTTP action syntax. |
* Adds tests for #action(<id>) and #action(<params>) queries
@@ -18,6 +18,7 @@ before(function () { | |||
} | |||
Test.sinon = require('sinon') | |||
Test.JSData = require('js-data') | |||
Test.addAction = require('./dist/js-data-http-node').addAction |
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.
It would be good to de-duplicate these 3 files. I would have preferred to do this via. es6 but I haven't gotten both build pipelines to work correctly with that =/
Current coverage is 93.87% (diff: 100%)@@ master #56 diff @@
==========================================
Files 1 1
Lines 45 49 +4
Methods 7 7
Messages 0 0
Branches 6 6
==========================================
+ Hits 42 46 +4
Misses 3 3
Partials 0 0
|
@@ -0,0 +1,14 @@ | |||
describe('sum', function () { |
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.
Not sure these are worth keeping in the library - but at least added tests for coverage stats.
More tests #36 |
try { | ||
fetch // eslint-disable-line | ||
} catch (e) { | ||
return this.skip() |
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.
Skipping the mocha test because the fetch
polyfill for Node is not actually compatible with the browser fetch
. We would need to fork the polyfill or have different fetch
behaviors depending on node/browser.
@@ -18,8 +18,7 @@ | |||
"axios", | |||
"rest", | |||
"adapter", | |||
"http", | |||
"fetch" |
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.
why?
So not all of the top level
opts
such asbasePath
per docs are getting merged into_opts
in addAction. The following PR should fix it by missing both of them, also adding a test since addAction was missing coverage.A few other things (maybe worth opening an issue for) - one thing I'm not a huge fan of is the large dynamic function definition in
addAction
, it may be nicer to have a static function and either bind, or store some of the default arguments to be passed to it.Another is that
addAction
is a function in an extension that reliesmapper
/store
introspection to be correct. Would a more general path-way to to allowaction: {}
definitions in themapper
which the applied / registered adapters be allowed to absorb into their own actions without requiring them to introspect the core framework?