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) + } + }) })