-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
75 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useStore } from "pages/FlowEditor/lib/store"; | ||
import ServiceSettings from "../ServiceSettings"; | ||
import setupServiceSettingsScreen, { | ||
mockWindowLocationObject, | ||
} from "./helpers/setupServiceSettingsScreen"; | ||
import { screen } from "@testing-library/react"; | ||
import { rootFlowPath } from "routes/utils"; | ||
|
||
const { getState, setState } = useStore; | ||
|
||
describe("Check when service is offline and published, the team has a subdomain", () => { | ||
beforeEach(async () => { | ||
// setup state values that <ServiceSettings/> depends on | ||
setState({ | ||
flowSettings: {}, | ||
flowStatus: "offline", | ||
teamDomain: "mockedteamdomain.com", | ||
teamName: "mockTeam", | ||
isFlowPublished: true, | ||
flowSlug: "mock-planning-permish", | ||
}); | ||
|
||
// render the <ServiceSettings/> comp | ||
setupServiceSettingsScreen(); | ||
|
||
// Mocking window.location.origin | ||
jest | ||
.spyOn(window, "location", "get") | ||
.mockReturnValue(mockWindowLocationObject); | ||
}); | ||
|
||
it("public link should be the current published url", async () => { | ||
expect( | ||
await screen.findByText( | ||
`https://mockedteamdomain.com/mock-planning-permish` | ||
) | ||
).toBe; | ||
}); | ||
}); |
35 changes: 33 additions & 2 deletions
35
....uk/src/pages/FlowEditor/components/Settings/tests/helpers/setupServiceSettingsScreen.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,38 @@ | ||
import React from "react"; | ||
|
||
import ServiceSettings from "../../ServiceSettings"; | ||
import { setup } from "testUtils"; | ||
import { DndProvider } from "react-dnd"; | ||
import { HTML5Backend } from "react-dnd-html5-backend"; | ||
import { screen } from "@testing-library/react"; | ||
|
||
export default function setupServiceSettingsScreen() { | ||
return <ServiceSettings />; | ||
export default async function setupServiceSettingsScreen() { | ||
const { user } = setup( | ||
<DndProvider backend={HTML5Backend}> | ||
<ServiceSettings /> | ||
</DndProvider> | ||
); | ||
await screen.findByText("Your public Link"); | ||
return user; | ||
} | ||
|
||
export const mockWindowLocationObject = { | ||
origin: "https://mocked-origin.com", | ||
hash: "", | ||
host: "dummy.com", | ||
port: "80", | ||
protocol: "http:", | ||
hostname: "dummy.com", | ||
href: "http://dummy.com?page=1&name=testing", | ||
pathname: "", | ||
search: "", | ||
assign: jest.fn(), | ||
reload: jest.fn(), | ||
replace: jest.fn(), | ||
ancestorOrigins: { | ||
length: 0, | ||
contains: () => true, | ||
item: () => null, | ||
[Symbol.iterator]: jest.fn(), | ||
}, | ||
}; |