mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
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:
parent
1822db0c03
commit
1a5362fd80
2 changed files with 21 additions and 2 deletions
|
@ -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);
|
||||
});
|
||||
});
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue