From 6a82b6cea4730bb510e8ead6a53221b1ec15b9ae Mon Sep 17 00:00:00 2001 From: ayush-coder-hai Date: Sat, 14 Oct 2023 16:01:20 +0530 Subject: [PATCH] Added the test --- src/hooks/command_not_found/myhook.ts | 2 +- test/hooks/command_not_found/myhook.spec.ts | 10 ++++++++++ test/hooks/command_not_found/myhook.test.ts | 9 --------- 3 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 test/hooks/command_not_found/myhook.spec.ts delete mode 100644 test/hooks/command_not_found/myhook.test.ts diff --git a/src/hooks/command_not_found/myhook.ts b/src/hooks/command_not_found/myhook.ts index ad7625674b9..3f4077a2324 100644 --- a/src/hooks/command_not_found/myhook.ts +++ b/src/hooks/command_not_found/myhook.ts @@ -1,7 +1,7 @@ import {Hook} from '@oclif/core'; const hook: Hook<'command_not_found'> = async function (opts) { - if (opts.id === 'help') { process.stdout.write(`help hook running ${opts.id}\n`);} + if (opts.id === 'help') { process.stdout.write(`${opts.id} command not found.\n`);} }; export default hook; diff --git a/test/hooks/command_not_found/myhook.spec.ts b/test/hooks/command_not_found/myhook.spec.ts new file mode 100644 index 00000000000..bab80936b07 --- /dev/null +++ b/test/hooks/command_not_found/myhook.spec.ts @@ -0,0 +1,10 @@ +import {expect, test} from '@oclif/test'; + +describe('hooks', () => { + test + .stdout() + .hook('command_not_found', {id: 'help'}) + .do(output => expect(output.stdout).to.contain('help command not found.')) + .it('shows a message'); +}); + diff --git a/test/hooks/command_not_found/myhook.test.ts b/test/hooks/command_not_found/myhook.test.ts deleted file mode 100644 index 29e1413428d..00000000000 --- a/test/hooks/command_not_found/myhook.test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import {expect, test} from '@oclif/test'; - -describe('hooks', () => { - test - .stdout() - .hook('init', {id: 'mycommand'}) - .do(output => expect(output.stdout).to.contain('example hook running mycommand')) - .it('shows a message'); -});