UNPKG

1.46 kBJavaScriptView Raw
1/*global describe, it */
2
3var helper = require('../lib/helper')
4 , should = require('chai').should()
5;
6
7describe('helper.objectifyMarkup()', function(){
8 it('should add object array properties from $markup', function(){
9 var input, output;
10 input = {
11 $name: 'root',
12 $attrs: {},
13 $markup: [
14 'text',
15 [
16 {$name: 'item', $text: 'something'},
17 {$name: 'item', $text: 'else'}
18 ]
19 ]
20 };
21
22 output = {
23 $name: 'root',
24 $attrs: {},
25 $text: 'text',
26 item: ['something', 'else']
27 };
28
29 helper.objectifyMarkup(input).should.deep.equal(output);
30 });
31
32 it('should aggregate everything from $markup', function() {
33 var input, output;
34 input = {
35 $name: 'root',
36 $attrs: {},
37 $markup: [
38 'text',
39 [
40 {$name: 'item', $text: 'something'},
41 {$name: 'item', $text: 'else'}
42 ],
43 'text',
44 {$name: 'item', $text: 'otherwise'}
45 ]
46 };
47
48 output = {
49 $name: 'root',
50 $attrs: {},
51 $text: ['text', 'text'],
52 item: ['something', 'else', 'otherwise']
53 };
54 helper.objectifyMarkup(input).should.deep.equal(output);
55 });
56});