Skip to content

Commit

Permalink
Merge 48ab4c0 into 560df91
Browse files Browse the repository at this point in the history
  • Loading branch information
ciscou committed Mar 13, 2021
2 parents 560df91 + 48ab4c0 commit 7bc50a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
@@ -1,9 +1,10 @@
language: node_js
node_js:
- 6.7.0
services:
- xvfb
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
script:
- npm run ci
- npm run lint
2 changes: 1 addition & 1 deletion src/localstorage.js
Expand Up @@ -114,7 +114,7 @@ export class LocalStorage {
*/
destroy(model) {
this._removeItem(this._itemName(model.id));
const newRecords = without(this.records, model);
const newRecords = without(this.records, model.id.toString());

this.records = newRecords;
this.save();
Expand Down
10 changes: 10 additions & 0 deletions test/localstorage.test.js
Expand Up @@ -422,6 +422,16 @@ describe('LocalStorage Collection', function() {
expect(removed).to.be(null);
expect(mySavedCollection.length).to.be(0);
});

it('cleans up localStorage after destroying a model', function() {
const parsed = JSON.parse(item);
expect(localStorage.getItem('SavedCollection').split(',')).to.contain(parsed.id);

const newModel = mySavedCollection.get(parsed.id);
newModel.destroy();

expect(localStorage.getItem('SavedCollection').split(',')).to.not.contain(parsed.id);
});
});

describe('will fetch from localStorage if updated separately', function() {
Expand Down

0 comments on commit 7bc50a8

Please sign in to comment.