Esempio n. 1
0
QUnit.test("Click Radio Buttons", function () {

	var radio1 = 0,
		radio2 = 0;

	st.g("radio1")
		.checked = false;
	//make sure changes are called
	st.bind(st.g("radio1"), "change", function (ev) {
		radio1++;
	});
	st.bind(st.g("radio2"), "change", function (ev) {
		radio2++;
	});

	syn.trigger(st.g("radio1"), "click", {});

	QUnit.equal(radio1, 1, "radio event");
	QUnit.ok(st.g("radio1")
		.checked, "radio checked");

	syn.trigger(st.g("radio2"), "click", {});

	QUnit.equal(radio2, 1, "radio event");
	QUnit.ok(st.g("radio2")
		.checked, "radio checked");

	QUnit.ok(!st.g("radio1")
		.checked, "radio unchecked");

});
Esempio n. 2
0
QUnit.test("Select is changed on click", function () {

	var select1 = 0,
		select2 = 0;

	st.g("qunit-fixture")
		.innerHTML = '<select id="s1"><option id="s1o1">One</option><option id="s1o2">Two</option></select><select id="s2"><option id="s2o1">One</option><option id="s2o2">Two</option></select>';

	st.bind(st.g("s1"), "change", function (ev) {
		select1++;
	});
	st.bind(st.g("s2"), "change", function (ev) {
		select2++;
	});

	syn.trigger(st.g('s1o2'), 'click', {});
	QUnit.equal(st.g('s1')
		.selectedIndex, 1, "select worked");
	QUnit.equal(select1, 1, "change event");
	syn.trigger(st.g('s2o2'), 'click', {});
	QUnit.equal(st.g('s2')
		.selectedIndex, 1, "select worked");
	QUnit.equal(select2, 1, "change event");
	syn.trigger(st.g('s1o1'), 'click', {});
	QUnit.equal(st.g('s1')
		.selectedIndex, 0, "select worked");
	QUnit.equal(select1, 2, "change event");
});
Esempio n. 3
0
QUnit.test("Click Forms", function () {
	var submit = 0,
		submitf = function (ev) {
			submit++;
			if (ev.preventDefault) {
				ev.preventDefault();
			}
			ev.returnValue = false;
			return false;
		};
	st.bind(st.g("outer"), "submit", submitf);
	syn.trigger(st.g("submit"), "click", {});
	syn("submit", "outer", {});

	QUnit.equal(submit, 2, "Click on submit");

	//make sure clicking the div does not submit the form
	var click = 0,
		clickf = function (ev) {
			click++;
			if (ev.preventDefault) {
				ev.preventDefault();
			}
			return false;
		};
	st.binder("inner", "click", clickf);

	syn.trigger(st.g("submit"), "click", {});

	QUnit.equal(submit, 2, "Submit prevented");
	QUnit.equal(click, 1, "Clicked");

	st.unbinder("outer", "submit", submitf);
	st.unbinder("inner", "click", clickf);
});
Esempio n. 4
0
	locate("test/pages/page3.html",function(page3){
		page3 = page3.replace(".js","");
		
		var iframe = document.createElement('iframe');
	
		st.bind(iframe, "load", function () {
			var iget = function (id) {
				return iframe.contentWindow.document.getElementById(id);
			};
			st.bind(iget('select1'), "change", function () {
				QUnit.ok(true, "select worked");
			});
			st.bind(iget('select2'), "change", function () {
				QUnit.ok(true, "select worked");
			});
	
			syn.click(iget('s1o2'), {}, function () {
				QUnit.start();
				syn.click(iget('s2o2'));
				syn.click(iget('s1o1'));
			});
	
		});
	
		iframe.src = page3;
	
		st.g("qunit-fixture")
			.appendChild(iframe);
	});
Esempio n. 5
0
			var runTest = function(el){
				st.bind(el, "click", function () {
					QUnit.ok(true, "h3 was clicked");
				});
				syn.click(el, {}, function () {
					QUnit.start();
					popup.close();
				});
			};
Esempio n. 6
0
		st.bind(iframe, "load", function () {
			var iget = function (id) {
				return iframe.contentWindow.document.getElementById(id);
			};
			st.bind(iget('select1'), "change", function () {
				QUnit.ok(true, "select worked");
			});
			st.bind(iget('select2'), "change", function () {
				QUnit.ok(true, "select worked");
			});
	
			syn.click(iget('s1o2'), {}, function () {
				QUnit.start();
				syn.click(iget('s2o2'));
				syn.click(iget('s1o1'));
			});
	
		});
Esempio n. 7
0
		locate("test/pages/page2.html", function(page2){
			var iframe = document.createElement('iframe'),
				calls = 0;
			
			st.bind(iframe, "load", function () {
				if (calls === 0) {
					syn.click(iframe.contentWindow.document.getElementById("first"), {}, function () {
						iframe.contentWindow.location = page2;
					});
					calls++;
				} else {
					syn.click(iframe.contentWindow.document.getElementById("second"), {}, function () {
						QUnit.ok(iframe.contentWindow.document.getElementById("second") === iframe.contentWindow.document.activeElement);
						QUnit.start();
					});
				}
			});
			iframe.src = page1;
			st.g("qunit-fixture")
				.appendChild(iframe);
		});
Esempio n. 8
0
QUnit.test("syn basics", function () {

	QUnit.ok(syn, "syn exists");

	st.g("qunit-fixture")
		.innerHTML = "<div id='outer'><div id='inner'></div></div>";
	var mouseover = 0,
		mouseoverf = function () {
			mouseover++;
		};
	st.bind(st.g("outer"), "mouseover", mouseoverf);
	syn("mouseover", st.g("inner"));

	st.unbinder("outer", "mouseover", mouseoverf);
	QUnit.equal(mouseover, 1, "Mouseover");
	syn("mouseover", 'inner', {});

	QUnit.equal(mouseover, 1, "Mouseover on no event handlers");
	st.g("qunit-fixture")
		.innerHTML = "";

});