mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Convert packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js to RTL (#55284)
Co-authored-by: gitstart <gitstart@users.noreply.github.com> Co-authored-by: Nitesh Singh <nitesh.singh@gitstart.dev> Co-authored-by: Rafael Toledo <87545086+Toledodev@users.noreply.github.com> Co-authored-by: Murilo Amaral <87545137+MuriloAmarals@users.noreply.github.com> Co-authored-by: Matheus Benini Ferreira <88898100+MatheusBeniniF@users.noreply.github.com> Co-authored-by: Rubens Rafael <70234898+RubensRafael@users.noreply.github.com> Co-authored-by: Toledodev <rafael.toledo@engenharia.ufjf.br> Co-authored-by: Júlio Piubello da Silva Cabral <julio.piubello@gitstart.dev>
This commit is contained in:
parent
d2adb1a3cd
commit
6fb8abbbb6
@ -23,9 +23,6 @@ exports[`no enzyme tests`] = {
|
||||
"packages/grafana-ui/src/slate-plugins/suggestions.test.tsx:2682912140": [
|
||||
[0, 18, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/TickLabels.test.js:2931161174": [
|
||||
[14, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
"packages/jaeger-ui-components/src/TracePageHeader/SpanGraph/ViewingLayer.test.js:1676554632": [
|
||||
[14, 19, 13, "RegExp match", "2409514259"]
|
||||
],
|
||||
|
@ -11,8 +11,7 @@
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
import { shallow } from 'enzyme';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import TickLabels from './TickLabels';
|
||||
@ -23,37 +22,36 @@ describe('<TickLabels>', () => {
|
||||
duration: 5000,
|
||||
};
|
||||
|
||||
let wrapper;
|
||||
let ticks;
|
||||
|
||||
beforeEach(() => {
|
||||
wrapper = shallow(<TickLabels {...defaultProps} />);
|
||||
ticks = wrapper.find('[data-test="tick"]');
|
||||
render(<TickLabels {...defaultProps} />);
|
||||
ticks = screen.getAllByTestId('tick');
|
||||
});
|
||||
|
||||
it('renders the right number of ticks', () => {
|
||||
expect(ticks.length).toBe(defaultProps.numTicks + 1);
|
||||
expect(ticks).toHaveLength(defaultProps.numTicks + 1);
|
||||
});
|
||||
|
||||
it('places the first tick on the left', () => {
|
||||
const firstTick = ticks.first();
|
||||
expect(firstTick.prop('style')).toEqual({ left: '0%' });
|
||||
const firstTick = ticks[0];
|
||||
expect(firstTick).toHaveStyle(`left: 0%;`);
|
||||
});
|
||||
|
||||
it('places the last tick on the right', () => {
|
||||
const lastTick = ticks.last();
|
||||
expect(lastTick.prop('style')).toEqual({ right: '0%' });
|
||||
const lastTick = ticks[ticks.length - 1];
|
||||
expect(lastTick).toHaveStyle(`right: 0%;`);
|
||||
});
|
||||
|
||||
it('places middle ticks at proper intervals', () => {
|
||||
const positions = ['25%', '50%', '75%'];
|
||||
positions.forEach((pos, i) => {
|
||||
const tick = ticks.at(i + 1);
|
||||
expect(tick.prop('style')).toEqual({ left: pos });
|
||||
expect(tick).toHaveStyle(`left: ${pos};`);
|
||||
});
|
||||
});
|
||||
|
||||
it("doesn't explode if no trace is present", () => {
|
||||
expect(() => shallow(<TickLabels {...defaultProps} trace={null} />)).not.toThrow();
|
||||
expect(() => render(<TickLabels {...defaultProps} trace={null} />)).not.toThrow();
|
||||
});
|
||||
});
|
||||
|
@ -50,7 +50,7 @@ export default function TickLabels(props: TickLabelsProps) {
|
||||
const portion = i / numTicks;
|
||||
const style = portion === 1 ? { right: '0%' } : { left: `${portion * 100}%` };
|
||||
ticks.push(
|
||||
<div key={portion} className={styles.TickLabelsLabel} style={style} data-test="tick">
|
||||
<div key={portion} className={styles.TickLabelsLabel} style={style} data-testid="tick">
|
||||
{formatDuration(duration * portion)}
|
||||
</div>
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user