1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00
unleash.unleash/public/js/__tests__/components/feature/ArchiveFeatureComponent-test.js
2020-02-20 08:30:21 +01:00

46 lines
1.4 KiB
JavaScript

jest.dontMock("../../../components/feature/ArchiveFeatureComponent");
jest.mock("../../../stores/FeatureToggleServerFacade");
jest.autoMockOff();
var React = require("react/addons");
var TestUtils = React.addons.TestUtils;
var FeatureArchive = require("../../../components/feature/ArchiveFeatureComponent");
var Server = require("../../../stores/FeatureToggleServerFacade");
var FeatureToggleStore = require("../../../stores/FeatureToggleStore");
describe("FeatureForm", function () {
var Component;
beforeEach(function() {
var archivedToggles = [
{ name: "featureX" },
{ name: "featureY" }
];
Server.getArchivedFeatures.mockImplementation(function(cb) {
cb(archivedToggles);
});
FeatureToggleStore.initStore([], archivedToggles);
Component = TestUtils.renderIntoDocument(<FeatureArchive />);
});
afterEach(function() {
React.unmountComponentAtNode(document.body);
});
it("should render two archived features", function() {
var rows = Component.getDOMNode().querySelectorAll("tbody tr");
expect(rows.length).toEqual(2);
});
it("should revive archived feature toggle", function() {
var button = Component.getDOMNode().querySelector("tbody button");
TestUtils.Simulate.click(button);
jest.runAllTimers();
expect(Server.reviveFeature).toBeCalled();
});
});