Как я могу написать шутник, если в компоненте используется функция, которая передается через контекст? - PullRequest
0 голосов

Необходимо протестировать компонент SlotItem.В нем функция передается через контекст this.context.i18n.t ("free")

a busy cat

Мой компонент:

import React from 'react';
import  {
  View,
  Image,
} from 'react-native';

import SamComponent from '../SamComponent';
import Label from '../Label';
import styles from './style';

export default class SlotItem extends SamComponent {
  render() {
    return (
      <View style={styles.slotItem}>
        <View style={styles.slotIcon}>
          <Image source={require('../../../images/icon-slot.png')}  />
        </View>
        <Label style={styles.slotStatus} size={15}>{ this.context.i18n.t('free') }</Label>
      </View>
    );
  }
}

Я пыталсясделать это, но я получаю ошибку.

import 'react-native'
import React from 'react'
import SlotItem from '../components/Station/SlotItem'
import renderer from 'react-test-renderer'

import {shallow, configure} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() })


it('test SlotItem', ()=>{
    const wrapper = shallow(<SlotItem />).props()
});

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...