mirror of
https://github.com/prymitive/karma
synced 2026-05-09 03:36:44 +00:00
46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import React from "react";
|
|
|
|
import { shallow } from "enzyme";
|
|
|
|
import {
|
|
SilenceFormStore,
|
|
NewEmptyMatcher,
|
|
MatcherValueToObject
|
|
} from "Stores/SilenceFormStore";
|
|
import { SilenceMatch } from "./SilenceMatch";
|
|
|
|
let silenceFormStore;
|
|
let matcher;
|
|
|
|
beforeEach(() => {
|
|
silenceFormStore = new SilenceFormStore();
|
|
matcher = NewEmptyMatcher();
|
|
});
|
|
|
|
const ShallowLabelValueInput = () => {
|
|
return shallow(
|
|
<SilenceMatch matcher={matcher} silenceFormStore={silenceFormStore} />
|
|
);
|
|
};
|
|
|
|
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);
|
|
});
|
|
});
|