1
0
Fork 0
firefox/browser/components/aboutwelcome/tests/unit/InstallButton.test.jsx
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

49 lines
1.3 KiB
JavaScript

import React from "react";
import { shallow } from "enzyme";
import { InstallButton } from "content-src/components/InstallButton";
const TEST_ADDON_INFO = [
{
name: "Test Add-on",
id: "d634138d-c276-4fc8-924b-40a0ea21d284",
url: "http://example.com",
icons: { 32: "test.png", 64: "test.png" },
type: "extension",
},
];
describe("InstallButton component", () => {
let sandbox;
let wrapper;
let handleAction;
beforeEach(() => {
sandbox = sinon.createSandbox();
handleAction = sandbox.stub();
wrapper = shallow(
<InstallButton
key={TEST_ADDON_INFO.id}
addonId={TEST_ADDON_INFO.id}
addonType={TEST_ADDON_INFO.type}
addonName={TEST_ADDON_INFO.name}
index={"primary_button"}
handleAction={handleAction}
installedAddons={[]}
/>
);
});
it("should render InstallButton component", () => {
assert.ok(wrapper.exists());
});
it("should render the button with the correct value", () => {
assert.lengthOf(wrapper.find("button[value='primary_button']"), 1);
});
it("should call handleAction method when button is link is clicked", () => {
const btnLink = wrapper.find("button.primary");
btnLink.simulate("click");
assert.calledOnce(handleAction);
});
});