Promise.map is not a native function (#9562)

* Promise.map is not a native function

Fixes #9557 and adds a test that would have caught it.

* use native map
This commit is contained in:
Stacey Gammon 2016-12-20 10:23:50 -05:00 committed by GitHub
parent 1822db0c03
commit 1a5362fd80
2 changed files with 21 additions and 2 deletions

View file

@ -0,0 +1,15 @@
import ngMock from 'ng_mock';
import expect from 'expect.js';
describe('SavedDashboards Service', function () {
let savedDashboardLoader;
beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (savedDashboards) {
savedDashboardLoader = savedDashboards;
}));
it('delete returns a native promise', function () {
expect(savedDashboardLoader.delete(['1','2'])).to.be.a(Promise);
});
});

View file

@ -39,9 +39,13 @@ export class SavedObjectLoader {
delete(ids) {
ids = !_.isArray(ids) ? [ids] : ids;
return Promise.map(ids, (id) => {
return (new this.Class(id)).delete();
const deletions = ids.map(id => {
const savedObject = new this.Class(id);
return savedObject.delete();
});
return Promise.all(deletions);
}
/**