Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/candy-chat/candy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'tests/candy/unit/core/chatRoster.js')
-rw-r--r--tests/candy/unit/core/chatRoster.js49
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/candy/unit/core/chatRoster.js b/tests/candy/unit/core/chatRoster.js
new file mode 100644
index 0000000..53229f2
--- /dev/null
+++ b/tests/candy/unit/core/chatRoster.js
@@ -0,0 +1,49 @@
+/*global define, Candy */
+/*jshint -W030 */
+
+define([
+ 'intern!bdd'
+ , 'intern/chai!expect'
+ , 'intern/order!jquery'
+ , 'intern/order!candy/libs.bundle.js'
+ , 'intern/order!candy/src/candy.js'
+ , 'intern/order!candy/src/core.js'
+ , 'intern/order!candy/src/core/chatUser.js'
+ , 'intern/order!candy/src/core/chatRoster.js'
+], function (bdd, expect) {
+ bdd.describe('Candy.Core.ChatRoster', function () {
+ var chatRoster;
+
+ bdd.beforeEach(function () {
+ chatRoster = new Candy.Core.ChatRoster();
+ });
+
+ bdd.it('can add and fetch users', function () {
+ expect(chatRoster.get('foo@bar.com')).to.be.undefined;
+
+ var chatUser = new Candy.Core.ChatUser('foo@bar.com', 'SomeNick');
+ chatRoster.add(chatUser);
+
+ expect(chatRoster.get('foo@bar.com')).to.be.equal(chatUser);
+ });
+
+ bdd.it('reveals the full set of users', function () {
+ expect(chatRoster.getAll()).to.be.empty;
+
+ var chatUser = new Candy.Core.ChatUser('foo@bar.com', 'SomeNick');
+ chatRoster.add(chatUser);
+
+ expect(chatRoster.getAll()).to.eql({'foo@bar.com': chatUser});
+ });
+
+ bdd.it('can remove users', function () {
+ var chatUser = new Candy.Core.ChatUser('foo@bar.com', 'SomeNick');
+ chatRoster.add(chatUser);
+
+ chatRoster.remove('foo@bar.com');
+
+ expect(chatRoster.get('foo@bar.com')).to.be.undefined;
+ expect(chatRoster.getAll()).to.be.empty;
+ });
+ });
+});