2 'libs/jquery-1.9.1.min',
\r
5 'modules/documentCanvas/canvasNode'
\r
6 ], function($, chai, utils, canvasNode) {
\r
10 var assert = chai.assert;
\r
12 var assertDomEqual = function(lhs, rhs) {
\r
15 return assert.ok(lhs[0].isEqualNode(rhs[0]), 'nodes are equal');
\r
19 suite('Create canvas node', function() {
\r
20 test('from description', function() {
\r
21 var node = canvasNode.create({tag: 'header', klass: 'some-class', content: 'some text content'});
\r
22 assert.equal(node.getTag(), 'header');
\r
23 assert.equal(node.getClass(), 'some-class');
\r
24 assert.equal(node.getContent(), 'some text content');
\r
25 assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">some text content</div>'), node.dom);
\r
28 test('from dom object', function() {
\r
29 var node = canvasNode.create($('<div wlxml-tag="header" wlxml-class="some-class" id="1">'));
\r
30 assert.equal(node.getTag(), 'header');
\r
31 assert.equal(node.getClass(), 'some-class');
\r
32 //assertDomEqual($('<div wlxml-tag="header" wlxml-class="some-class">'), node.dom);
\r
36 suite('class information', function() {
\r
37 test('class of', function() {
\r
38 var node = canvasNode.create({tag: 'header', klass: 'a-b-c'});
\r
39 assert.ok(node.isOfClass('a'), 'first level');
\r
40 assert.ok(node.isOfClass('a-b'), 'second level');
\r
41 assert.ok(node.isOfClass('a-b-c'), 'third level');
\r
42 assert.notOk(node.isOfClass('b-c'));
\r
44 var node2 = canvasNode.create({tag: 'header'});
\r
45 assert.notOk(node2.isOfClass('b'));
\r
51 suite('comparing nodes', function() {
\r
52 test('isSame', function() {
\r
53 var html = '<div wlxml-class="some-class" wlxml-tag="some-tag">';
\r
56 assert.ok(canvasNode.create(dom1).isSame(canvasNode.create(dom1)));
\r
57 assert.notOk(canvasNode.create(dom1).isSame(canvasNode.create(dom2)));
\r