From 378985f4cdc4dfe1dedf4ab130f4df5d160a4991 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Sat, 8 Feb 2025 07:05:10 +0300 Subject: [PATCH] Update tests --- .../channels-lint/single_quotes.channels.xml | 4 +++ .../input/channels-lint/valid.channels.xml | 4 +++ tests/commands/channels/lint.test.ts | 27 +++++++++++++++++++ 3 files changed, 35 insertions(+) create mode 100644 tests/__data__/input/channels-lint/single_quotes.channels.xml create mode 100644 tests/__data__/input/channels-lint/valid.channels.xml diff --git a/tests/__data__/input/channels-lint/single_quotes.channels.xml b/tests/__data__/input/channels-lint/single_quotes.channels.xml new file mode 100644 index 00000000..a95422cd --- /dev/null +++ b/tests/__data__/input/channels-lint/single_quotes.channels.xml @@ -0,0 +1,4 @@ + + + Bravo 2 + \ No newline at end of file diff --git a/tests/__data__/input/channels-lint/valid.channels.xml b/tests/__data__/input/channels-lint/valid.channels.xml new file mode 100644 index 00000000..8c499450 --- /dev/null +++ b/tests/__data__/input/channels-lint/valid.channels.xml @@ -0,0 +1,4 @@ + + + Bravo's + \ No newline at end of file diff --git a/tests/commands/channels/lint.test.ts b/tests/commands/channels/lint.test.ts index 2ba65d80..501b6989 100644 --- a/tests/commands/channels/lint.test.ts +++ b/tests/commands/channels/lint.test.ts @@ -53,4 +53,31 @@ describe('channels:lint', () => { expect((error as ExecError).stdout).toContain('2 error(s)') } }) + + it('will show a message if the file contains single quotes', () => { + try { + const cmd = + 'npm run channels:lint --- tests/__data__/input/channels-lint/single_quotes.channels.xml' + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + process.exit(1) + } catch (error) { + expect((error as ExecError).status).toBe(1) + expect((error as ExecError).stdout).toContain('single_quotes.channels.xml') + expect((error as ExecError).stdout).toContain( + '1:14 Single quotes cannot be used in attributes' + ) + } + }) + + it('does not display errors if there are none', () => { + try { + const cmd = 'npm run channels:lint --- tests/__data__/input/channels-lint/valid.channels.xml' + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + } catch (error) { + if (process.env.DEBUG === 'true') console.log((error as ExecError).stdout) + process.exit(1) + } + }) })