@@ -7,45 +7,108 @@ define([
77 module ( 'AppointmentGroupList' )
88
99 test ( 'renders the AppointmentGroupList component' , ( ) => {
10- const appointmentGroup = { " appointments" : [ { " child_events" : [ { " user" : { " sortable_name" : " test" } } ] , " start_at" : " 2016-10-18T19:00:00Z" , " end_at" : " 2016-10-18T110:00:00Z" } ] , " appointments_count" : 1 }
10+ const appointmentGroup = { appointments : [ { child_events : [ { user : { sortable_name : ' test' } } ] , start_at : ' 2016-10-18T19:00:00Z' , end_at : ' 2016-10-18T110:00:00Z' } ] , appointments_count : 1 }
1111
12- const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
12+ const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
1313 const appointmentGroupList = TestUtils . findRenderedDOMComponentWithClass ( component , 'AppointmentGroupList__List' )
1414 ok ( appointmentGroupList )
1515 } )
1616
17- test ( 'renders unreserved with user' , ( ) => {
18- const appointmentGroup = { "appointments" : [ { "child_events" : [ { "user" : { "sortable_name" : "test" } } ] , "start_at" : "2016-10-18T19:00:00Z" , "end_at" : "2016-10-18T110:00:00Z" } ] , "appointments_count" : 1 }
19- const expectedContent = "7pm to 12am - test; Available"
17+ test ( 'renders renders reserved badge when someone is signed up in a slot' , ( ) => {
18+ const appointmentGroup = {
19+ appointments : [ {
20+ child_events : [ {
21+ user : { sortable_name : test }
22+ } ] ,
23+ start_at : '2016-10-18T19:00:00Z' ,
24+ end_at : '2016-10-18T110:00:00Z'
25+ } , {
26+ child_events : [ ] ,
27+ start_at : '2016-10-18T16:00:00Z' ,
28+ end_at : '2016-10-18T17:00:00Z'
29+ } ] ,
30+ appointments_count : 2
31+ }
2032
21- const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
22- const appointmentGroupUnreserved = TestUtils . findRenderedDOMComponentWithClass ( component , 'AppointmentGroupList__unreserved' )
23- ok ( expectedContent === appointmentGroupUnreserved . textContent )
33+ const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
34+ const reservedBadge = TestUtils . scryRenderedDOMComponentsWithClass ( component , 'AppointmentGroupList__Badge--reserved' ) [ 0 ]
35+ ok ( reservedBadge )
2436 } )
2537
26- test ( 'renders multiple unreserved with user' , ( ) => {
27- const appointmentGroup = { "appointments" : [ { "child_events" : [ { "user" : { "sortable_name" : "test" } } ] , "start_at" : "2016-10-18T19:00:00Z" , "end_at" : "2016-10-18T110:00:00Z" } , { "child_events" : [ { "user" : { "sortable_name" : "test" } } ] , "start_at" : "2016-10-18T16:00:00Z" , "end_at" : "2016-10-18T17:00:00Z" } ] , "appointments_count" : 2 }
38+ test ( 'renders available badge when no one is signed up' , ( ) => {
39+ const appointmentGroup = {
40+ appointments : [ {
41+ child_events : [ ] ,
42+ start_at : '2016-10-18T19:00:00Z' ,
43+ end_at : '2016-10-18T110:00:00Z'
44+ } , {
45+ child_events : [ ] ,
46+ start_at : '2016-10-18T16:00:00Z' ,
47+ end_at : '2016-10-18T17:00:00Z'
48+ } ] ,
49+ appointments_count : 2
50+ }
2851
29- const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
30- const appointmentGroupUnreserved = TestUtils . findRenderedDOMComponentWithClass ( component , 'AppointmentGroupList__List' )
31- ok ( appointmentGroupUnreserved . childElementCount === 2 )
52+ const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
53+ const availableBadge = TestUtils . scryRenderedDOMComponentsWithClass ( component , 'AppointmentGroupList__Badge--unreserved' ) [ 0 ]
54+ ok ( availableBadge )
3255 } )
3356
34- test ( 'renders reserved with user' , ( ) => {
35- const appointmentGroup = { "appointments" : [ { "child_events" : [ { "user" : { "sortable_name" : "test" } } ] , "start_at" : "2016-10-18T19:00:00Z" , "end_at" : "2016-10-18T110:00:00Z" , 'reserved' : true } , { "child_events" : [ { "user" : { "sortable_name" : "test" } } ] , "start_at" : "2016-10-18T16:00:00Z" , "end_at" : "2016-10-18T17:00:00Z" } ] , "appointments_count" : 2 }
57+ test ( 'renders correct user names' , ( ) => {
58+ const appointmentGroup = {
59+ appointments : [ {
60+ child_events : [ {
61+ user : { sortable_name : 'test1' }
62+ } ] ,
63+ start_at : '2016-10-18T19:00:00Z' ,
64+ end_at : '2016-10-18T110:00:00Z'
65+ } , {
66+ child_events : [ {
67+ user : { sortable_name : 'test2' }
68+ } ] ,
69+ start_at : '2016-10-18T16:00:00Z' ,
70+ end_at : '2016-10-18T17:00:00Z'
71+ } ] ,
72+ appointments_count : 2 ,
73+ participants_per_appointment : 1
74+ }
3675
37- const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
38- const appointmentGroupReserved = TestUtils . findRenderedDOMComponentWithClass ( component , 'AppointmentGroupList__reserved' )
39- ok ( appointmentGroupReserved )
76+ const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
77+ const appointmentGroupNames = TestUtils . scryRenderedDOMComponentsWithClass ( component , 'AppointmentGroupList__Appointment-label' )
78+ equal ( appointmentGroupNames . length , 2 )
79+ equal ( appointmentGroupNames [ 0 ] . textContent , 'test1' )
80+ equal ( appointmentGroupNames [ 1 ] . textContent , 'test2' )
4081 } )
4182
42- test ( 'renders correct user names' , ( ) => {
43- const appointmentGroup = { "appointments" : [ { "child_events" : [ { "user" : { "sortable_name" : "test1" } } ] , "start_at" : "2016-10-18T19:00:00Z" , "end_at" : "2016-10-18T110:00:00Z" } , { "child_events" : [ { "user" : { "sortable_name" : "test2" } } ] , "start_at" : "2016-10-18T16:00:00Z" , "end_at" : "2016-10-18T17:00:00Z" } ] , "appointments_count" : 2 , participants_per_appointment : 1 }
83+ test ( 'renders "Available" at the end of the user list if more appointments are available for the slot' , ( ) => {
84+ const appointmentGroup = {
85+ appointments : [ {
86+ child_events : [ {
87+ user : { sortable_name : 'test1' }
88+ } ] ,
89+ start_at : '2016-10-18T19:00:00Z' ,
90+ end_at : '2016-10-18T110:00:00Z' ,
91+ child_events_count : 1
92+ } , {
93+ child_events : [ {
94+ user : { sortable_name : 'test2' }
95+ } , {
96+ user : { sortable_name : 'test3' }
97+ } ] ,
98+ start_at : '2016-10-18T16:00:00Z' ,
99+ end_at : '2016-10-18T17:00:00Z' ,
100+ child_events_count : 2
101+ } ] ,
102+ appointments_count : 2 ,
103+ participants_per_appointment : 2
104+ }
44105
45- const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
46- const appointmentGroupNames = TestUtils . scryRenderedDOMComponentsWithClass ( component , 'AppointmentGroupList__Appointment-label' ) . map ( nameComp => ReactDOM . findDOMNode ( nameComp ) )
106+ const component = TestUtils . renderIntoDocument ( < AppointmentGroupList appointmentGroup = { appointmentGroup } /> )
107+ const appointmentGroupNames = TestUtils . scryRenderedDOMComponentsWithClass ( component , 'AppointmentGroupList__Appointment-label' )
47108 equal ( appointmentGroupNames . length , 2 )
48- equal ( appointmentGroupNames [ 0 ] . textContent . split ( ' - ' ) [ 1 ] , 'test1' )
49- equal ( appointmentGroupNames [ 1 ] . textContent . split ( ' - ' ) [ 1 ] , 'test2' )
109+ equal ( appointmentGroupNames [ 0 ] . textContent , 'test1; Available ' )
110+ equal ( appointmentGroupNames [ 1 ] . textContent , 'test2; test3 ' )
50111 } )
112+
113+
51114} )
0 commit comments