Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
"bugs": "https://github.com/adobe/aio-cli-plugin-info/issues",
"dependencies": {
"@adobe/aio-lib-core-config": "^5",
"@oclif/core": "^1.5.0",
"@oclif/core": "^2.0.0",
"chalk": "^4.0.0",
"debug": "^4.3.3",
"envinfo": "^7.5.0",
"js-yaml": "^4.1.0",
"open": "^8.4.2",
"proxy-from-env": "^1.1.0",
"semver": "^7.3.7"
},
Expand Down
5 changes: 3 additions & 2 deletions src/commands/report.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ OF ANY KIND, either express or implied. See the License for the specific languag
governing permissions and limitations under the License.
*/

const { Command, Flags, CliUx: { ux: cli } } = require('@oclif/core')
const { Command, Flags } = require('@oclif/core')
const envinfo = require('envinfo')
const open = require('open')

// ///////////////
const issueTemplate = `### Expected Behaviour\n
Expand Down Expand Up @@ -59,7 +60,7 @@ class ReportCommand extends Command {
const issueBody = issueTemplate.replace('%replaced%', resInfo)
url = `${baseReportUrl}?body=${encodeURIComponent(issueBody)}&title=new+bug+report&labels=bug`
}
cli.open(url)
open(url)
}
}

Expand Down
22 changes: 0 additions & 22 deletions test/__mocks__/cli-ux.js

This file was deleted.

23 changes: 7 additions & 16 deletions test/commands/report.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@ const Command = require('../../src/commands/report')
const { stdout } = require('stdout-stderr')
const envinfo = require('envinfo')
jest.mock('envinfo')
jest.mock('@oclif/core', () => {
return {
...jest.requireActual('@oclif/core'),
CliUx: {
ux: {
open: jest.fn()
}
}
}
})
const { CliUx: { ux: cli } } = require('@oclif/core')
jest.mock('open', () => jest.fn())
const open = require('open')

test('exports', async () => {
expect(typeof Command).toEqual('function')
Expand All @@ -48,7 +39,7 @@ describe('instance methods', () => {
beforeEach(() => {
command = new Command([])
envinfo.run.mockResolvedValue('ok')
cli.open.mockResolvedValue('mkay')
open.mockResolvedValue('mkay')
})

describe('run', () => {
Expand All @@ -70,7 +61,7 @@ describe('instance methods', () => {
console: false
}))
expect(stdout.output).toMatch('')
expect(cli.open).toHaveBeenCalled()
expect(open).toHaveBeenCalled()
})
})

Expand All @@ -88,7 +79,7 @@ describe('instance methods', () => {
console: false
}))
expect(stdout.output).toMatch('')
expect(cli.open).toHaveBeenCalled()
expect(open).toHaveBeenCalled()
})
})

Expand All @@ -97,7 +88,7 @@ describe('instance methods', () => {
command.config = { pjson: { bugs: { url: 'some-link' } } }
return command.run().then(() => {
expect(envinfo.run).not.toHaveBeenCalled()
expect(cli.open).toHaveBeenCalled()
expect(open).toHaveBeenCalled()
expect(stdout.output).toMatch('')
})
})
Expand All @@ -120,7 +111,7 @@ describe('instance methods', () => {
expect(envinfo.run).not.toHaveBeenCalled()
expect(stdout.output).toMatch('')
expect(command.error).toHaveBeenCalled()
expect(cli.open).not.toHaveBeenCalled()
expect(open).not.toHaveBeenCalled()
})
})
})