Browse Source

Fix tests

pull/36/head
Artur Arseniev 10 years ago
parent
commit
fcf32955fe
  1. 3
      src/parser/model/ParserHtml.js
  2. 17
      test/specs/parser/model/ParserHtml.js

3
src/parser/model/ParserHtml.js

@ -118,9 +118,8 @@ define(function(require) {
var parsed = this.parseNode(node);
// From: <div> <span>TEST</span> </div> <-- span is text type
// TO: <div> TEST </div> <-- div become text type
// With 'nodeChild > 1' I know that nodes were merged
if(parsed.length == 1 && parsed[0].type == 'text' &&
nodeChild > 1 && parsed[0].tagName == TEXT_NODE){
parsed[0].tagName == TEXT_NODE){
model.type = 'text';
model.content = parsed[0].content;
}else

17
test/specs/parser/model/ParserHtml.js

@ -12,6 +12,7 @@ define([path + 'model/ParserHtml', path + 'model/ParserCss', 'DomComponents'],
var dom = new DomComponents();
obj = new ParserHtml({
textTags: ['br', 'b', 'i', 'u'],
pStylePrefix: 'gjs-',
});
obj.compTypes = dom.componentTypes;
});
@ -62,6 +63,12 @@ define([path + 'model/ParserHtml', path + 'model/ParserCss', 'DomComponents'],
obj.parseClass(str).should.deep.equal(result);
});
it('Parse class string to array with special classes', function() {
var str = 'test1 test2 test3 test-4 gjs-test';
var result = ['test1', 'test2', 'test3', 'test-4'];
obj.parseClass(str).should.deep.equal(result);
});
it('Style attribute is isolated', function() {
var str = '<div id="test1" style="color:black; width:100px; test:value;"></div>';
var result = {
@ -219,10 +226,6 @@ define([path + 'model/ParserHtml', path + 'model/ParserCss', 'DomComponents'],
tagName: 'article',
attributes: {id: 'test1'},
components: [{
content: ' ',
type: 'textnode',
tagName: ''
},{
tagName: 'div'
},{
content: ' ',
@ -278,11 +281,7 @@ define([path + 'model/ParserHtml', path + 'model/ParserCss', 'DomComponents'],
},{
tagName: 'div',
type: 'text',
components: [{
tagName: 'span',
type: 'text',
content: 'nested',
}]
content: 'nested',
},{
tagName: '',
type: 'textnode',

Loading…
Cancel
Save