github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/src/views/cluster/components/range/range.spec.tsx (about)

     1  // Copyright 2020 The Cockroach Authors.
     2  //
     3  // Use of this software is governed by the Business Source License
     4  // included in the file licenses/BSL.txt.
     5  //
     6  // As of the Change Date specified in that file, in accordance with
     7  // the Business Source License, use of this software will be governed
     8  // by the Apache License, Version 2.0, included in the file
     9  // licenses/APL.txt.
    10  
    11  import React from "react";
    12  import RangeSelect, {RangeOption} from "src/views/cluster/components/range/index";
    13  import {mount} from "enzyme";
    14  import moment from "moment";
    15  import {TimeWindow} from "src/redux/timewindow";
    16  import { assert } from "chai";
    17  import "src/enzymeInit";
    18  
    19  describe("RangeSelect", function() {
    20    describe("basic dropdown", function() {
    21      it("should show all options on dropdown activation", function() {
    22        const options: RangeOption[] = [
    23          { value: "1", label: "1", timeLabel: "1" },
    24          { value: "2", label: "2", timeLabel: "2" },
    25          { value: "3", label: "3", timeLabel: "3" },
    26        ];
    27        const value: TimeWindow = {
    28          start: moment.utc().subtract(moment.duration(1, "day")),
    29          end: moment.utc(),
    30        };
    31        const rangeSelect = mount(<RangeSelect options={options} onChange={() => {}}
    32                                               changeDate={() => {}}
    33                                               value={value} selected={{}}
    34                                               onOpened={() => {}}
    35                                               useTimeRange={false} />);
    36  
    37        rangeSelect.find(".click-zone").simulate("click");
    38        assert.lengthOf(rangeSelect.find("button .__option-label"), 3);
    39      });
    40    });
    41  });