forked from grafana/clickhouse-datasource
-
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
1 parent
ada2cb7
commit 18b3c8d
Showing
7 changed files
with
161 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import LogsContextPanel, { _testExports } from './LogsContextPanel'; | ||
import { Components } from 'selectors'; | ||
|
||
describe('LogsContextPanel', () => { | ||
it('shows an alert when no columns are matched', () => { | ||
const result = render(<LogsContextPanel columns={[]} datasourceUid="test-uid" />); | ||
expect(result.getByTestId(Components.LogsContextPanel.alert)).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders LogContextKey components for each column', () => { | ||
const mockColumns = [ | ||
{ name: 'host', value: '127.0.0.1' }, | ||
{ name: 'service', value: 'test-api' }, | ||
]; | ||
|
||
const result = render(<LogsContextPanel columns={mockColumns} datasourceUid="test-uid" />); | ||
|
||
expect(result.getAllByTestId(Components.LogsContextPanel.LogContextKey.icon)).toHaveLength(2); | ||
expect(result.getByText('host')).toBeInTheDocument(); | ||
expect(result.getByText('127.0.0.1')).toBeInTheDocument(); | ||
expect(result.getByText('service')).toBeInTheDocument(); | ||
expect(result.getByText('test-api')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('LogContextKey', () => { | ||
const LogContextKey = _testExports.LogContextKey; | ||
|
||
it('renders the expected keys', () => { | ||
const props = { | ||
name: 'testName', | ||
value: 'testValue', | ||
primaryColor: '#000', | ||
primaryTextColor: '#aaa', | ||
secondaryColor: '#111', | ||
secondaryTextColor: '#bbb', | ||
}; | ||
|
||
|
||
const result = render(<LogContextKey {...props} />); | ||
|
||
expect(result.getByTestId(Components.LogsContextPanel.LogContextKey.icon)).toBeInTheDocument(); | ||
expect(result.getByText('testName')).toBeInTheDocument(); | ||
expect(result.getByText('testValue')).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
describe('iconMatcher', () => { | ||
const iconMatcher = _testExports.iconMatcher; | ||
|
||
it('returns correct icons for different context names', () => { | ||
expect(iconMatcher('database')).toBe('database'); | ||
expect(iconMatcher('???')).toBe('align-left'); | ||
}); | ||
}); |
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
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