我有一个基于Process.env变量加载的DIV,任何人都可以指出如何测试这个部分的方向吗?
{ process.env.STYLE === 'RNR' &&
<div className="price-option">
<span>$ <input type="text" ref="minInput" placeholder="Min" defaultValue={minValue} /></span>
<span>{i18n.l('to ')} $ <input type="text" ref="maxInput" defaultValue={maxValue} placeholder="Max" /></span>
<button onClick = {this.filterPrice.bind(this)} ref={(node) => { this.minMaxfilter = node }} >{i18n.l('Go')}</button>
</div>
}
答案 0 :(得分:0)
一种简单的方法是将const originalSTYLE = process.env.STYLE;
process.env.STYLE = 'tested-value';
// your test
// Reset original value
process.env.STYLE = originalSTYLE;
变量设置为您要测试的值。只需记住在强拆时将变量恢复为原始值。
{{1}}