UNPKG

1.28 kBJavaScriptView Raw
1/*global describe, it */
2
3var helper = require('../lib/helper')
4 , should = require('chai').should()
5;
6
7describe('helper.simplifyNode()', function(){
8 it('should return only text when really simple', function(){
9 var input = {
10 $name: 'title',
11 $attrs: {},
12 $text: 'this is a title'
13 };
14 helper.simplifyNode(input, true).should.equal('this is a title');
15 helper.simplifyNode(input).should.not.equal('this is a title');
16 });
17
18 it('should return only attributes when really simple', function(){
19 var input = {
20 $name: 'div',
21 $attrs: {id: '34', type:'thing'},
22 };
23 helper.simplifyNode(input).should.deep.equal({$name: 'div', id: '34', type: 'thing'});
24 helper.simplifyNode(input, true).should.deep.equal({id: '34', type: 'thing'});
25 });
26
27 it('should drop unecessary properties', function(){
28 var input, output;
29
30 input = {
31 $name: 'title',
32 $attrs: {id: '34'},
33 $text: null
34 };
35 output = {
36 $name: 'title',
37 id: '34'
38 };
39 helper.simplifyNode(input).should.deep.equal(output);
40 helper.simplifyNode(input, true).should.deep.equal(input.$attrs);
41 });
42});