"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "openstack_dashboard/static/app/core/openstack-service-api/common-test.mock.js" between
horizon-22.1.0.tar.gz and horizon-23.0.0.tar.gz

About: OpenStack Horizon (Optional Service: Dashboard) provides a web-based self-service portal to interact with underlying OpenStack services, such as launching an instance, assigning IP addresses and configuring access controls.
The "Zed" series (latest release).

common-test.mock.js  (horizon-22.1.0):common-test.mock.js  (horizon-23.0.0)
skipping to change at line 66 skipping to change at line 66
'error' method. 'error' method.
Having established those spies, the code then inspects the parameters Having established those spies, the code then inspects the parameters
passed to the apiService, as well as the results of those methods. passed to the apiService, as well as the results of those methods.
Then the code invokes of function passed to the error handler, and Then the code invokes of function passed to the error handler, and
ensures that the toastService is called with the appropriate parameters. ensures that the toastService is called with the appropriate parameters.
*/ */
function testCall(apiService, service, toastService, config) { function testCall(apiService, service, toastService, config) {
// 'promise' simulates a promise, including a self-referential success // 'promise' simulates a promise, including a self-referential success
// handler. // handler.
var promise = {error: angular.noop, success: function() { var promise = {catch: angular.noop, then: function() {
return this; return this;
}}; }};
spyOn(apiService, config.method).and.returnValue(promise); spyOn(apiService, config.method).and.returnValue(promise);
spyOn(promise, 'error'); spyOn(promise, 'catch');
service[config.func].apply(null, config.testInput); service[config.func].apply(null, config.testInput);
// Checks to ensure we call the api service with the appropriate // Checks to ensure we call the api service with the appropriate
// parameters. // parameters.
if (angular.isDefined(config.call_args)) { if (angular.isDefined(config.call_args)) {
expect(apiService[config.method].calls.mostRecent().args).toEqual(config.c all_args); expect(apiService[config.method].calls.mostRecent().args).toEqual(config.c all_args);
} else if (angular.isDefined(config.data)) { } else if (angular.isDefined(config.data)) {
expect(apiService[config.method]).toHaveBeenCalledWith(config.path, config .data); expect(apiService[config.method]).toHaveBeenCalledWith(config.path, config .data);
} else { } else {
expect(apiService[config.method]).toHaveBeenCalledWith(config.path); expect(apiService[config.method]).toHaveBeenCalledWith(config.path);
} }
// The following retrieves the first argument of the first call to the // The following retrieves the first argument of the first call to the
// error spy. This exposes the inner function that, when invoked, // error spy. This exposes the inner function that, when invoked,
// allows us to inspect the error call and the message given. // allows us to inspect the error call and the message given.
if (config.error) { if (config.error) {
var innerFunc = promise.error.calls.argsFor(0)[0]; var innerFunc = promise.catch.calls.argsFor(0)[0];
expect(innerFunc).toBeDefined(); expect(innerFunc).toBeDefined();
spyOn(toastService, 'add'); spyOn(toastService, 'add');
innerFunc({status: 500}); innerFunc({status: 500});
expect(toastService.add).toHaveBeenCalledWith(config.messageType || 'error ', config.error); expect(toastService.add).toHaveBeenCalledWith(config.messageType || 'error ', config.error);
} }
} }
})(); })();
 End of changes. 3 change blocks. 
3 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)