-
Notifications
You must be signed in to change notification settings - Fork 592
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
10 changed files
with
119 additions
and
11 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
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
53 changes: 53 additions & 0 deletions
53
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 |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { Formik } from 'formik'; | ||
import { LoadingBox, StatusBox } from '@console/internal/components/utils'; | ||
import ProjectAccess from '../ProjectAccess'; | ||
|
||
type ProjectAccessProps = React.ComponentProps<typeof ProjectAccess>; | ||
|
||
describe('Project Access', () => { | ||
it('should show the LoadingBox when role bindings are not loaded, but user has access to role bindings', () => { | ||
const projectAccessProps: ProjectAccessProps = { | ||
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', () => { | ||
const projectAccessProps: ProjectAccessProps = { | ||
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', () => { | ||
const projectAccessProps: ProjectAccessProps = { | ||
formName: 'project access', | ||
namespace: 'abc', | ||
roleBindings: { | ||
data: [], | ||
loaded: true, | ||
loadError: undefined, | ||
}, | ||
}; | ||
const renderProjectAccess = shallow(<ProjectAccess {...projectAccessProps} />); | ||
expect(renderProjectAccess.find(Formik).exists()).toBe(true); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
...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 |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { NamespaceBar } from '@console/internal/components/namespace'; | ||
import ProjectAccessPage from '../ProjectAccessPage'; | ||
import RenderProjectAccess from '../RenderProjectAccessPage'; | ||
|
||
describe('Project Access Page', () => { | ||
const projectAccessPageProps: React.ComponentProps<typeof ProjectAccessPage> = { | ||
match: { | ||
isExact: true, | ||
path: `/project-access/ns/:ns`, | ||
url: ``, | ||
params: { | ||
ns: 'default', | ||
}, | ||
}, | ||
}; | ||
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(RenderProjectAccess).exists()).toBeTruthy(); | ||
}); | ||
}); |
30 changes: 30 additions & 0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ProjectAccess from '../ProjectAccess'; | ||
import ProjectListPage from '../../projects/ProjectListPage'; | ||
import { RenderProjectAccessPage } from '../RenderProjectAccessPage'; | ||
|
||
type RenderProjectAccessPageProps = React.ComponentProps<typeof RenderProjectAccessPage>; | ||
|
||
describe('Render Project Access Page', () => { | ||
it('should render Project Access page', () => { | ||
const renderProjectAccessPageProps: RenderProjectAccessPageProps = { | ||
namespace: 'abc', | ||
}; | ||
const renderProjectAccessPageWrapper = shallow( | ||
<RenderProjectAccessPage {...renderProjectAccessPageProps} />, | ||
); | ||
expect(renderProjectAccessPageWrapper.find(ProjectAccess).exists()).toBe(true); | ||
}); | ||
|
||
it('should render the project list when a namespace is not selected', () => { | ||
const renderProjectAccessPageProps: RenderProjectAccessPageProps = { | ||
namespace: '', | ||
}; | ||
const renderProjectAccessPageWrapper = shallow( | ||
<RenderProjectAccessPage {...renderProjectAccessPageProps} />, | ||
); | ||
expect(renderProjectAccessPageWrapper.find(ProjectAccess).exists()).toBe(false); | ||
expect(renderProjectAccessPageWrapper.find(ProjectListPage).exists()).toBe(true); | ||
}); | ||
}); |
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