酶:wrapper.find('SickButton')。simulate('click')未点击

时间:2018-12-15 23:37:28

标签: unit-testing enzyme

酶:“ ^ 3.6.0”
酶适配器反应16:“ ^ 1.5.0”

所以我有一个定义如下的按钮,它没有单击:

import java.util.Scanner;

public class Lab8 {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int usernumbers[] = new int[20];
    int size = usernumbers.length;

    System.out.println("Enter integers between 1 and 100, " + "enter a 0 to end ");

    // user populates the array usernumbers
    int i = 0;
    do {
      usernumbers[i] = input.nextInt();
    } while (usernumbers[i++] != 0);

    // invokes the method to sort the array
    arraySort(usernumbers);

    System.out.println(java.util.Arrays.toString(usernumbers));

    // this invokes the method to search the array for the numbers
    linearSearch(usernumbers);

    input.close();
  }

  public static void arraySort(int[] usernumbers) {
    // bubblesort for usernumbers[]
    int a = usernumbers.length;
    for (int i = 0; i < a - 1; i++) {
      for (int j = 0; j < a - i - 1; j++) {

        if (usernumbers[j] > usernumbers[j + 1]) {
          int temp = usernumbers[j];
          usernumbers[j] = usernumbers[j + 1];
          usernumbers[j + 1] = temp;
        }
      }
    }
  }

  public static void linearSearch(int[] usernumbers) {
    int compare = usernumbers[0];
    int count = 0;

    for (int i = 0; i < usernumbers.length; i++) {
      if (compare == usernumbers[i]) {
        count++;
      } else {
        if (count > 1 && compare != 0) {
          System.out.println(compare + " occurs " + count + " times");
        }

        if (count == 1 && compare != 0) {
          System.out.println(compare + " occurs " + count + " time");
        }

        count = 1;
        compare = usernumbers[i];
      }
    }
  }
}

,我正在尝试使用以下测试表达式进行测试:

  

wrapper.find('SickButton')。simulate('click')

我该怎么做?

我的完整测试代码如下:

<SickButton type="button" disabled={loading} onClick={() => { 
addToCart().catch(err => alert(err.message));
}}>
  Add{loading && 'ing'} to Cart
</SickButton>

0 个答案:

没有答案