this
关键字。一类组件中访问的道具,你前言您使用与访问它的代码this
。例如,如果ES6类组件具有名为data
的prop,则在JSX中编写{this.props.data}
。 ResetPassword
呈现ReturnTempPassword
组件的实例。在这里,给ReturnTempPassword
一个tempPassword
的prop,并为它tempPassword
一个至少8个字符长的字符串的值。在子项ReturnTempPassword
,访问strong
标记内的tempPassword
prop,以确保用户看到临时密码。 ResetPassword
组件应返回单个div
元素。
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.children().type() === "div"; })(), "The ResetPassword
component should return a single div
element.");'
- text: ResetPassword
的第四个子ResetPassword
应该是ReturnTempPassword
组件。
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.children().childAt(3).name() === "ReturnTempPassword"; })(), "The fourth child of ResetPassword
should be the ReturnTempPassword
component.");'
- text: ReturnTempPassword
组件应该有一个名为tempPassword
的prop。
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.find("ReturnTempPassword").props().tempPassword; })(), "The ReturnTempPassword
component should have a prop called tempPassword
.");'
- text: ReturnTempPassword
的tempPassword
道具应该等于至少8
字符的字符串。
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); const temp = mockedComponent.find("ReturnTempPassword").props().tempPassword; return typeof temp === "string" && temp.length >= 8; })(), "The tempPassword
prop of ReturnTempPassword
should be equal to a string of at least 8
characters.");'
- text: ReturnTempPassword
组件应显示您在strong
标记内作为tempPassword
支柱创建的密码。
testString: 'assert((function() { const mockedComponent = Enzyme.mount(React.createElement(ResetPassword)); return mockedComponent.find("strong").text() === mockedComponent.find("ReturnTempPassword").props().tempPassword; })(), "The ReturnTempPassword
component should display the password you create as the tempPassword
prop within strong
tags.");'
```
Your temporary password is:
{ /* change code above this line */ }