Browse code

Prepinanie medzi tabmi

Cinan Rakosnik authored on 31/03/2013 at 19:08:01
Showing 3 changed files
... ...
@@ -7,6 +7,7 @@ class Xmpp.Views.Tabbar.TabView extends Backbone.View
7 7
 
8 8
   events:
9 9
     'click .js-close': 'closeChat'
10
+    'click a div': 'switchChatWindow'
10 11
 
11 12
   initialize: () ->
12 13
     _.bindAll(this)
... ...
@@ -54,3 +55,6 @@ class Xmpp.Views.Tabbar.TabView extends Backbone.View
54 54
 
55 55
   hasParticipants: (who, withWhom) ->
56 56
     @model && @model.get('who') == who && @model.get('withWhom') == withWhom
57
+
58
+  switchChatWindow: ->
59
+    Backbone.Events.trigger('openChat', @model)
57 60
\ No newline at end of file
... ...
@@ -15,7 +15,7 @@ casper.then(->
15 15
   inactiveListLengthAfter = @inactiveListLength()
16 16
 
17 17
   @test.assertExists('#conversation-js', 'Conversation window created')
18
-  @test.assertExists('#tabbar .tab.active', 'Created new tab in the tabbar')
18
+  @test.assertExists('#js-tabbar .tab.active', 'Created new tab in the tabbar')
19 19
   @test.assert(inactiveListLengthBefore - 1 == inactiveListLengthAfter, 'User isn\'t in the inactive list')
20 20
   @test.assertExists('#js-active-friends ul li', 'User is in the active list')
21 21
 )
... ...
@@ -38,13 +38,23 @@ casper.then(->
38 38
   @test.assert(inactiveListLengthBefore == inactiveListLengthAfter, 'Users from the active and the inactive list swapped')
39 39
 )
40 40
 
41
+#Test tab switching behaviour
42
+casper.then(->
43
+  for i in [1..2]
44
+    @click("#js-tabbar .tab:nth-child(#{i}) a div")
45
+    isActive = @evaluate((i)->
46
+      __utils__.exists("#js-tabbar .tab:nth-child(#{i}).active")
47
+    , i)
48
+    @test.assert(isActive, 'Clicked tab is active')
49
+)
50
+
41 51
 #Test tab closing behaviour
42 52
 casper.then(->
43
-  @click('#tabbar .tab.active .js-close')
53
+  @click('#js-tabbar .tab.active .js-close')
44 54
   @echo 'Closed active tab'
45 55
 
46
-  @test.assertExists('#tabbar .tab.active', 'There\'s another active tab')
47
-  @click('#tabbar .tab.active .js-close')
56
+  @test.assertExists('#js-tabbar .tab.active', 'There\'s another active tab')
57
+  @click('#js-tabbar .tab.active .js-close')
48 58
   @echo 'Closed another active tab'
49 59
 
50 60
   tabsLength = @tabsLength()
... ...
@@ -28,6 +28,6 @@ casper.activeListLength = ->
28 28
   casper.evaluate(-> __utils__.findAll('#js-active-friends ul li').length)
29 29
 
30 30
 casper.tabsLength = ->
31
-  casper.evaluate(-> __utils__.findAll('#tabbar .tab').length)
31
+  casper.evaluate(-> __utils__.findAll('#js-tabbar .tab').length)
32 32
 
33 33
 exports.Fantomas = casper
34 34
\ No newline at end of file