canvas3 wip - testing simple api, children
[fnpeditor.git] / modules / documentCanvas / canvas / canvas.test3.js
1 define([
2 'libs/chai',
3 'modules/documentCanvas/canvas/canvas',
4 'modules/documentCanvas/canvas/documentElement'
5 ], function(chai, canvas, documentElement) {
6     
7 'use strict';
8
9 var expect = chai.expect;
10
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);
16         });
17
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');
21         });
22     });
23
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);
29             });
30             it('is of type DocumentNodeElement', function() {
31                 expect(c.doc()).to.be.instanceOf(documentElement.DocumentNodeElement);
32             });
33         });
34
35         it('a', function() {
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);
42         });
43
44     });
45 });
46
47 /*describe('Canvas', function() {
48     it('can wrap selected document nodes in a list', function() {
49         var c = canvas.fromXML('\
50             <section>\
51                 <div>Alice</div>\
52                 <div>has</div>\
53                 <div>a cat</div>\
54             </section>
55         ');
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});
59
60         expect(c.doc().children().length === 3)
61
62
63     })
64 });*/
65
66
67
68
69 });