-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
corrected bug when restoring more times than stored
- Loading branch information
Derick Bailey
committed
Sep 2, 2011
1 parent
4f6ba4c
commit 85ac510
Showing
3 changed files
with
75 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
describe("clearing all mementos", function(){ | ||
beforeEach(function(){ | ||
this.model = new AModel(); | ||
}); | ||
|
||
describe("when clearing", function(){ | ||
it("should restore to first memento given successive save points", function(){ | ||
var changed = false; | ||
this.model.set({foo: "bar"}); | ||
this.model.store(); | ||
this.model.set({foo: "baz"}); | ||
this.model.store(); | ||
this.model.set({foo: "qux"}); | ||
this.model.store(); | ||
|
||
this.model.bind("change:foo", function(){ | ||
changed = true; | ||
}); | ||
|
||
expect(this.model.get('foo')).toBe('qux'); | ||
this.model.clear(); | ||
expect(changed).toBeTruthy(); | ||
expect(this.model.get('foo')).toBe('bar'); | ||
}); | ||
|
||
it("should lose all other save points", function(){ | ||
var changed = false; | ||
this.model.set({foo: "bar"}); | ||
this.model.store(); | ||
this.model.set({foo: "baz"}); | ||
this.model.store(); | ||
this.model.set({foo: "qux"}); | ||
this.model.store(); | ||
|
||
this.model.clear(); | ||
this.model.restore(); | ||
|
||
expect(this.model.get('foo')).toBe('bar'); //should not be qux | ||
}); | ||
|
||
it("should do nothing given no store point", function(){ | ||
var changed = false; | ||
this.model.set({foo: "bar"}); | ||
|
||
this.model.bind("change:foo", function(){ | ||
changed = true; | ||
}); | ||
this.model.clear(); | ||
|
||
expect(this.model.get('foo')).toBe('bar'); | ||
expect(changed).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters