3 'modules/documentCanvas/canvas/canvas',
4 'modules/documentCanvas/canvas/documentElement'
5 ], function(chai, canvas, documentElement) {
9 var expect = chai.expect;
11 describe('Canvas', function() {
12 describe('basic properties', function() {
13 it('renders empty document when canvas created from empty XML', function() {
14 var c = canvas.fromXML('');
15 expect(c.doc()).to.equal(null);
18 it('gives access to its document root node', function() {
19 var c = canvas.fromXML('<section></section>');
20 expect(c.doc().wlxmlTag).to.equal('section');
24 describe('document api', function() {
25 describe('document root element', function() {
26 var c = canvas.fromXML('<section></section>');
27 it('exists', function() {
28 expect(c.doc()).to.be.instanceOf(documentElement.DocumentElement);
30 it('is of type DocumentNodeElement', function() {
31 expect(c.doc()).to.be.instanceOf(documentElement.DocumentNodeElement);
36 var c = canvas.fromXML('<section><div></div></section>'),
37 children = c.doc().children();
38 expect(children.length).to.equal(3);
39 expect(children[0]).to.be.instanceOf(documentElement.DocumentTextElement);
40 expect(children[1]).to.be.instanceOf(documentElement.DocumentNodeElement);
41 expect(children[2]).to.be.instanceOf(documentElement.DocumentTextElement);
47 /*describe('Canvas', function() {
48 it('can wrap selected document nodes in a list', function() {
49 var c = canvas.fromXML('\
56 var div_alice = c.doc().children({tag: 'div'})[0];
57 var div_cat = c.doc().children({tag: 'div'})[2];
58 c.doc.wrapInList({start: div_alice, end: div_cat});
60 expect(c.doc().children().length === 3)