Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('click()', function() {
let spy = sinon.spy(function(e) {
// noop
});
let target = document.createElement('div');
click(target).subscribe(spy);
ClickEvent.simulate(target);
assert(spy.calledOnce);
ClickEvent.simulate(target);
assert(spy.calledTwice);
ClickEvent.simulate(target);
assert(spy.calledThrice);
});
it('should support keyCode up & down', () => {
const dataSource = [
{ label: 'xxx', value: 'a' },
{ label: 'empty', value: 'b' },
];
wrapper.setProps({
dataSource,
visible: true,
});
wrapper.find('input').simulate('keydown', { keyCode: 40 });
wrapper.find('input').simulate('keydown', { keyCode: 40 });
wrapper.update();
assert(
document.querySelectorAll('.next-menu-item.next-focused').length ===
1
);
wrapper.find('input').simulate('keydown', { keyCode: 13 });
wrapper.update();
assert(wrapper.find('input').prop('value') === 'b');
wrapper.find('input').simulate('keydown', { keyCode: 38 });
wrapper.find('input').simulate('keydown', { keyCode: 27 });
wrapper.find('input').simulate('keydown', { keyCode: 32 });
wrapper.find('input').simulate('keydown', { keyCode: 8 });
wrapper.find('input').simulate('keydown', { keyCode: 9 });
// wrapper.find('input').simulate('keydown', {keyCode: 38});
// wrapper.find('input').simulate('keydown', {keyCode: 13});
// assert(wrapper.find('input').prop('value') === 'a');
it('should support once method', function() {
let flag = false;
events.once(element, 'click', function(e) {
flag = true;
assert(e.target === element);
});
simulateEvents.simulate(element, 'click');
assert(flag);
flag = false;
simulateEvents.simulate(element, 'click');
assert(!flag);
});
});
it("defines a callback property", () => {
class Foo {
constructor() {
this._ = {};
}
@props.on("end")
onend() {}
}
const foo = new Foo();
assert(foo.onend === null);
assert.doesNotThrow(() => { foo.onend = it; });
assert(foo.onend === it);
assert.throws(() => { foo.onend = "not a function"; }, TypeError);
});
});
it('should test if a file exists', () => {
const validPath = join(__dirname, 'fs.js')
const invalidPath = join(__dirname, 'path-to-nowhere.js')
assert(exists(validPath))
assert(!exists(invalidPath))
})
})
it('field1.pristine should be true', () => {
assert(vm.$validator1.field1.pristine === true)
})
it('field2.pristine should be false', () => {
accessToken.delete().then(response => {
const cookies = response.meta.headers["set-cookie"];
const parsedCookie = cookie.parse(cookies);
assert(parsedCookie["access-token"] === "null");
assert(parsedCookie.Expires === "Thu, 01 Jan 1970 00:00:00 GMT");
});
});
let store1 = new Store();
let store2 = new Store();
let spy1 = sinon.spy();
let spy2 = sinon.spy();
domain.addStore(store1);
domain.addStore(store2);
store1.storeReceiveDispatch = spy1;
store2.storeReceiveDispatch = spy2;
domain.dispatch(DISPATCH_TEST1, arg);
assert(spy1.withArgs(DISPATCH_TEST1, arg).calledOnce);
assert(spy2.withArgs(DISPATCH_TEST1, arg).calledOnce);
domain.dispatch(DISPATCH_TEST2, arg);
assert(spy1.withArgs(DISPATCH_TEST2, arg).calledOnce);
assert(spy2.withArgs(DISPATCH_TEST2, arg).calledOnce);
});
it('should add and remove transparent selection class', function () {
drag = TestUtils.renderIntoDocument(
<div>
);
const node = ReactDOM.findDOMNode(drag);
assert(!document.body.classList.contains('react-draggable-transparent-selection'));
TestUtils.Simulate.mouseDown(node, {clientX: 0, clientY: 0});
assert(document.body.classList.contains('react-draggable-transparent-selection'));
TestUtils.Simulate.mouseUp(node);
assert(!document.body.classList.contains('react-draggable-transparent-selection'));
});
</div>
return Harness.testCreate(EditGridComponent, comp1).then((component) => {
Harness.testSetGet(component, [
{
field1: 'good',
field2: 'foo'
},
{
field1: 'good',
field2: 'bar'
}
]);
Harness.clickElement(component, 'li.list-group-item:nth-child(3) div.editRow');
assert(!component.checkValidity(component.getValue(), true), 'Item should not be valid');
Harness.clickElement(component, 'div.editgrid-actions button.btn-primary');
assert(component.checkValidity(component.getValue(), true), 'Item should be valid');
Harness.clickElement(component, 'li.list-group-item:nth-child(3) div.editRow');
assert(!component.checkValidity(component.getValue(), true), 'Item should not be valid');
Harness.clickElement(component, 'div.editgrid-actions button.btn-danger');
assert(component.checkValidity(component.getValue(), true), 'Item should be valid');
});
});