I have been developping an app refering to https://github.com/meteor/todos/tree/react,
Here is my problem now
describe('UsersList', () => {
it('should render item', () => {
const target = { _id: 1, profile: { username:'tester', allowed:false }};
const wrapper = shallow(<User user={target} />);
expect(wrapper.find('td').at(0).text()).to.equal('tester');
expect(wrapper.find('td').at(1).childAt(0).prop('checked')).to.equal(false);
});
describe('Interaction', () => {
let target;
let wrapper;
beforeEach(() => {
target = { _id: 1, profile: { username:'tester', allowed:false }};
wrapper = shallow(<User user={target} />);
});
it('should toggle allow status', () => {
**sinon.stub(insert, 'call');**
//wrapper.find('td').at(1).childAt(0).simulate('click');
//sinon.assert.calledWith(insert.call, { _id: 1, allowed: true });
//insert.call.restore();
});
});
});
when the test runs, the complaining shows Error: call to eval() blocked by CSPcreateProxy@packages/practicalmeteor_sinon.js?hash=b2d5a9f0bc4d44b0cc741e58786e4e3a1c997c69:2406:17, and I am sure that it lead by sinon.stub
By the way , the insert is defined with ValidatedMethod
export const insert = new ValidatedMethod({
name: 'todos.insert',
validate: new SimpleSchema({
listId: { type: String },
text: { type: String },
}).validator(),
run({ listId, text }) {
return;
},
});