Skip to content

Commit

Permalink
feat: remove ux.makeStubs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdonnalley committed Oct 24, 2023
1 parent 0ee44e4 commit 8a81413
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 66 deletions.
2 changes: 1 addition & 1 deletion .nycrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"check-coverage": true,
"lines": 80,
"lines": 79,
"statements": 70,
"functions": 70,
"branches": 60,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@oclif/plugin-help": "^5.2.8",
"@oclif/plugin-plugins": "^3.3.0",
"@oclif/prettier-config": "^0.2.1",
"@oclif/test": "^3.0.1",
"@oclif/test": "^3.0.3",
"@types/ansi-styles": "^3.2.1",
"@types/benchmark": "^2.1.2",
"@types/chai": "^4.3.8",
Expand Down
5 changes: 3 additions & 2 deletions src/cli-ux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const {
url,
wait,
} = ux

const {error, exit, warn} = Errors

export {
Expand Down Expand Up @@ -192,6 +193,6 @@ export {ActionBase} from './action/base'
export {Config, config} from './config'
export {ExitError} from './exit'
export {IPromptOptions} from './prompt'
export {makeStubs} from './stub'

export {Table} from './styled'

export {default as write} from './write'
40 changes: 0 additions & 40 deletions src/cli-ux/stub.ts

This file was deleted.

9 changes: 5 additions & 4 deletions test/cli-ux/styled/header.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import {expect} from 'chai'
import {SinonSandbox, createSandbox} from 'sinon'
import {SinonSandbox, SinonStub, createSandbox} from 'sinon'
import stripAnsi from 'strip-ansi'

import {ux} from '../../../src'

describe('styled/header', () => {
let sandbox: SinonSandbox
let stubs: ReturnType<typeof ux.makeStubs>
let stdoutStub: SinonStub

beforeEach(() => {
sandbox = createSandbox()
stubs = ux.makeStubs(sandbox)
stdoutStub = sandbox.stub(ux.write, 'stdout')
})

afterEach(() => {
Expand All @@ -18,6 +19,6 @@ describe('styled/header', () => {

it('shows a styled header', () => {
ux.styledHeader('A styled header')
expect(stubs.stdout.firstCall.firstArg).to.include('=== A styled header\n')
expect(stripAnsi(stdoutStub.firstCall.firstArg)).to.include('=== A styled header\n')
})
})
14 changes: 7 additions & 7 deletions test/command/main.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {expect} from 'chai'
import {resolve} from 'node:path'
import {SinonSandbox, createSandbox} from 'sinon'
import {SinonSandbox, SinonStub, createSandbox} from 'sinon'
import stripAnsi from 'strip-ansi'

import {Interfaces, ux} from '../../src/index'
Expand All @@ -12,11 +12,11 @@ const version = `@oclif/core/${pjson.version} ${process.platform}-${process.arch

describe('main', () => {
let sandbox: SinonSandbox
let stubs: ReturnType<typeof ux.makeStubs>
let stdoutStub: SinonStub

beforeEach(() => {
sandbox = createSandbox()
stubs = ux.makeStubs(sandbox)
stdoutStub = sandbox.stub(ux.write, 'stdout')
})

afterEach(() => {
Expand All @@ -30,12 +30,12 @@ describe('main', () => {

it('should run version', async () => {
await run(['--version'], resolve(__dirname, '../../package.json'))
expect(stubs.stdout.firstCall.firstArg).to.equal(`${version}\n`)
expect(stdoutStub.firstCall.firstArg).to.equal(`${version}\n`)
})

it('should run help', async () => {
await run(['--help'], resolve(__dirname, '../../package.json'))
expect(stubs.stdout.args.map((a) => stripAnsi(a[0])).join('')).to.equal(`base library for oclif CLIs
expect(stdoutStub.args.map((a) => stripAnsi(a[0])).join('')).to.equal(`base library for oclif CLIs
VERSION
${version}
Expand All @@ -55,7 +55,7 @@ COMMANDS

it('should show help for topics with spaces', async () => {
await run(['--help', 'foo'], resolve(__dirname, 'fixtures/typescript/package.json'))
expect(stubs.stdout.args.map((a) => stripAnsi(a[0])).join('')).to.equal(`foo topic description
expect(stdoutStub.args.map((a) => stripAnsi(a[0])).join('')).to.equal(`foo topic description
USAGE
$ oclif foo COMMAND
Expand All @@ -71,7 +71,7 @@ COMMANDS

it('should run spaced topic help v2', async () => {
await run(['foo', 'bar', '--help'], resolve(__dirname, 'fixtures/typescript/package.json'))
expect(stubs.stdout.args.map((a) => stripAnsi(a[0])).join('')).to.equal(`foo bar topic description
expect(stdoutStub.args.map((a) => stripAnsi(a[0])).join('')).to.equal(`foo bar topic description
USAGE
$ oclif foo bar COMMAND
Expand Down
21 changes: 10 additions & 11 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -786,20 +786,19 @@
wordwrap "^1.0.0"
wrap-ansi "^7.0.0"

"@oclif/core@^3.0.0-beta.17":
version "3.0.0-beta.17"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.0.0-beta.17.tgz#a6f0d22703647743aba6c9e53f0560724aba3ccb"
integrity sha512-knoDpfAVYgbVeuoUpX/es8os1GeVp//gNczB3mgNPotENXMALOZKgIv7rBbKpHa1xmpGdEf0n31WrBq3HigKwQ==
"@oclif/core@^3.6.0":
version "3.6.0"
resolved "https://registry.yarnpkg.com/@oclif/core/-/core-3.6.0.tgz#b9582f3bf1ad933a6ac0335d0437be9ac10ce3b6"
integrity sha512-qjLXQEHUajQPeHQYRU9kRv5tBCW8O4L/OvILF/8lt08RLlp24E8yK6J7ROCZMwPxYsD3YC1/AQ76br2R+O1Cqw==
dependencies:
"@types/cli-progress" "^3.11.0"
ansi-escapes "^4.3.2"
ansi-styles "^4.3.0"
cardinal "^2.1.1"
chalk "^4.1.2"
clean-stack "^3.0.1"
cli-progress "^3.12.0"
debug "^4.3.4"
ejs "^3.1.8"
ejs "^3.1.9"
get-package-type "^0.1.0"
globby "^11.1.0"
hyperlinker "^1.0.0"
Expand Down Expand Up @@ -849,12 +848,12 @@
resolved "https://registry.yarnpkg.com/@oclif/prettier-config/-/prettier-config-0.2.1.tgz#1def9f38134f9bfb229257f48a35f7d0d183dc78"
integrity sha512-XB8kwQj8zynXjIIWRm+6gO/r8Qft2xKtwBMSmq1JRqtA6TpwpqECqiu8LosBCyg2JBXuUy2lU23/L98KIR7FrQ==

"@oclif/test@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@oclif/test/-/test-3.0.1.tgz#81d7645222211640afae7512d8243d5a9c52e2c1"
integrity sha512-1oJNdnwpp1x4WhUcstgwNgbijNOdz7l5LdWiTU0ZMwkyvxcQhZKCF5puFXndV+EkYds/s/0+dZOx0rhhDILA/w==
"@oclif/test@^3.0.3":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@oclif/test/-/test-3.0.3.tgz#fe32dd96171933a323468b27951104a22673e981"
integrity sha512-hhQa732q85z71wur0Tzf9n9Z32Yiq8Hb4suNGeweYHtNQ5DmWgGqHJ57S+zs6ri0GF+xJmzRyr5qFq8KNs3Xqg==
dependencies:
"@oclif/core" "^3.0.0-beta.17"
"@oclif/core" "^3.6.0"
chai "^4.3.10"
fancy-test "^3.0.1"

Expand Down

0 comments on commit 8a81413

Please sign in to comment.