@@ -2,6 +2,13 @@ const helpers = require("../helpers/global-setup");
22const weatherHelper = require ( "../helpers/weather-setup" ) ;
33const { cleanupMockData } = require ( "../../utils/weather_mocker" ) ;
44
5+ const CURRENT_WEATHER_CONFIG = "tests/configs/modules/weather/currentweather_default.js" ;
6+ const SUNRISE_DATE = "13 Jan 2019 00:30:00 GMT" ;
7+ const SUNSET_DATE = "13 Jan 2019 12:30:00 GMT" ;
8+ const SUN_EVENT_SELECTOR = ".weather .normal.medium span:nth-child(4)" ;
9+ const EXPECTED_SUNRISE_TEXT = "7:00 am" ;
10+ const EXPECTED_SUNSET_TEXT = "3:45 pm" ;
11+
512describe ( "Weather module" , ( ) => {
613 afterEach ( async ( ) => {
714 await helpers . stopApplication ( ) ;
@@ -10,21 +17,23 @@ describe("Weather module", () => {
1017
1118 describe ( "Current weather with sunrise" , ( ) => {
1219 beforeAll ( async ( ) => {
13- await weatherHelper . startApp ( "tests/configs/modules/weather/currentweather_default.js" , "13 Jan 2019 00:30:00 GMT" ) ;
20+ await weatherHelper . startApp ( CURRENT_WEATHER_CONFIG , SUNRISE_DATE ) ;
1421 } ) ;
1522
1623 it ( "should render sunrise" , async ( ) => {
17- await expect ( weatherHelper . getText ( ".weather .normal.medium span:nth-child(4)" , "7:00 am" ) ) . resolves . toBe ( true ) ;
24+ const isSunriseRendered = await weatherHelper . getText ( SUN_EVENT_SELECTOR , EXPECTED_SUNRISE_TEXT ) ;
25+ expect ( isSunriseRendered ) . toBe ( true ) ;
1826 } ) ;
1927 } ) ;
2028
2129 describe ( "Current weather with sunset" , ( ) => {
2230 beforeAll ( async ( ) => {
23- await weatherHelper . startApp ( "tests/configs/modules/weather/currentweather_default.js" , "13 Jan 2019 12:30:00 GMT" ) ;
31+ await weatherHelper . startApp ( CURRENT_WEATHER_CONFIG , SUNSET_DATE ) ;
2432 } ) ;
2533
2634 it ( "should render sunset" , async ( ) => {
27- await expect ( weatherHelper . getText ( ".weather .normal.medium span:nth-child(4)" , "3:45 pm" ) ) . resolves . toBe ( true ) ;
35+ const isSunsetRendered = await weatherHelper . getText ( SUN_EVENT_SELECTOR , EXPECTED_SUNSET_TEXT ) ;
36+ expect ( isSunsetRendered ) . toBe ( true ) ;
2837 } ) ;
2938 } ) ;
3039} ) ;
0 commit comments