-
Notifications
You must be signed in to change notification settings - Fork 593
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move test data from
mocks
to tests
folder
- Loading branch information
Showing
9 changed files
with
68 additions
and
70 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
56 changes: 32 additions & 24 deletions
56
frontend/packages/dev-console/src/components/project-access/__tests__/ProjectAccess.spec.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,43 +1,51 @@ | ||
import * as React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import { shallow } from 'enzyme'; | ||
import { Formik } from 'formik'; | ||
import { LoadingBox, StatusBox } from '@console/internal/components/utils'; | ||
import ProjectAccess, { ProjectAccessProps } from '../ProjectAccess'; | ||
|
||
const projectAccessProps: ProjectAccessProps = { | ||
formName: 'project access', | ||
namespace: 'abc', | ||
roleBindings: { | ||
data: [], | ||
loaded: true, | ||
loadError: {}, | ||
}, | ||
}; | ||
import ProjectAccess from '../ProjectAccess'; | ||
|
||
describe('Project Access', () => { | ||
let renderProjectAccess: ShallowWrapper<ProjectAccessProps>; | ||
|
||
it('should show the LoadingBox when role bindings are not loaded, but user has access to role bindings', () => { | ||
projectAccessProps.roleBindings.loaded = false; | ||
renderProjectAccess = shallow(<ProjectAccess {...projectAccessProps} />); | ||
expect(renderProjectAccess.exists()).toBe(true); | ||
const projectAccessProps: React.ComponentProps<typeof ProjectAccess> = { | ||
formName: 'project access', | ||
namespace: 'abc', | ||
roleBindings: { | ||
data: [], | ||
loaded: false, | ||
loadError: {}, | ||
}, | ||
}; | ||
const renderProjectAccess = shallow(<ProjectAccess {...projectAccessProps} />); | ||
expect(renderProjectAccess.find(LoadingBox).exists()).toBeTruthy(); | ||
expect(renderProjectAccess.find(Formik).exists()).toBe(false); | ||
}); | ||
|
||
it('should show the StatusBox when there is error loading the role bindings', () => { | ||
projectAccessProps.roleBindings.loadError = { error: 'user has no access to role bindigs' }; | ||
renderProjectAccess = shallow(<ProjectAccess {...projectAccessProps} />); | ||
expect(renderProjectAccess.exists()).toBe(true); | ||
const projectAccessProps: React.ComponentProps<typeof ProjectAccess> = { | ||
formName: 'project access', | ||
namespace: 'abc', | ||
roleBindings: { | ||
data: [], | ||
loaded: false, | ||
loadError: { error: 'user has no access to role bindigs' }, | ||
}, | ||
}; | ||
const renderProjectAccess = shallow(<ProjectAccess {...projectAccessProps} />); | ||
expect(renderProjectAccess.find(StatusBox).exists()).toBeTruthy(); | ||
expect(renderProjectAccess.find(Formik).exists()).toBe(false); | ||
}); | ||
|
||
it('should load the Formik Form Component when role bindings loads without any error', () => { | ||
projectAccessProps.roleBindings.loaded = true; | ||
projectAccessProps.roleBindings.loadError = undefined; | ||
renderProjectAccess = shallow(<ProjectAccess {...projectAccessProps} />); | ||
expect(renderProjectAccess.exists()).toBe(true); | ||
const projectAccessProps: React.ComponentProps<typeof ProjectAccess> = { | ||
formName: 'project access', | ||
namespace: 'abc', | ||
roleBindings: { | ||
data: [], | ||
loaded: true, | ||
loadError: undefined, | ||
}, | ||
}; | ||
const renderProjectAccess = shallow(<ProjectAccess {...projectAccessProps} />); | ||
expect(renderProjectAccess.find(Formik).exists()).toBe(true); | ||
}); | ||
}); |
30 changes: 14 additions & 16 deletions
30
...d/packages/dev-console/src/components/project-access/__tests__/ProjectAccessPage.spec.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,27 +1,25 @@ | ||
import * as React from 'react'; | ||
import { shallow, ShallowWrapper } from 'enzyme'; | ||
import { shallow } from 'enzyme'; | ||
import { NamespaceBar } from '@console/internal/components/namespace'; | ||
import ProjectAccessPage, { ProjectAccessPageProps } from '../ProjectAccessPage'; | ||
import { RenderProjectAccessPage } from '../RenderProjectAccessPage'; | ||
import ProjectAccessPage from '../ProjectAccessPage'; | ||
import RenderProjectAccess from '../RenderProjectAccessPage'; | ||
|
||
describe('Project Access Page', () => { | ||
let wrapper: ShallowWrapper<ProjectAccessPageProps>; | ||
let projectAccessPageProps; | ||
|
||
beforeEach(() => { | ||
projectAccessPageProps = { | ||
match: { | ||
params: { | ||
ns: 'default', | ||
}, | ||
const projectAccessPageProps = { | ||
match: { | ||
isExact: true, | ||
path: `/project-access/ns/:ns`, | ||
url: ``, | ||
params: { | ||
ns: 'default', | ||
}, | ||
}; | ||
wrapper = shallow(<ProjectAccessPage {...projectAccessPageProps} />); | ||
}); | ||
}, | ||
}; | ||
const wrapper = shallow(<ProjectAccessPage {...projectAccessPageProps} />); | ||
it('should have the NamespaceBar Component', () => { | ||
expect(wrapper.find(NamespaceBar).exists()).toBeTruthy(); | ||
}); | ||
it('should render the RenderProjectAccessPage Component', () => { | ||
expect(wrapper.find(RenderProjectAccessPage).exists()).toBeTruthy(); | ||
expect(wrapper.find(RenderProjectAccess).exists()).toBeTruthy(); | ||
}); | ||
}); |
30 changes: 12 additions & 18 deletions
30
...ages/dev-console/src/components/project-access/__tests__/RenderProjectAccessPage.spec.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
File renamed without changes.
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
2 changes: 1 addition & 1 deletion
2
...sole/src/components/project-access/__tests__/project-access-form-validation-utils.spec.ts
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