Created
November 22, 2010 15:46
-
-
Save rklancer/710140 to your computer and use it in GitHub Desktop.
Simpler test of SC.ObserverSet problem
This file contains hidden or 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
| // Author: Richard Klancer <[email protected]> | |
| /*globals module test ok equals same stop start */ | |
| module("SC.ObserverSet.getMethods() removal", { | |
| setup: function () { | |
| SC.LOG_OBSERVERS = YES; | |
| }, | |
| teardown: function () { | |
| SC.LOG_OBSERVERS = NO; | |
| } | |
| }); | |
| // This updated test no longer fails using sproutcore commit c78e1bf25087a3ebd553dbc513923e0d32d09f7b | |
| // HOWEVER. It still triggers an error at line 987 of frameworks/system/runtime/mixins/observable.js (in the method | |
| // SC.Observable._notifyPropertyObservers()) as of current master commit, 789fe805cd08976b7aab1c346c71cf22b78b7285 | |
| test("Observers removing themselves shouldn't cause an error", function () { | |
| expect(1); | |
| var observed = SC.Object.create({ | |
| key: 'val' | |
| }); | |
| var observer1, observer2; | |
| var observer1Fired = NO; | |
| function removeObservers() { | |
| observed.removeObserver('key', observer1); | |
| observed.removeObserver('key', observer2); | |
| } | |
| observer1 = function () { | |
| removeObservers(); | |
| }; | |
| observer2 = function () { | |
| removeObservers(); | |
| }; | |
| observed.addObserver('key', observer1); | |
| observed.addObserver('key', observer2); | |
| observed.set('key', 'newval'); | |
| ok(true, "Code after a simple call to set() should execute"); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment