javascript Jest / Enzyme React Native Test for Array

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了javascript Jest / Enzyme React Native Test for Array相关的知识,希望对你有一定的参考价值。

import React from 'react';
import { mount } from 'enzyme';
import TextAccordion from '../index';

const items = [
  {
    label: 'In progress',
    title: "What'ts the problem",
    value: 'Lorem ipsum',
    onPress: () => console.log('onpress'),
    stageComplete: true,
  },
];

describe('Text Accordion', () => {
  test('should render the label, title and value', () => {
    const textAccordion = mount(<TextAccordion items={items} />);
    expect(textAccordion.prop('items')).toEqual(
      expect.arrayContaining([
        expect.objectContaining({
          label: expect.any(String),
          title: expect.any(String),
          value: expect.any(String),
          onPress: expect.any(Function),
          stageComplete: expect.any(Boolean),
        }),
      ]),
    );
    expect(textAccordion).toMatchSnapshot();
  });
});

以上是关于javascript Jest / Enzyme React Native Test for Array的主要内容,如果未能解决你的问题,请参考以下文章

Jest + Enzyme React 组件测试实践

Jest + Enzyme React 组件测试实践

React / Enzyme:运行 Jest / Enzyme 测试时出现 Invariant Violation 错误

Jest 和 Enzyme 的问题

React/Jest/Enzyme - 等待时间不够长

Jest / Enzyme - 如何在不同的视口进行测试?