File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
site/src/pages/TemplatePage Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { API } from "api/api" ;
2
+ import * as M from "testHelpers/entities" ;
3
+ import { TemplateRedirectController } from "./TemplateRedirectController" ;
4
+ import { renderWithAuth } from "testHelpers/renderHelpers" ;
5
+ import { waitFor } from "@testing-library/react" ;
6
+
7
+ const renderTemplateRedirectController = ( route : string ) => {
8
+ return renderWithAuth ( < TemplateRedirectController /> , {
9
+ route,
10
+ path : "/templates/:organization?/:template" ,
11
+ } ) ;
12
+ } ;
13
+
14
+ it ( "redirects from multi-org to single-org" , async ( ) => {
15
+ const page = renderTemplateRedirectController (
16
+ `/templates/${ M . MockTemplate . organization_name } /${ M . MockTemplate . name } ` ,
17
+ ) ;
18
+
19
+ await waitFor ( ( ) =>
20
+ expect ( page . router . state . location . pathname ) . toEqual (
21
+ `/templates/${ M . MockTemplate . name } ` ,
22
+ ) ,
23
+ ) ;
24
+ } ) ;
25
+
26
+ it ( "redirects from single-org to multi-org" , async ( ) => {
27
+ jest
28
+ . spyOn ( API , "getOrganizations" )
29
+ . mockResolvedValueOnce ( [ M . MockDefaultOrganization , M . MockOrganization2 ] ) ;
30
+
31
+ const page = renderTemplateRedirectController (
32
+ `/templates/${ M . MockTemplate . name } ` ,
33
+ ) ;
34
+
35
+ await waitFor ( ( ) =>
36
+ expect ( page . router . state . location . pathname ) . toEqual (
37
+ `/templates/${ M . MockDefaultOrganization . name } /${ M . MockTemplate . name } ` ,
38
+ ) ,
39
+ ) ;
40
+ } ) ;
You can’t perform that action at this time.
0 commit comments