restangular
restangular copied to clipboard
Tests fail with Angular 1.6
- Just to document this for others.
- Three tests fail with Angular 1.6
- Not sure if the test or the code has to be fixed
- Maybe a workaround here if "real" issue: https://github.com/angular-ui/ui-router/issues/2889
- https://docs.angularjs.org/guide/migration#migrating-from-1-5-to-1-6
Verifying property karma.build exists in config...OK
File: [no files]
Options: background=false, client={}, configFile="karma.conf.js"
13 12 2016 22:03:06.821:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
13 12 2016 22:03:06.829:INFO [launcher]: Starting browser PhantomJS
13 12 2016 22:03:07.117:INFO [PhantomJS 2.1.1 (Linux 0.0.0)]: Connected on socket e1fQngp6cO8J1nHCAAAA with id 66088275
Start:
Restangular
Interceptors
✔ Should add multiple request and response interceptors
✔ Should add multiple error interceptors
✔ Should add multiple error interceptors but don't reject the promise if one of them returns false
✔ Should add multiple error interceptors for a single get too
Transformers
✔ Should decorate element both on server and local by default
With Suffix
✔ shouldn't add suffix to getRestangularUrl
✔ should add suffix to getRequestedUrl
✔ should add suffix to request
✔ shouldn't add suffix to allUrl
JSONp
✖ should work for get
✖ should work for getList
✔ shouldn't override post
Local data
✔ Should restangularize a collection OK
✔ Should restangularize a function with arguments OK
✔ should have fromServer set when restangularizeElement is called with that param
✔ should have fromServer set when restangularizeCollection is called with that param
restangularizePromiseIntercept
✔ should be invoked by restangularizePromise
$object
✔ Should work for single get
✔ Shouldn't be restangularized by default
ALL
✔ getList() should return an array of items
✔ several getList() should return an array of items
✔ several remove() should work
✔ get(id) should return the item with given id
✔ uses all to get the list without parameters
✔ Custom GET methods should work
✔ post() should add a new item
✔ customPOST() should add a new item
✔ post() should work with arrays
✔ post() should add a new item with data and return the data from the server
✔ Doing a post and then other operation (delete) should call right URLs
✔ Doing a post to a server that returns no element will return undefined
✔ head() should safely return
✔ trace() should safely return
✔ customPUT should work
✔ customPATCH should work
✔ options() should safely return
✔ getList() should correctly handle params after customDELETE
Scoped Service
✔ should correctly work
✔ should correctly work with children
✔ should add custom collection method added with withConfig
✔ should provide a one-off $http configuration method
ONE
✔ get() should return a JSON item
✔ Should save as put correctly
✔ Should save as post correctly
✔ Should keep route property when element is created
✔ Should make RequestLess connections with one
✔ Should make RequestLess connections with all
✔ Custom GET methods should work
✔ put() should update the value
✔ should return an array when accessing a subvalue
COPY
✔ should copy an object and "this" should reference the copied object
✔ should copy an object and "fromServer" param should be the same with the copied object
getRestangularUrl
✔ should return the generated URL when you chain Restangular methods together
getRestangularUrl with useCannonicalId set to true
✔ should return the generated URL when you chain Restangular methods together
addElementTransformer
✔ should allow for a custom method to be placed at the collection level
✔ should allow for a custom method to be placed at the model level when one model is requested
✔ should allow for a custom method to be placed at the model level when several models are requested
extendCollection
✔ should be an alias for a specific invocation of addElementTransformer
extendModel
✔ should be an alias for a specific invocation of addElementTransformer
headers
✔ should return defaultHeaders
✖ should pass uppercase methods in X-HTTP-Method-Override
defaultRequestParams
✔ should return defaultRequestParams
✔ should be able to set default params for get, post, put.. methods separately
✔ should be able to set default params for multiple methods with array
withConfig
✔ should create new service with scoped configuration
✔ should allow nested configurations
Self linking
✔ Should request the link in HAL format
Singe one (endpoint not expecting an id)
✔ does not use the id for single resource GET
✔ getRestangularUrl() returns still the url without id after GET
✔ does not use the id for single nested resource GET
✔ does not use the id for single resource PUT
setSelfLinkAbsoluteUrl
✔ works
Misc
✔ should not strip [one] or [all] key from plain object
✔ should not stip non-restangularized elements
testing normalize url
✔ should get a list of objects
✔ should get a list of objects even if the path has extra slashes
✔ should post with slash at the end
✔ should put with slash at the end
✔ should return a normalized URL even it has extra slashes
✔ should create a new service and still working normalized URL
✔ Should work with absolute URL with //authority
setPlainByDefault
✔ should not add restangularized methods to response object
✔ shoud not add restangularized methods to response collection
Finished in 0.836 secs / 0.82 secs
SUMMARY:
✔ 81 tests completed
✖ 3 tests failed
FAILED TESTS:
Restangular
JSONp
✖ should work for get
PhantomJS 2.1.1 (Linux 0.0.0)
Possibly unhandled rejection: {"line":1421,"sourceURL":"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular-mocks.js","stack":"$httpBackend@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular-mocks.js:1421:90\nsendReq@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:12152:21\nserverRequest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:11905:23\nprocessQueue@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:16643:39\nhttps://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:16683:39\n$eval@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:17958:28\n$digest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:17772:36\nflush@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular-mocks.js:1813:45\n/home/flo/Projects/Javascript/restangular/test/restangularSpec.js:401:25\nexecute@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:1145:22\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2177:38\nstart@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2130:13\nexecute@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2458:19\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2177:38\nstart@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2130:13\nexecute@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2604:19\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2177:38\nonComplete@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2173:23\nfinish@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2561:15\n/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2605:16\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2187:24\nonComplete@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2173:23\nfinish@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2432:15\n/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2459:16\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2187:24\n/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2167:23"}
✖ should work for getList
PhantomJS 2.1.1 (Linux 0.0.0)
Possibly unhandled rejection: {"line":1421,"sourceURL":"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular-mocks.js","stack":"$httpBackend@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular-mocks.js:1421:90\nsendReq@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:12152:21\nserverRequest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:11905:23\nprocessQueue@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:16643:39\nhttps://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:16683:39\n$eval@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:17958:28\n$digest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular.js:17772:36\nflush@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.0/angular-mocks.js:1813:45\n/home/flo/Projects/Javascript/restangular/test/restangularSpec.js:409:25\nexecute@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:1145:22\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2177:38\nstart@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2130:13\nexecute@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2458:19\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2177:38\nstart@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2130:13\nexecute@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2604:19\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2177:38\nonComplete@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2173:23\nfinish@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2561:15\n/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2605:16\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2187:24\nonComplete@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2173:23\nfinish@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2432:15\n/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2459:16\nnext_@/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2187:24\n/home/flo/Projects/Javascript/restangular/node_modules/karma-jasmine/lib/jasmine.js:2167:23"}
headers
✖ should pass uppercase methods in X-HTTP-Method-Override
PhantomJS 2.1.1 (Linux 0.0.0)
Possibly unhandled rejection: {"status":0,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","headers":{"X-HTTP-Method-Override":"PUT","Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"},"url":"/overriders/1","data":{"id":1}},"statusText":""}
Warning: Task "karma:build" failed. Use --force to continue.
Aborted due to warnings.
npm ERR! Test failed. See above for more details.
This would probably be solved by including $qProvider.errorOnUnhandledRejections(false);
in the spec file. I'll see if I have time to look at it, but a PR would be welcome!
Apparently there are also some breaking changes about JSONP requests in Angular 1.6. https://code.angularjs.org/1.6.1/docs/api/ng/service/$http#jsonp
I get the following errors with Angular 1.6.1
FAILED TESTS:
Restangular
JSONp
✖ should work for get
PhantomJS 2.1.1 (Mac OS X 0.0.0)
Error: Unexpected request: JSONP /accounts/1?callback=JSON_CALLBACK
Expected JSONP /accounts/1 in https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-mocks.js (line 1421)
$httpBackend@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-mocks.js:1421:90
sendReq@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:12155:21
serverRequest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:11908:23
processQueue@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:16648:39
https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:16692:39
$eval@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:17972:28
$digest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:17786:36
flush@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-mocks.js:1813:45
test/restangularSpec.js:519:25
loaded@http://localhost:9876/context.js:151:17
✖ should work for getList
PhantomJS 2.1.1 (Mac OS X 0.0.0)
Error: Unexpected request: JSONP /accounts?callback=JSON_CALLBACK
Expected JSONP /accounts in https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-mocks.js (line 1421)
$httpBackend@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-mocks.js:1421:90
sendReq@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:12155:21
serverRequest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:11908:23
processQueue@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:16648:39
https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:16692:39
$eval@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:17972:28
$digest@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.js:17786:36
flush@https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular-mocks.js:1813:45
test/restangularSpec.js:527:25
loaded@http://localhost:9876/context.js:151:17
headers
✖ should pass uppercase methods in X-HTTP-Method-Override
PhantomJS 2.1.1 (Mac OS X 0.0.0)
Possibly unhandled rejection: {"status":0,"config":{"method":"POST","transformRequest":[null],"transformResponse":[null],"jsonpCallbackParam":"callback","headers":{"X-HTTP-Method-Override":"PUT","Accept":"application/json, text/plain, */*","Content-Type":"application/json;charset=utf-8"},"url":"/overriders/1","data":{"id":1}},"statusText":""} thrown
On the theme of JSONP for AngularJS V1.6 https://stackoverflow.com/questions/42706549