1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { ColumnSelector } from "./column-selector";
8 describe("<ColumnSelector />", () => {
9 it("shows only configurable columns", () => {
13 render: () => <span />,
19 render: () => <span />,
25 render: () => <span />,
30 cy.mount(<ColumnSelector columns={columns} onColumnToggle={cy.stub()} />);
31 cy.get('button[aria-label="Select columns"]').click();
32 cy.get('[data-cy=column-selector-li]').should('have.length', 2);
35 it("renders checked checkboxes next to selected columns", () => {
39 render: () => <span />,
45 render: () => <span />,
51 render: () => <span />,
56 cy.mount(<ColumnSelector columns={columns} onColumnToggle={cy.stub()} />);
57 cy.get('button[aria-label="Select columns"]').click();
58 cy.get('input[type=checkbox]').should('have.length', 3);
59 cy.get('input[type=checkbox]').eq(0).should('be.checked');
60 cy.get('input[type=checkbox]').eq(1).should('not.be.checked');
61 cy.get('input[type=checkbox]').eq(2).should('be.checked');
64 it("calls onColumnToggle with clicked column", () => {
68 render: () => <span />,
73 const onColumnToggle = cy.spy().as("onColumnToggle");
74 cy.mount(<ColumnSelector columns={columns} onColumnToggle={onColumnToggle} />);
75 cy.get('button[aria-label="Select columns"]').click();
76 cy.get('[data-cy=column-selector-li]').click();
77 cy.get('@onColumnToggle').should('have.been.calledWith', columns[0]);