Test and fix #clear().
This commit is contained in:
parent
e072ff2d77
commit
34ac4b25af
@ -226,7 +226,7 @@ export default class Collection extends EventEmitter {
|
||||
}
|
||||
|
||||
clear () {
|
||||
forEach(this._items, key => {
|
||||
forEach(this._items, (_, key) => {
|
||||
delete this._items[key]
|
||||
this._size--
|
||||
this._touch('remove', key)
|
||||
|
@ -195,6 +195,19 @@ describe('Collection', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describe('clear()', function () {
|
||||
it('removes all items from the collection', function () {
|
||||
this.col.clear()
|
||||
|
||||
expect(this.col.size).to.equal(0)
|
||||
|
||||
return eventToPromise(this.col, 'remove').then((items) => {
|
||||
expect(items).to.have.all.keys('bar')
|
||||
expect(items.bar).to.not.exist()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('deduplicates events', function () {
|
||||
forEach({
|
||||
'add & update → add': [
|
||||
|
Loading…
Reference in New Issue
Block a user