Skip to content

Commit

Permalink
replace .map with .forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
bourgeoa committed Apr 25, 2021
1 parent 9319b20 commit 1b9789a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/update-manager.ts
Expand Up @@ -689,7 +689,7 @@ export default class UpdateManager {
const docs = deletions.concat(insertions).map(st => st.why)
const thisUpdater = this
const uniqueDocs: Array<NamedNode> = []
docs.map(doc => {
docs.forEach(doc => {
if (!uniqueDocs.find(uniqueDoc => uniqueDoc.equals(doc))) uniqueDocs.push(doc as NamedNode)
})
const updates = uniqueDocs.map(doc =>
Expand Down
19 changes: 9 additions & 10 deletions tests/unit/update-manager-test.js
Expand Up @@ -156,23 +156,22 @@ describe('UpdateManager', () => {
})

// on console should display @@@@@@@ updateMany to: 2
it('Should insert triples in more than one document', done => {
it('Should insert triples in more than one document', () => {
loadMeta(updater.store)
updater.updateMany([], [st1, st2, st3]).then(array => {
expect(updater.store.fetcher.webOperation).to.have.been.called() // @@ twice
}, err => console.log(err))
done()
expect(updater.store.fetcher.webOperation).to.have.been.called()
})
})

// on console should display @@@@@@@ updateMany to: 2
// and no console error
it('Should remove triples in more than one document', async done => {
it('Should remove triples in more than one document', done => {
loadMeta(updater.store)
updater.updateMany([], [st1, st2, st3])
updater.updateMany([st1, st2, st3]).then(array => {
expect(updater.store.fetcher.webOperation).to.have.been.called() // @@ twice
}, err => { console.log(err) })
done()
updater.updateMany([st1, st2, st3])
.then(array => {
expect(updater.store.fetcher.webOperation).to.have.been.called()
})
.then(() => done(), done)
})
/*
it('Should patch an insert triple with no proior load', done => {
Expand Down

0 comments on commit 1b9789a

Please sign in to comment.