forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
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
51 additions
and
2 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
x-pack/plugins/security_solution/public/rules/jest.config.js
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,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../../../../..', | ||
roots: ['<rootDir>/x-pack/plugins/security_solution/public/rules'], | ||
coverageDirectory: | ||
'<rootDir>/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/rules', | ||
coverageReporters: ['text', 'html'], | ||
collectCoverageFrom: ['<rootDir>/x-pack/plugins/security_solution/public/rules/**/*.{ts,tsx}'], | ||
moduleNameMapper: require('../../server/__mocks__/module_name_map'), | ||
}; |
31 changes: 31 additions & 0 deletions
31
x-pack/plugins/security_solution/public/rules/landing.test.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,31 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import React from 'react'; | ||
import { TestProviders } from '../common/mock'; | ||
import { RulesLandingHeader } from './landing'; | ||
|
||
const mockUseUserData = jest.fn().mockReturnValue([{ canUserCRUD: true }]); | ||
|
||
jest.mock('../detections/components/user_info', () => ({ | ||
useUserData: () => mockUseUserData(), | ||
})); | ||
|
||
describe('Rules landing page header', () => { | ||
it('renders', () => { | ||
const { queryByTestId } = render(<RulesLandingHeader />, { wrapper: TestProviders }); | ||
expect(queryByTestId(`ruleLandingHeader`)).toBeInTheDocument(); | ||
}); | ||
|
||
it('should disable "create rule" when user has no CRUD access', () => { | ||
mockUseUserData.mockReturnValue([{ canUserCRUD: false }]); | ||
|
||
const { queryByTestId } = render(<RulesLandingHeader />, { wrapper: TestProviders }); | ||
|
||
expect(queryByTestId(`createRuleBtn`)).toHaveAttribute('disabled'); | ||
}); | ||
}); |
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