@@ -52,7 +52,7 @@ describe('Clock.vue', () => {
5252 expect ( wrapper . find ( '.clock__minutes' ) [ 0 ] . text ( ) ) . to . contain ( '03' ) ;
5353 } ) ;
5454
55- it ( 'Updates minutes when changed' , ( ) => {
55+ it ( 'updates minutes when changed' , ( ) => {
5656 clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
5757 clock . tick ( 3 * minutes ) ;
5858 const wrapper = mount ( Clock ) ;
@@ -61,6 +61,29 @@ describe('Clock.vue', () => {
6161 setTimeout ( ( ) => expect ( wrapper . find ( '.clock__minutes' ) [ 0 ] . text ( ) ) . to . contain ( '04' ) , 1000 ) ;
6262 } ) ;
6363
64+ it ( 'renders current seconds with padded 0 if props displaySeconds is true' , ( ) => {
65+ clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
66+ clock . tick ( 5 * seconds ) ;
67+ const wrapper = mount ( Clock , { propsData : { displaySeconds : true } } ) ;
68+ expect ( wrapper . find ( '.clock__seconds' ) [ 0 ] . text ( ) ) . to . contain ( '05' ) ;
69+ } ) ;
70+
71+ it ( 'updates seconds when changed if props displaySeconds is true' , ( ) => {
72+ clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
73+ clock . tick ( 3 * seconds ) ;
74+ const wrapper = mount ( Clock , { propsData : { displaySeconds : true } } ) ;
75+ expect ( wrapper . find ( '.clock__seconds' ) [ 0 ] . text ( ) ) . to . contain ( '03' ) ;
76+ clock . tick ( 4 * seconds ) ;
77+ setTimeout ( ( ) => expect ( wrapper . find ( '.clock__seconds' ) [ 0 ] . text ( ) ) . to . contain ( '04' ) , 1000 ) ;
78+ } ) ;
79+
80+ it ( 'does not render seconds with if props displaySeconds is undefined' , ( ) => {
81+ clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
82+ clock . tick ( 5 * seconds ) ;
83+ const wrapper = mount ( Clock ) ;
84+ expect ( wrapper . find ( '.clock__seconds' ) . length ) . to . equal ( 0 ) ;
85+ } ) ;
86+
6487 it ( 'displays colon when not passed blink prop and seconds are even' , ( ) => {
6588 clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
6689 clock . tick ( seconds * 2 ) ;
@@ -70,7 +93,7 @@ describe('Clock.vue', () => {
7093
7194 it ( 'displays colon when not passed blink prop and seconds are odd' , ( ) => {
7295 clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
73- clock . tick ( seconds ) ;
96+ clock . tick ( seconds * 3 ) ;
7497 const wrapper = mount ( Clock ) ;
7598 expect ( wrapper . text ( ) ) . to . contain ( ':' ) ;
7699 } ) ;
@@ -82,13 +105,33 @@ describe('Clock.vue', () => {
82105 expect ( wrapper . text ( ) ) . to . contain ( ':' ) ;
83106 } ) ;
84107
85- it ( 'does not display colon when passed blink prop and seconds are odd ' , ( ) => {
108+ it ( 'does not display colon when passed blink prop and seconds are even ' , ( ) => {
86109 clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
87- clock . tick ( seconds ) ;
110+ clock . tick ( seconds * 3 ) ;
88111 const wrapper = mount ( Clock , { propsData : { blink : true } } ) ;
89112 expect ( wrapper . text ( ) ) . to . not . contain ( ':' ) ;
90113 } ) ;
91114
115+ it ( 'displays second colon when passed blink and displaySeconds props and seconds are even' , ( ) => {
116+ clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
117+ clock . tick ( seconds * 2 ) ;
118+ const wrapper = mount ( Clock , { propsData : { blink : true , displaySeconds : true } } ) ;
119+ expect ( wrapper . find ( 'span' ) [ 3 ] . text ( ) ) . to . contain ( ':' ) ;
120+ } ) ;
121+
122+ it ( 'does not display second colon when passed blink and displaySeconds props and seconds are odd' , ( ) => {
123+ clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
124+ clock . tick ( seconds * 3 ) ;
125+ const wrapper = mount ( Clock , { propsData : { blink : true , displaySeconds : true } } ) ;
126+ expect ( wrapper . find ( 'span' ) [ 3 ] . text ( ) ) . to . not . contain ( ':' ) ;
127+ } ) ;
128+
129+ it ( 'does not display colon when passed blink prop and seconds are even' , ( ) => {
130+ clock = sinon . useFakeTimers ( new Date ( 2016 , 2 , 15 ) . getTime ( ) ) ;
131+ clock . tick ( seconds * 3 ) ;
132+ const wrapper = mount ( Clock , { propsData : { blink : true } } ) ;
133+ expect ( wrapper . text ( ) ) . to . not . contain ( ':' ) ;
134+ } ) ;
92135 it ( 'Calls clear input with vm.ticker when component is destroyed' , ( ) => {
93136 const stub = sinon . stub ( ) ;
94137 window . clearInterval = stub ;
0 commit comments