it('should catch log and rethrow an error thrown by the processor', function () { const visitor = new XmlUsageVisitorSum(); const node = xsd.select1('//xs:complexType'); visitor.visit(node, jsonSchema, xsd); expect(Object.keys(visitor.uris).length).toEqual(1); expect(visitor.tagCounts.AttributeTestType).toEqual(1); visitor.dump(); });
it('should ensure the xsd has not already been added to the uris map before beginning', function () { var visitor = new XmlUsageVisitorSum(); var cont = visitor.onBegin(jsonSchema, xsd); expect(cont).toBeTruthy(); visitor = new XmlUsageVisitorSum(); visitor.addSchema(xsd.uri); cont = visitor.onBegin(jsonSchema, xsd); expect(cont).toBeFalsy(); })
it('should add tag name to the given schema initializing the count or incrementing the tag count as needed', function () { const visitor = new XmlUsageVisitorSum(); visitor.addSchema(uri); visitor.addTag(tagName); expect(visitor.tagCounts[tagName]).toEqual(1); visitor.addTag(tagName); visitor.addTag(tagName); visitor.addTag(tagName); expect(visitor.tagCounts[tagName]).toEqual(4); });
it('should add a schema to the the uris map', function () { const visitor = new XmlUsageVisitorSum(); expect(Object.keys(visitor.uris).length).toEqual(0); visitor.addSchema(uri); expect(Object.keys(visitor.uris).length).toEqual(1); });