Skip to content

Commit

Permalink
test: use oclif/test v4
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed May 22, 2024
1 parent f37e5ac commit 634ca19
Show file tree
Hide file tree
Showing 8 changed files with 725 additions and 241 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
"dependencies": {
"@oclif/core": "^3.26.6",
"@oclif/plugin-test-esm-1": "^0.7.16",
"@oclif/plugin-plugins": "^4.3.10"
"@oclif/plugin-plugins": "^5"
},
"devDependencies": {
"@oclif/prettier-config": "^0.2.1",
"@oclif/test": "^3",
"@oclif/test": "^4",
"@types/chai": "^4",
"@types/mocha": "^10.0.0",
"@types/mocha": "^10",
"@types/node": "^18",
"chai": "^4",
"esbuild": "^0.21.3",
Expand Down
13 changes: 6 additions & 7 deletions test/commands/commands-from-plugins.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {expect, test} from '@oclif/test'
import {runCommand} from '@oclif/test'
import {expect} from 'chai'

describe('esm1 (@oclif/plugin-test-esm-1)', () => {
test
.stdout()
.command(['esm1'])
.it('runs esm1 cmd from @oclif/plugin-test-esm-1', (ctx) => {
expect(ctx.stdout).to.contain('hello I am an ESM plugin from')
})
it('runs esm1 cmd from @oclif/plugin-test-esm-1', async () => {
const {stdout} = await runCommand(['esm1'])
expect(stdout).to.contain('hello I am an ESM plugin from')
})
})
13 changes: 6 additions & 7 deletions test/commands/esbuild.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {expect, test} from '@oclif/test'
import {runCommand} from '@oclif/test'
import {expect} from 'chai'

describe('esbuild', () => {
test
.stdout()
.command(['esbuild'])
.it('runs esbuild cmd', (ctx) => {
expect(ctx.stdout).to.contain('hello I am a bundled (esbuild) plugin')
})
it('runs esbuild cmd', async () => {
const {stdout} = await runCommand('esbuild')
expect(stdout).to.contain('hello I am a bundled (esbuild) plugin')
})
})
11 changes: 5 additions & 6 deletions test/commands/hello/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {expect, test} from '@oclif/test'
import {runCommand} from '@oclif/test'
import {expect} from 'chai'

describe('hello', () => {
test
.stdout()
.command(['hello', 'friend', '--from=oclif'])
.it('runs hello cmd', ctx => {
expect(ctx.stdout).to.contain('hello friend from oclif!')
it('runs hello cmd', async () => {
const {stdout} = await runCommand(['hello', 'friend', '--from=oclif'])
expect(stdout).to.contain('hello friend from oclif!')
})
})
23 changes: 10 additions & 13 deletions test/commands/hello/world.test.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import {expect, test} from '@oclif/test'
import {runCommand} from '@oclif/test'
import {expect} from 'chai'

describe('hello world', () => {
test
.stdout()
.command(['hello:world'])
.it('runs hello world cmd', (ctx) => {
expect(ctx.stdout).to.contain('hello world!')
})
it('runs hello world cmd', async () => {
const {stdout} = await runCommand(['hello:world'])
expect(stdout).to.contain('hello world!')
})
})

describe('hello alias', () => {
test
.stdout()
.command(['hello:alias'])
.it('runs hello alias cmd', (ctx) => {
expect(ctx.stdout).to.contain('hello world!')
})
it('runs hello alias cmd', async () => {
const {stdout} = await runCommand(['hello:alias'])
expect(stdout).to.contain('hello world!')
})
})
12 changes: 6 additions & 6 deletions test/hooks/hooks-from-plugins.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {expect, test} from '@oclif/test'
import {runHook} from '@oclif/test'
import {expect} from 'chai'

describe('hooks (@oclif/plugin-test-esm-1)', () => {
test
.stdout()
.hook('init', {id: 'mycommand'})
.do((output) => expect(output.stdout).to.contain('Greetings! from plugin-test-esm-1 init hook'))
.it('shows a message')
it('shows a message', async () => {
const {stdout} = await runHook('init', {id: 'mycommand'})
expect(stdout).to.contain('Greetings! from plugin-test-esm-1 init hook')
})
})
12 changes: 6 additions & 6 deletions test/hooks/init/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {expect, test} from '@oclif/test'
import {runHook} from '@oclif/test'
import {expect} from 'chai'

describe('hooks', () => {
test
.stdout()
.hook('init', {id: 'mycommand'})
.do((output) => expect(output.stdout).to.contain('Greetings! from plugin-test-esbuild init hook'))
.it('shows a message')
it('shows a message', async () => {
const {stdout} = await runHook('init', {id: 'mycommand'})
expect(stdout).to.contain('Greetings! from plugin-test-esbuild init hook')
})
})
Loading

0 comments on commit 634ca19

Please sign in to comment.