File tree Expand file tree Collapse file tree 4 files changed +61
-9
lines changed Expand file tree Collapse file tree 4 files changed +61
-9
lines changed Original file line number Diff line number Diff line change
1
+ import { render , screen } from "@testing-library/react"
2
+ import React from "react"
3
+ import { CreateProjectForm } from "./CreateProjectForm"
4
+ import { MockProvisioner , MockOrganization , MockProject } from "./../test_helpers"
5
+
6
+ describe ( "CreateProjectForm" , ( ) => {
7
+ it ( "renders" , async ( ) => {
8
+ // Given
9
+ const provisioners = [ MockProvisioner ]
10
+ const organizations = [ MockOrganization ]
11
+ const onSubmit = ( ) => Promise . resolve ( MockProject )
12
+ const onCancel = ( ) => Promise . resolve ( )
13
+
14
+ // When
15
+ render (
16
+ < CreateProjectForm
17
+ provisioners = { provisioners }
18
+ organizations = { organizations }
19
+ onSubmit = { onSubmit }
20
+ onCancel = { onCancel }
21
+ /> ,
22
+ )
23
+
24
+ // Then
25
+ // Simple smoke test to verify form renders
26
+ const element = await screen . findByText ( "Create Project" )
27
+ expect ( element ) . toBeDefined ( )
28
+ } )
29
+ } )
Original file line number Diff line number Diff line change @@ -12,4 +12,4 @@ export const render = (component: React.ReactElement): RenderResult => {
12
12
return wrappedRender ( < WrapperComponent > { component } </ WrapperComponent > )
13
13
}
14
14
15
- export * from "./user "
15
+ export * from "./mocks "
Original file line number Diff line number Diff line change
1
+ import { User } from "../contexts/UserContext"
2
+ import { Provisioner , Organization , Project } from "../api"
3
+
4
+ export const MockUser : User = {
5
+ id : "test-user-id" ,
6
+ username : "TestUser" ,
7
+ email : "test@coder.com" ,
8
+ created_at : "" ,
9
+ }
10
+
11
+ export const MockProject : Project = {
12
+ id : "project-id" ,
13
+ created_at : "" ,
14
+ updated_at : "" ,
15
+ organization_id : "test-org" ,
16
+ name : "Test Project" ,
17
+ provisioner : "test-provisioner" ,
18
+ active_version_id : "" ,
19
+ }
20
+
21
+ export const MockProvisioner : Provisioner = {
22
+ id : "test-provisioner" ,
23
+ name : "Test Provisioner" ,
24
+ }
25
+
26
+ export const MockOrganization : Organization = {
27
+ id : "test-org" ,
28
+ name : "Test Organization" ,
29
+ created_at : "" ,
30
+ updated_at : "" ,
31
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments