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