it('should explode if adding a node that creates a cycle', () => { const graph = new Graph() .add('a', 'b'); function explode() { graph.addAndVerify('b', 'a'); } explode.should.throwError('Detected 1 cycle:\n a -> b -> a'); });
describe('#parse array', () => { it('#empty array', () => { should(x2o('<item></item>')).eql([null]); }) it('#one dimensional array', () => { should(x2o('<item>a</item><item>b</item>')).eql(['a', 'b']); }) it('#nested array', () => { should(x2o('<item><item>1</item><item></item></item><item> </item>')).eql([['1', null], ' ']) }) it('#complex array', () => { should(x2o('<xml><item><node><item><item></item></item></node></item></xml>')).eql({ xml: [{ node: [[null]] }] }); }) it('#mix item with common tags should throw error', () => { should(() => x2o('<item></item><xml></xml>')).throwError(); }) it('#mix item with text should throw error', () => { should(() => x2o('text<item></item>')).throwError(); should(() => x2o('<item></item>text')).throwError(); }) })
should(() => x2o('<b></b><a></a><a></a>')).throwError(); should(() => x2o('<a></a><a></a><b></b>')).throwError(); should(() => x2o('<a></a><b></b><a></a>')).throwError(); }) should(() => x2o('<a>')).throwError(); should(() => x2o('</a>')).throwError(); should(() => x2o('<a><b></a></b>')).throwError(); should(() => x2o('<a><![CDATA[')).throwError(); should(() => x2o('<a><![CDATA[]]>')).throwError(); should(() => x2o('<a><![CDATA[ ]]>')).throwError(); }) })
should(() => x2o('string with "&"')).throwError(); }) should(() => x2o('string with "<"')).throwError(); }) should(() => x2o('string with "]]>"')).throwError(); }) should(() => x2o('<![CDATA[')).throwError(); }) should(() => x2o('&entity;')).throwError(); }) })