mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 13:09:33 -06:00
Merge pull request #1487 from velesin/has_current_user_tests
adds unit tests for Discourse.HasCurrentUser
This commit is contained in:
commit
0b5df524c7
19
test/javascripts/mixins/has_current_user_test.js
Normal file
19
test/javascripts/mixins/has_current_user_test.js
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
module("Discourse.HasCurrentUser", {
|
||||||
|
setup: function() {
|
||||||
|
sinon.stub(Discourse.User, "current");
|
||||||
|
},
|
||||||
|
|
||||||
|
teardown: function() {
|
||||||
|
Discourse.User.current.restore();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
test("adds `currentUser` property to an object and ensures it is not cached", function() {
|
||||||
|
var testObj = Ember.Object.createWithMixins(Discourse.HasCurrentUser, {});
|
||||||
|
|
||||||
|
Discourse.User.current.returns("first user");
|
||||||
|
equal(testObj.get("currentUser"), "first user", "on the first call property returns initial user");
|
||||||
|
|
||||||
|
Discourse.User.current.returns("second user");
|
||||||
|
equal(testObj.get("currentUser"), "second user", "if the user changes, on the second call property returns changed user");
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user