diff options
Diffstat (limited to 'src/tools/xml-formatter/xml-formatter.service.test.ts')
-rw-r--r-- | src/tools/xml-formatter/xml-formatter.service.test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tools/xml-formatter/xml-formatter.service.test.ts b/src/tools/xml-formatter/xml-formatter.service.test.ts new file mode 100644 index 0000000..2b14558 --- /dev/null +++ b/src/tools/xml-formatter/xml-formatter.service.test.ts @@ -0,0 +1,27 @@ +import { describe, expect, it } from 'vitest'; +import { formatXml } from './xml-formatter.service'; + +describe('xml-formatter service', () => { + describe('formatXml', () => { + it('converts XML into a human readable format', () => { + const initString = '<hello><world>foo</world><world>bar</world></hello>'; + + expect(formatXml(initString)).toMatchInlineSnapshot(` + "<hello> + <world> + foo + </world> + <world> + bar + </world> + </hello>" + `); + }); + + it('returns an empty string if the input is not valid XML', () => { + const initString = 'hello world'; + + expect(formatXml(initString)).toEqual(''); + }); + }); +}); |