2012-02-25 02:13:18 +00:00
|
|
|
<!DOCTYPE html>
|
2013-02-16 15:02:26 +00:00
|
|
|
<html>
|
|
|
|
<head>
|
2013-10-29 03:32:01 +00:00
|
|
|
<meta charset="utf-8" />
|
2013-02-17 17:28:19 +00:00
|
|
|
<title>Unit Tests for contextmenu.js</title>
|
- Linting (HTML): Use double-quotes for attributes, remove redundant `type=text/css`,
indent/lbs, consistent non-use of HTML namespace, consistent indents, consistent charset
casing
- Linting (Markdown): Add `.remarkrc`, use proper hierarchical headings, use consistent
heading format, trailing spaces
- `composer.json`: consistent property spacing
- License: Add `.txt` extension, update copyright date, and reflect type (MIT) in file name
- Credits: Add self
- npm: Add `package.json` (version 3.0.0-alpha.1 for npm release only; just reserving name)
2018-05-13 01:58:13 +00:00
|
|
|
<link rel="stylesheet" href="qunit/qunit.css"/>
|
|
|
|
<script src="../editor/jquery.js"></script>
|
2013-02-17 17:28:19 +00:00
|
|
|
<script>
|
|
|
|
// Mock for browser.js
|
- Linting (HTML): Use double-quotes for attributes, remove redundant `type=text/css`,
indent/lbs, consistent non-use of HTML namespace, consistent indents, consistent charset
casing
- Linting (Markdown): Add `.remarkrc`, use proper hierarchical headings, use consistent
heading format, trailing spaces
- `composer.json`: consistent property spacing
- License: Add `.txt` extension, update copyright date, and reflect type (MIT) in file name
- Credits: Add self
- npm: Add `package.json` (version 3.0.0-alpha.1 for npm release only; just reserving name)
2018-05-13 01:58:13 +00:00
|
|
|
window.svgEditor = {ready: function(){}};
|
2013-02-17 17:28:19 +00:00
|
|
|
</script>
|
- Linting (HTML): Use double-quotes for attributes, remove redundant `type=text/css`,
indent/lbs, consistent non-use of HTML namespace, consistent indents, consistent charset
casing
- Linting (Markdown): Add `.remarkrc`, use proper hierarchical headings, use consistent
heading format, trailing spaces
- `composer.json`: consistent property spacing
- License: Add `.txt` extension, update copyright date, and reflect type (MIT) in file name
- Credits: Add self
- npm: Add `package.json` (version 3.0.0-alpha.1 for npm release only; just reserving name)
2018-05-13 01:58:13 +00:00
|
|
|
<script src="../editor/contextmenu.js"></script>
|
|
|
|
<script src="qunit/qunit.js"></script>
|
2013-02-17 17:28:19 +00:00
|
|
|
<script>
|
|
|
|
$(function() {
|
|
|
|
// log function
|
2014-04-07 05:33:44 +00:00
|
|
|
QUnit.log = function(details) {
|
2013-02-17 17:28:19 +00:00
|
|
|
if (window.console && window.console.log) {
|
2014-04-07 05:33:44 +00:00
|
|
|
window.console.log(details.result +' :: '+ details.message);
|
2013-02-17 17:28:19 +00:00
|
|
|
}
|
|
|
|
};
|
2012-02-25 02:13:18 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
function tearDown(){
|
|
|
|
svgedit.contextmenu.resetCustomMenus();
|
|
|
|
}
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
module('svgedit.contextmenu');
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
test('Test svgedit.contextmenu package', function() {
|
|
|
|
expect(4);
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
ok(svgedit.contextmenu,"contextmenu registered correctly");
|
|
|
|
ok(svgedit.contextmenu.add,"contextmenu.add registered correctly");
|
|
|
|
ok(svgedit.contextmenu.hasCustomHandler,"contextmenu hasCustomHandler registered correctly");
|
|
|
|
ok(svgedit.contextmenu.getCustomHandler,"contextmenu getCustomHandler registered correctly");
|
|
|
|
});
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
test('Test svgedit.contextmenu does not add invalid menu item', function() {
|
|
|
|
expect(3);
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
svgedit.contextmenu.add({id:"justanid"});
|
|
|
|
ok(!svgedit.contextmenu.hasCustomHandler("justanid"),"menu item with just an id is invalid");
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
svgedit.contextmenu.add({id:"idandlabel",label:"anicelabel"});
|
|
|
|
ok(!svgedit.contextmenu.hasCustomHandler("idandlabel"),"menu item with just an id and label is invalid");
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
svgedit.contextmenu.add({id:"idandlabel",label:"anicelabel",action:'notafunction'});
|
|
|
|
ok(!svgedit.contextmenu.hasCustomHandler("idandlabel"),"menu item with action that is not a function is invalid");
|
|
|
|
});
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
test('Test svgedit.contextmenu adds valid menu item', function() {
|
|
|
|
expect(2);
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
var validItem = {id:"valid",label:"anicelabel",action:function(){alert('testing')}};
|
|
|
|
svgedit.contextmenu.add(validItem);
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
ok(svgedit.contextmenu.hasCustomHandler("valid"),"Valid menu item is added.");
|
|
|
|
equals(svgedit.contextmenu.getCustomHandler("valid"),validItem.action,"Valid menu action is added.");
|
|
|
|
tearDown();
|
|
|
|
});
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
test('Test svgedit.contextmenu rejects valid duplicate menu item id', function() {
|
|
|
|
expect(1);
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
var validItem1 = {id:"valid",label:"anicelabel",action:function(){alert('testing')}};
|
|
|
|
var validItem2 = {id:"valid",label:"anicelabel",action:function(){alert('testingtwice')}};
|
|
|
|
svgedit.contextmenu.add(validItem1);
|
|
|
|
svgedit.contextmenu.add(validItem2);
|
2013-02-16 15:02:26 +00:00
|
|
|
|
2013-02-17 17:28:19 +00:00
|
|
|
equals(svgedit.contextmenu.getCustomHandler("valid"),validItem1.action,"duplicate menu item is rejected.");
|
|
|
|
tearDown();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2013-02-16 15:02:26 +00:00
|
|
|
</head>
|
|
|
|
<body>
|
- Linting (HTML): Use double-quotes for attributes, remove redundant `type=text/css`,
indent/lbs, consistent non-use of HTML namespace, consistent indents, consistent charset
casing
- Linting (Markdown): Add `.remarkrc`, use proper hierarchical headings, use consistent
heading format, trailing spaces
- `composer.json`: consistent property spacing
- License: Add `.txt` extension, update copyright date, and reflect type (MIT) in file name
- Credits: Add self
- npm: Add `package.json` (version 3.0.0-alpha.1 for npm release only; just reserving name)
2018-05-13 01:58:13 +00:00
|
|
|
<h1 id="qunit-header">Unit Tests for contextmenu.js</h1>
|
|
|
|
<h2 id="qunit-banner"></h2>
|
|
|
|
<h2 id="qunit-userAgent"></h2>
|
|
|
|
<ol id="qunit-tests"></ol>
|
|
|
|
<div id="svgroot" style="visibility:hidden"></div>
|
2013-02-16 15:02:26 +00:00
|
|
|
</body>
|
2012-02-25 02:13:18 +00:00
|
|
|
</html>
|