UNPKG

1.37 kBJavaScriptView Raw
1/*eslint func-names: 0, no-magic-numbers:0 */
2/*global describe, it */
3
4const helper = require('../lib/helper');
5require('chai').should();
6
7describe('helper.shouldObjectifyMarkup()', () => {
8 it('should succeed on text', () => {
9 const input = [ 'Some words' ];
10 helper.shouldObjectifyMarkup(input).should.be.true;
11 });
12
13 it('should succeed when no duplicates', () => {
14 const input = [
15 [
16 { $name: 'item', $text: 'something' },
17 { $name: 'item', $text: 'else' }
18 ],
19 [
20 { $name: 'other', $text: 'something' },
21 { $name: 'other', $text: 'else' }
22 ]
23 ];
24 helper.shouldObjectifyMarkup(input).should.be.true;
25 input.push('some text');
26 helper.shouldObjectifyMarkup(input).should.be.true;
27 });
28
29 it('should fail on duplicates', () => {
30 const input = [
31 [{ $name: 'other', $text: 'something' }],
32 [
33 { $name: 'item', $text: 'something' },
34 { $name: 'item', $text: 'else' }
35 ],
36 [{ $name: 'other', $text: 'else' }]
37 ];
38 helper.shouldObjectifyMarkup(input).should.be.false;
39 });
40
41 it('should fail on duplicate text items', () => {
42 const input = [
43 'text',
44 [
45 { $name: 'item', $text: 'something' },
46 { $name: 'item', $text: 'else' }
47 ],
48 'text'
49 ];
50 helper.shouldObjectifyMarkup(input).should.be.false;
51 });
52});