-define([\r
-'libs/jquery-1.9.1.min',\r
-'libs/chai', \r
-'./utils.js',\r
-'modules/documentCanvas/canvasNode'\r
-], function($, chai, utils, canvasNode) {\r
-\r
-'use strict';\r
-\r
-var assert = chai.assert;\r
-\r
-var assertDomEqual = function(lhs, rhs) {\r
- lhs.attr('id', '');\r
- rhs.attr('id', '');\r
- return assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');\r
-\r
-}\r
-\r
-suite('Create canvas node', function() { \r
- test('from description', function() {\r
- var node = canvasNode.create({tag: 'header', klass: 'some-class', content: 'some text content'});\r
- assert.equal(node.getTag(), 'header');\r
- assert.equal(node.getClass(), 'some-class');\r
- assert.equal(node.getContent(), 'some text content');\r
- assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">some text content</div>'), node.dom);\r
- });\r
- \r
- test('from dom object', function() {\r
- var node = canvasNode.create($('<div wlxml-tag="header" wlxml-class="some-class" id="1">'));\r
- assert.equal(node.getTag(), 'header');\r
- assert.equal(node.getClass(), 'some-class');\r
- //assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">'), node.dom);\r
- });\r
-});\r
-\r
-suite('class information', function() {\r
- test('class of', function() {\r
- var node = canvasNode.create({tag: 'header', klass: 'a-b-c'});\r
- assert.ok(node.isOfClass('a'), 'first level');\r
- assert.ok(node.isOfClass('a-b'), 'second level');\r
- assert.ok(node.isOfClass('a-b-c'), 'third level');\r
- assert.notOk(node.isOfClass('b-c'));\r
- \r
- var node2 = canvasNode.create({tag: 'header'});\r
- assert.notOk(node2.isOfClass('b'));\r
-\r
- });\r
-\r
-});\r
-\r
-suite('comparing nodes', function() {\r
- test('isSame', function() {\r
- var html = '<div wlxml-class="some-class" wlxml-tag="some-tag">';\r
- var dom1 = $(html);\r
- var dom2 = $(html);\r
- assert.ok(canvasNode.create(dom1).isSame(canvasNode.create(dom1)));\r
- assert.notOk(canvasNode.create(dom1).isSame(canvasNode.create(dom2)));\r
- });\r
-});\r
-\r
-\r
+define([
+'libs/jquery-1.9.1.min',
+'libs/chai',
+'./utils.js',
+'modules/documentCanvas/canvasNode'
+], function($, chai, utils, canvasNode) {
+
+'use strict';
+
+var assert = chai.assert;
+
+var assertDomEqual = function(lhs, rhs) {
+ lhs.attr('id', '');
+ rhs.attr('id', '');
+ return assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');
+
+};
+
+suite('Create canvas node', function() {
+ test('from description', function() {
+ var node = canvasNode.create({
+ tag: 'header',
+ klass: 'some-class',
+ content: 'some text content',
+ meta: {uri: 'some uri'}
+ });
+ assert.equal(node.getTag(), 'header');
+ assert.equal(node.getClass(), 'some-class');
+ assert.equal(node.getContent(), 'some text content');
+ assert.equal(node.getMetaAttr('uri'), 'some uri');
+ assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class" wlxml-meta-uri="some uri">some text content</div>'), node.dom);
+ });
+
+ test('from dom object', function() {
+ var node = canvasNode.create($('<div wlxml-tag="header" wlxml-class="some-class" id="1" wlxml-meta-uri="some uri">'));
+ assert.equal(node.getTag(), 'header');
+ assert.equal(node.getClass(), 'some-class');
+ assert.equal(node.getMetaAttr('uri'), 'some uri');
+ //assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">'), node.dom);
+ });
+});
+
+suite('class information', function() {
+ test('class of', function() {
+ var node = canvasNode.create({tag: 'header', klass: 'a-b-c'});
+ assert.ok(node.isOfClass('a'), 'first level');
+ assert.ok(node.isOfClass('a-b'), 'second level');
+ assert.ok(node.isOfClass('a-b-c'), 'third level');
+ assert.notOk(node.isOfClass('b-c'));
+
+ var node2 = canvasNode.create({tag: 'header'});
+ assert.notOk(node2.isOfClass('b'));
+
+ });
+
+});
+
+suite('comparing nodes', function() {
+ test('isSame', function() {
+ var html = '<div wlxml-class="some-class" wlxml-tag="some-tag">';
+ var dom1 = $(html);
+ var dom2 = $(html);
+ assert.ok(canvasNode.create(dom1).isSame(canvasNode.create(dom1)));
+ assert.notOk(canvasNode.create(dom1).isSame(canvasNode.create(dom2)));
+ });
+});
+
+suite('meta attributes', function() {
+ test('get list of node\'s meta attributes', function() {
+ var node = canvasNode.create({tag: 'tag', klass: 'klass', meta: {a:1, b:2}});
+ var attrs = node.getMetaAttrs();
+ var expected = [{name: 'a', value: '1'}, {name:'b', value: '2'}];
+
+ assert.deepEqual(attrs.sort(), expected.sort());
+ });
+
+ test('set meta attribute', function() {
+ var node = canvasNode.create({tag: 'tag', meta: {a:'1'}});
+ node.setMetaAttr('a', '2');
+ assert.equal(node.dom.attr('wlxml-meta-a'), '2');
+ })
+})
+
});
\ No newline at end of file