React には、ユーザーがクリックすると簡単な確認ウィンドウを開くボタンがあります。confirm メソッドを追加する前は、以下のテストは緑色でした。確認を追加した後、それは赤です。追加の確認で動作するようにテストを変更するにはどうすればよいですか?
削除ボタンに反応:
const DeleteButton = (props) => {
  const handleDelete = () => {
    if(confirm("Are you sure?")) {
      props.onDelete(props.id)
    }
  };
  return (
      <Button className="btn" onClick={handleDelete}>
        <i className="fa fa-trash-o"></i>
      </Button>
  );
};
これがテストです(酵素を使用):
describe('<DeleteButton />', () => {
  it("deletes the entry", () => {
    const onDelete = sinon.spy();
    const props = {id: 1, onDelete: onDelete};
    const wrapper = shallow(<DeleteButton {...props} />);
    const deleteButton = wrapper.find(Button);
    deleteButton.simulate("click");
    expect(onDelete.calledOnce).to.equal(true);
  });
});