Created
July 28, 2011 18:09
-
-
Save prisoner/1112136 to your computer and use it in GitHub Desktop.
c1312.Observable.qunit
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
module("c1312.Observable"); | |
test("c1312.Observable 测试", function() { | |
var subject = new c1312.Observable(); | |
var observer_count = 0; | |
var o1 = function(msg) { | |
observer_count ++; | |
equals(msg, 'hello', 'notifyObservers操作1'); | |
} | |
var o2 = function(msg) { | |
observer_count ++; | |
equals(msg, 'hello', 'notifyObservers操作2'); | |
} | |
var o3 = function(msg) { | |
observer_count ++; | |
equals(msg, 'hello', 'notifyObservers操作3'); | |
} | |
subject.addObserver(o1); | |
subject.addObserver(o2); | |
subject.addObserver(o3); | |
subject.deleteObserver(o2); | |
subject.notifyObservers('hello'); | |
equals(observer_count, 2, 'deleteObserver操作'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment