mirror of
https://github.com/prymitive/karma
synced 2026-05-13 03:56:59 +00:00
feat(tests): add test coverage for SilenceMatch
This commit is contained in:
37
ui/src/Components/SilenceModal/SilenceMatch.test.js
Normal file
37
ui/src/Components/SilenceModal/SilenceMatch.test.js
Normal file
@@ -0,0 +1,37 @@
|
||||
import React from "react";
|
||||
|
||||
import { shallow } from "enzyme";
|
||||
|
||||
import { NewEmptyMatcher, MatcherValueToObject } from "Stores/SilenceFormStore";
|
||||
import { SilenceMatch } from "./SilenceMatch";
|
||||
|
||||
let matcher;
|
||||
|
||||
beforeEach(() => {
|
||||
matcher = NewEmptyMatcher();
|
||||
});
|
||||
|
||||
const ShallowLabelValueInput = () => {
|
||||
return shallow(<SilenceMatch matcher={matcher} />);
|
||||
};
|
||||
|
||||
describe("<SilenceMatch />", () => {
|
||||
it("allows changing matcher.isRegex value when matcher.values contains 1 element", () => {
|
||||
matcher.values = [MatcherValueToObject("foo")];
|
||||
const tree = ShallowLabelValueInput();
|
||||
expect(matcher.isRegex).toBe(false);
|
||||
const regex = tree.find("input[type='checkbox']");
|
||||
regex.simulate("change", { target: { checked: true } });
|
||||
expect(matcher.isRegex).toBe(true);
|
||||
});
|
||||
|
||||
it("disallows changing matcher.isRegex value when matcher.values contains 2 elements", () => {
|
||||
matcher.isRegex = true;
|
||||
matcher.values = [MatcherValueToObject("foo"), MatcherValueToObject("bar")];
|
||||
const tree = ShallowLabelValueInput();
|
||||
expect(matcher.isRegex).toBe(true);
|
||||
const regex = tree.find("input[type='checkbox']");
|
||||
regex.simulate("change", { target: { checked: false } });
|
||||
expect(matcher.isRegex).toBe(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user