aboutsummaryrefslogtreecommitdiff
path: root/src/tools/xml-formatter/xml-formatter.service.test.ts
diff options
context:
space:
mode:
authorGravatar jmmanzano <manzano.jm@gmail.com> 2023-06-18 12:27:26 +0200
committerGravatar GitHub <noreply@github.com> 2023-06-18 10:27:26 +0000
commita6bbeaebd8e4f629ff20d6e2386be9c8734f6d8d (patch)
tree586b395e8c4854d362d844a6b15bb9cc85f52b64 /src/tools/xml-formatter/xml-formatter.service.test.ts
parentf771e7a99f962463401cdd8addd455782605675f (diff)
downloadit-tools-a6bbeaebd8e4f629ff20d6e2386be9c8734f6d8d.tar.gz
it-tools-a6bbeaebd8e4f629ff20d6e2386be9c8734f6d8d.tar.zst
it-tools-a6bbeaebd8e4f629ff20d6e2386be9c8734f6d8d.zip
feat(new tool): xml formatter (#457)
* feat(new tool): xml formatter * feat(xml-formatter): added happy path e2e tests * refactor(xml-formatter): improved unit tests * refactor(xml-formatter): add better suitable icon * feat(xml-formatter): added happy path e2e tests * feat(xml-formatter): registered xml as syntax highlighter * chore(auto-import): removed unused NSpace --------- Co-authored-by: Corentin Thomasset <corentin.thomasset74@gmail.com>
Diffstat (limited to 'src/tools/xml-formatter/xml-formatter.service.test.ts')
-rw-r--r--src/tools/xml-formatter/xml-formatter.service.test.ts27
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('');
+ });
+ });
+});