Skip to content

Commit

Permalink
Lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyAkkuratov committed Jun 8, 2024
1 parent f3326ea commit 101a20d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
14 changes: 7 additions & 7 deletions src/WeatherApp.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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"));

Expand All @@ -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();

Expand All @@ -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"));

Expand All @@ -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("<span>History:</span><p id=\"Moscow\">Moscow</p><p id=\"SPB\">SPB</p>");
expect(weather["historyBlock"].innerHTML.trim()).toBe('<span>History:</span><p id="Moscow">Moscow</p><p id="SPB">SPB</p>');
});
});
18 changes: 9 additions & 9 deletions src/externalRequests.test.ts
Original file line number Diff line number Diff line change
@@ -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: {
Expand All @@ -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));
Expand Down Expand Up @@ -62,5 +62,5 @@ describe("External Requests", () => {

const cityRecivied = await getCityName();
expect(cityRecivied).toStrictEqual("Moscow");
})
});
});

0 comments on commit 101a20d

Please sign in to comment.