From b4948c553e7c5d0fccab63c50db4f1dd019f01e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BAlio=20C=C3=A9sar?= Date: Mon, 13 Jun 2022 14:42:01 -0300 Subject: [PATCH] Improve tests for --fail-on-update CLI option --- test/cli/cli.test.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index fc7c7872..24fe2123 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -10,6 +10,11 @@ describe('CLI', function () { // test execution time depends on I/O this.timeout(0) + // always start with a clean workspace + this.beforeEach(async () => { + await fs.remove(path.resolve(__dirname, './locales')) + }) + it('works without options', async () => { const subprocess = await execaCommand('yarn test:cli') @@ -102,7 +107,7 @@ describe('CLI', function () { assert.include(subprocess.stdout, '0 files were parsed') }) - it('works with `--fail-on-update` option', async () => { + it('throws error when updating translations with `--fail-on-update` option', async () => { try { await execaCommand('yarn test:cli --fail-on-update') } catch (error) { @@ -113,4 +118,12 @@ describe('CLI', function () { ) } }) + + it('works when not updating translations with `--fail-on-update` option', async () => { + // Arrange state by extracting initial translation files + await execaCommand('yarn test:cli') + + const result = await execaCommand('yarn test:cli --fail-on-update') + assert.strictEqual(result.exitCode, 0) + }) })