diff --git a/src/WeatherApp.test.ts b/src/WeatherApp.test.ts index bced09c..aa8158c 100644 --- a/src/WeatherApp.test.ts +++ b/src/WeatherApp.test.ts @@ -68,7 +68,7 @@ describe("Weather class cehcks", () => { it("should do correct initialisation", async () => { jest.spyOn(externalRequests, "getWeatherExternal").mockReturnValueOnce(Promise.resolve(weatherMoscow)); jest.spyOn(externalRequests, "getCityName").mockReturnValueOnce(Promise.resolve(weatherMoscow.name)); - for(let i=1; i<11;i+=1){ + for (let i = 1; i < 11; i += 1) { weather["historyList"].push(`City${i}`); } weather.init(); @@ -86,11 +86,11 @@ describe("Weather class cehcks", () => { jest.spyOn(externalRequests, "getWeatherExternal").mockReturnValueOnce(Promise.resolve(weatherMoscow)); jest.spyOn(externalRequests, "getCityName").mockReturnValueOnce(Promise.resolve(weatherMoscow.name)); weather.init(); - + await weatherIsLoaded(weather["store"], AppStatus.READY); jest.spyOn(externalRequests, "getWeatherExternal").mockReturnValueOnce(Promise.resolve(weatherSPB)); - + weather["cityNameField"].value = "SPB"; weather["cityNameForm"].dispatchEvent(new Event("submit")); @@ -105,7 +105,7 @@ describe("Weather class cehcks", () => { it("should correct show errors", async () => { jest.spyOn(externalRequests, "getWeatherExternal").mockReturnValueOnce(Promise.reject(Error("TEST ERROR"))); jest.spyOn(externalRequests, "getCityName").mockReturnValueOnce(Promise.resolve(weatherMoscow.name)); - jest.spyOn(window, 'alert').mockImplementation(() => {}); + jest.spyOn(window, "alert").mockImplementation(() => {}); weather.init(); @@ -118,11 +118,11 @@ describe("Weather class cehcks", () => { jest.spyOn(externalRequests, "getWeatherExternal").mockReturnValueOnce(Promise.resolve(weatherMoscow)); jest.spyOn(externalRequests, "getCityName").mockReturnValueOnce(Promise.resolve(weatherMoscow.name)); weather.init(); - + await weatherIsLoaded(weather["store"], AppStatus.READY); jest.spyOn(externalRequests, "getWeatherExternal").mockReturnValueOnce(Promise.resolve(weatherSPB)); - + weather["cityNameField"].value = "SPB"; weather["cityNameForm"].dispatchEvent(new Event("submit")); @@ -136,6 +136,6 @@ describe("Weather class cehcks", () => { await weatherIsLoaded(weather["store"], AppStatus.LOADING); await weatherIsLoaded(weather["store"], AppStatus.READY); - expect(weather["historyBlock"].innerHTML.trim()).toBe("History:

Moscow

SPB

"); + expect(weather["historyBlock"].innerHTML.trim()).toBe('History:

Moscow

SPB

'); }); }); diff --git a/src/externalRequests.test.ts b/src/externalRequests.test.ts index 63b81fa..d97e660 100644 --- a/src/externalRequests.test.ts +++ b/src/externalRequests.test.ts @@ -1,8 +1,8 @@ -import { enableFetchMocks } from 'jest-fetch-mock' +import { enableFetchMocks } from "jest-fetch-mock"; import { IWeatherData } from "./WeatherRedux/Types"; import { getCityName, getWeatherExternal } from "./externalRequests"; -enableFetchMocks() +enableFetchMocks(); describe("External Requests", () => { const testWeather = { coord: { @@ -24,16 +24,16 @@ describe("External Requests", () => { const errorWeather = { cood: 400, - message: "TEST ERROR" - } + message: "TEST ERROR", + }; const testCity = { - city: "Moscow" - } + city: "Moscow", + }; beforeEach(() => { - fetchMock.doMock() - }) + fetchMock.doMock(); + }); it("should return weather data", async () => { fetchMock.mockOnce(JSON.stringify(testWeather)); @@ -62,5 +62,5 @@ describe("External Requests", () => { const cityRecivied = await getCityName(); expect(cityRecivied).toStrictEqual("Moscow"); - }) + }); });