小编Tim*_*rce的帖子

带道具的玩笑快照

我正在尝试制作此组件的快照:

export default class LoginExternalApi extends Component {
  constructor(props) {
    super(props);
  }

  render() {
    let store = this.props.store.getState();

    return (
      <View style={styles.container}>
        {store.facebookToken ? null : <FacebookButtonConnect />}
        {store.spotifyToken ? null : <SpotifyButtonConnect />}
      </View>
    )
  }
}
Run Code Online (Sandbox Code Playgroud)

正如你所看到的,我在方法中有一个store变量render(),它调用了一个 props。

这是我基于 Jest librairie 的测试文件:

import 'react-native';
import React from 'react';
import LoginExternalApi from '../app/scenes/LoginExternalApi';

import renderer from 'react-test-renderer';

test('LoginExternalApi scene renders correctly', () => {
  const tree = renderer.create(
    <LoginExternalApi />
  ).toJSON();

  expect(tree).toMatchSnapshot();
});
Run Code Online (Sandbox Code Playgroud)

这是我的错误: TypeError: …

javascript snapshot reactjs jestjs

5
推荐指数
1
解决办法
1886
查看次数

链接插值i18n

我使用ember-i18n来处理项目中的多个语言,我需要在翻译中插入一个链接(使用插值).

任何的想法 ?

handlebars.js ember.js

2
推荐指数
1
解决办法
691
查看次数

表达式`p[i&amp;1]+=v,p` 是什么意思?

我正在用 CodeFights 练习我的 javascript,在我完成一个练习后,我看到了这个函数:

// Subject : 
// Several people are standing in a row and need to be divided into two teams. 
// The first person goes into team 1, the second goes into team 2, 
// the third goes into team 1 again, the fourth into team 2, and so on.
// You are given an array of positive integers - the weights of the people. 
// Return an array of two integers, where the first element is …
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6

0
推荐指数
1
解决办法
467
查看次数