11import XDate from 'xdate' ;
22import { UpdateSources } from '../commons' ;
33import { toMarkingFormat } from '../../interface' ;
4- import Presenter from './Presenter' ;
4+ import {
5+ getButtonIcon ,
6+ setDate ,
7+ setDisabled ,
8+ shouldAnimateTodayButton ,
9+ getPositionAnimation ,
10+ getOpacityAnimation ,
11+ getTodayDate ,
12+ getTodayFormatted
13+ } from './Presenter' ;
514
615describe ( 'Context provider tests' , ( ) => {
7- const makeUUT = ( ) => {
8- return new Presenter ( ) ;
9- } ;
10-
1116 const pastDate = '2021-04-04' ;
1217 const futureDate = '2050-04-04' ;
1318 const todayDate = toMarkingFormat ( XDate ( ) ) ;
1419 const updateSources = UpdateSources . CALENDAR_INIT ;
1520
1621 describe ( 'Button Icon test' , ( ) => {
1722 it ( 'Expect to get down button on past date' , ( ) => {
18- const { getButtonIcon} = makeUUT ( ) ;
1923 const imageUp = '../../../src/img/up.png' ;
2024 const imageDown = '../../../src/img/down.png' ;
2125
@@ -24,7 +28,6 @@ describe('Context provider tests', () => {
2428 } ) ;
2529
2630 it ( 'Expect no image when showTodayButton is false' , ( ) => {
27- const { getButtonIcon} = makeUUT ( ) ;
2831 expect ( getButtonIcon ( pastDate , false ) ) . toBe ( undefined ) ;
2932 } ) ;
3033 } ) ;
@@ -39,7 +42,6 @@ describe('Context provider tests', () => {
3942 } ) ;
4043
4144 it ( 'Expect onDataChanged and updateState to be called on same months dates passed' , ( ) => {
42- const { setDate} = makeUUT ( ) ;
4345 const date = '2021-01-01' ;
4446 const sameMonthDate = '2021-01-20' ;
4547 const props = { onDateChanged, onMonthChange, showTodayButton : false } ;
@@ -52,7 +54,6 @@ describe('Context provider tests', () => {
5254 } ) ;
5355
5456 it ( 'Expect onMonthChange to be called when different months date passed' , ( ) => {
55- const { setDate} = makeUUT ( ) ;
5657 const date = '2021-01-01' ;
5758 const differentMonth = '2021-02-20' ;
5859 const props = { onDateChanged, onMonthChange, showTodayButton : false } ;
@@ -67,7 +68,6 @@ describe('Context provider tests', () => {
6768
6869 describe ( 'Set Disabled test suit' , ( ) => {
6970 it ( 'Expect setDisabled would not call updateState when showTodayButton' , ( ) => {
70- const { setDisabled} = makeUUT ( ) ;
7171 const updateStateMock = jest . fn ( ) ;
7272 const showTodayButton = false ;
7373
@@ -76,7 +76,6 @@ describe('Context provider tests', () => {
7676 } ) ;
7777
7878 it ( 'Expect setDisabled will call updateState when showTodayButton is true and disabled value changed' , ( ) => {
79- const { setDisabled} = makeUUT ( ) ;
8079 const updateStateMock = jest . fn ( ) ;
8180 const showTodayButton = true ;
8281
@@ -88,7 +87,6 @@ describe('Context provider tests', () => {
8887 } ) ;
8988
9089 it ( 'Expect setDisabled will NOT call updateState when showTodayButton is true and disabled value is the same' , ( ) => {
91- const { setDisabled} = makeUUT ( ) ;
9290 const updateStateMock = jest . fn ( ) ;
9391 const showTodayButton = true ;
9492
@@ -102,14 +100,11 @@ describe('Context provider tests', () => {
102100
103101 describe ( "Animate Today's Button" , ( ) => {
104102 it ( 'Expect shouldAnimateTodayButton to return same value as props.showTodayButton' , ( ) => {
105- const { shouldAnimateTodayButton} = makeUUT ( ) ;
106-
107103 expect ( shouldAnimateTodayButton ( { showTodayButton : false } ) ) . toBe ( false ) ;
108104 expect ( shouldAnimateTodayButton ( { showTodayButton : true } ) ) . toBe ( true ) ;
109105 } ) ;
110106
111107 it ( "Expect animation value to be top position when today's date passed" , ( ) => {
112- const { getPositionAnimation} = makeUUT ( ) ;
113108 const TOP_POSITION = 65 ;
114109 const { tension, friction, useNativeDriver} = getPositionAnimation ( todayDate , 10 ) ;
115110
@@ -120,7 +115,6 @@ describe('Context provider tests', () => {
120115 } ) ;
121116
122117 it ( 'Expect animation value to be minus value of bottomMargin when past or future date passed' , ( ) => {
123- const { getPositionAnimation} = makeUUT ( ) ;
124118 const TOP_POSITION = 65 ;
125119
126120 expect ( getPositionAnimation ( futureDate , 999 ) . toValue ) . toEqual ( - 999 ) ;
@@ -130,7 +124,6 @@ describe('Context provider tests', () => {
130124 } ) ;
131125
132126 it ( 'Expect opacity animation value' , ( ) => {
133- const { getOpacityAnimation} = makeUUT ( ) ;
134127 const disabledOpacity = 0.5 ;
135128 let data = getOpacityAnimation ( { disabledOpacity} , true ) ;
136129
@@ -146,13 +139,11 @@ describe('Context provider tests', () => {
146139
147140 describe ( 'onTodayPressed tests' , ( ) => {
148141 it ( "Expect return value to be XDate today's date" , ( ) => {
149- const { getTodayDate} = makeUUT ( ) ;
150142 expect ( getTodayDate ( ) ) . toEqual ( todayDate ) ;
151143 } ) ;
152144 } ) ;
153145
154146 it ( "Today's date formatted" , ( ) => {
155- const { getTodayFormatted} = makeUUT ( ) ;
156147 expect ( getTodayFormatted ( ) ) . toEqual ( 'Today' ) ;
157148 } ) ;
158149} ) ;
0 commit comments