Skip to content

Commit

Permalink
test: fix
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Nov 12, 2021
1 parent fcae3f5 commit 3896404
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions test/e2e/bonjour.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,17 @@ const runBrowser = require("../helpers/run-browser");
const port = require("../ports-map").bonjour;

describe("bonjour option", () => {
const mockPublish = jest.fn();
const mockUnpublishAll = jest.fn();
let mockPublish;
let mockUnpublishAll;
let mockDestroy;

beforeEach(() => {
mockPublish = jest.fn();
mockUnpublishAll = jest.fn((callback) => {
callback();
});
mockDestroy = jest.fn();
});

describe("as true", () => {
let compiler;
Expand All @@ -24,6 +33,7 @@ describe("bonjour option", () => {
return {
publish: mockPublish,
unpublishAll: mockUnpublishAll,
destroy: mockDestroy,
};
});

Expand All @@ -42,8 +52,10 @@ describe("bonjour option", () => {
afterEach(async () => {
await browser.close();
await server.stop();

mockPublish.mockReset();
mockUnpublishAll.mockReset();
mockDestroy.mockReset();
});

it("should call bonjour with correct params", async () => {
Expand All @@ -69,6 +81,7 @@ describe("bonjour option", () => {
});

expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
expect(mockDestroy).toHaveBeenCalledTimes(0);

expect(response.status()).toMatchSnapshot("response status");

Expand All @@ -93,6 +106,7 @@ describe("bonjour option", () => {
return {
publish: mockPublish,
unpublishAll: mockUnpublishAll,
destroy: mockDestroy,
};
});

Expand All @@ -111,8 +125,10 @@ describe("bonjour option", () => {
afterEach(async () => {
await browser.close();
await server.stop();

mockPublish.mockReset();
mockUnpublishAll.mockReset();
mockDestroy.mockReset();
});

it("should call bonjour with 'https' type", async () => {
Expand All @@ -138,6 +154,7 @@ describe("bonjour option", () => {
});

expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
expect(mockDestroy).toHaveBeenCalledTimes(0);

expect(response.status()).toMatchSnapshot("response status");

Expand All @@ -162,6 +179,7 @@ describe("bonjour option", () => {
return {
publish: mockPublish,
unpublishAll: mockUnpublishAll,
destroy: mockDestroy,
};
});

Expand All @@ -180,8 +198,10 @@ describe("bonjour option", () => {
afterEach(async () => {
await browser.close();
await server.stop();

mockPublish.mockReset();
mockUnpublishAll.mockReset();
mockDestroy.mockReset();
});

it("should call bonjour with 'https' type", async () => {
Expand All @@ -207,6 +227,7 @@ describe("bonjour option", () => {
});

expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
expect(mockDestroy).toHaveBeenCalledTimes(0);

expect(response.status()).toMatchSnapshot("response status");

Expand All @@ -231,6 +252,7 @@ describe("bonjour option", () => {
return {
publish: mockPublish,
unpublishAll: mockUnpublishAll,
destroy: mockDestroy,
};
});

Expand Down Expand Up @@ -258,8 +280,10 @@ describe("bonjour option", () => {
afterEach(async () => {
await browser.close();
await server.stop();

mockPublish.mockReset();
mockUnpublishAll.mockReset();
mockDestroy.mockReset();
});

it("should apply bonjour options", async () => {
Expand All @@ -286,6 +310,7 @@ describe("bonjour option", () => {
});

expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
expect(mockDestroy).toHaveBeenCalledTimes(0);

expect(response.status()).toMatchSnapshot("response status");

Expand All @@ -310,6 +335,7 @@ describe("bonjour option", () => {
return {
publish: mockPublish,
unpublishAll: mockUnpublishAll,
destroy: mockDestroy,
};
});

Expand Down Expand Up @@ -338,8 +364,10 @@ describe("bonjour option", () => {
afterEach(async () => {
await browser.close();
await server.stop();

mockPublish.mockReset();
mockUnpublishAll.mockReset();
mockDestroy.mockReset();
});

it("should apply bonjour options", async () => {
Expand All @@ -366,6 +394,7 @@ describe("bonjour option", () => {
});

expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
expect(mockDestroy).toHaveBeenCalledTimes(0);

expect(response.status()).toMatchSnapshot("response status");

Expand All @@ -390,6 +419,7 @@ describe("bonjour option", () => {
return {
publish: mockPublish,
unpublishAll: mockUnpublishAll,
destroy: mockDestroy,
};
});

Expand All @@ -402,7 +432,9 @@ describe("bonjour option", () => {
type: "http",
protocol: "udp",
},
server: "https",
server: {
type: "https",
},
},
compiler
);
Expand All @@ -418,6 +450,7 @@ describe("bonjour option", () => {
afterEach(async () => {
await browser.close();
await server.stop();

mockPublish.mockReset();
mockUnpublishAll.mockReset();
});
Expand Down Expand Up @@ -446,6 +479,7 @@ describe("bonjour option", () => {
});

expect(mockUnpublishAll).toHaveBeenCalledTimes(0);
expect(mockDestroy).toHaveBeenCalledTimes(0);

expect(response.status()).toMatchSnapshot("response status");

Expand Down

0 comments on commit 3896404

Please sign in to comment.