我正在使用ReactJS
和迈出第一步Jest
。
下面的期望通过,即使它不应该。查看属性如何打印:
console.log(searchBox.props.url_variation);
// prints: curation/get_site_variations/
那么为什么期望没有失败呢?
jest.dontMock('../databank_web/static/js/curation_tools/SearchBox.js');
describe('SearchBox', function () {
it('loads results after click', function () {
var React = require('react/addons');
var TestUtils = React.addons.TestUtils;
var SearchBox = require('../databank_web/static/js/curation_tools/SearchBox.js');
// Render the form?
var searchBox = TestUtils.renderIntoDocument(<SearchBox
url_variation="curation/get_site_variations/"
url_golden="curation/golden_record/"/>);
console.log(searchBox.props.url_variation); // prints: curation/get_site_variations/
expect(searchBox.props.url_variation === "fail");
// Why is this passing? fail is not equal to 'curation/get_site_variations/'
});
});