Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit

Permalink
fix: lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed Sep 14, 2018
1 parent 809f184 commit d561bbf
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 102 deletions.
176 changes: 88 additions & 88 deletions test/command.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,50 @@ class Command extends Base {

describe('command', () => {
fancy
.stdout()
.do(() => Command.run([]))
.do(output => expect(output.stdout).to.equal('foo\n'))
.it('logs to stdout')
.stdout()
.do(() => Command.run([]))
.do(output => expect(output.stdout).to.equal('foo\n'))
.it('logs to stdout')

fancy
.do(async () => {
class Command extends Base {
static description = 'test command'
.do(async () => {
class Command extends Base {
static description = 'test command'

async run() {
return 101
async run() {
return 101
}
}
}

expect(await Command.run([])).to.equal(101)
})
.it('returns value')
expect(await Command.run([])).to.equal(101)
})
.it('returns value')

fancy
.do(() => {
class Command extends Base {
async run() {
throw new Error('new x error')
.do(() => {
class Command extends Base {
async run() {
throw new Error('new x error')
}
}
}

return Command.run([])
})
.catch(/new x error/)
.it('errors out')
return Command.run([])
})
.catch(/new x error/)
.it('errors out')

fancy
.stdout()
.do(() => {
class Command extends Base {
async run() {
this.exit(0)
.stdout()
.do(() => {
class Command extends Base {
async run() {
this.exit(0)
}
}
}
return Command.run([])
})
.catch(/EEXIT: 0/)
.it('exits with 0')
return Command.run([])
})
.catch(/EEXIT: 0/)
.it('exits with 0')

describe('convertToCached', () => {
fancy
Expand Down Expand Up @@ -140,11 +140,11 @@ describe('command', () => {
// ],
// })
// })
.it('converts to cached with everything set')
.it('converts to cached with everything set')

fancy
// .skip()
.do(async () => {
.do(async () => {
// const c = class extends Command {
// }.convertToCached()
// expect(await c.load()).to.have.property('run')
Expand All @@ -162,9 +162,9 @@ describe('command', () => {
// flags: {},
// args: [],
// })
})
})

.it('adds plugin name')
.it('adds plugin name')

fancy
// .skip()
Expand All @@ -187,90 +187,90 @@ describe('command', () => {
// args: [],
// })
// })
.it('converts to cached with nothing set')
.it('converts to cached with nothing set')
})

describe('parse', () => {
fancy
.stdout()
.it('has a flag', async ctx => {
class CMD extends Base {
static flags = {
foo: flags.string()
}
.stdout()
.it('has a flag', async ctx => {
class CMD extends Base {
static flags = {
foo: flags.string()
}

async run() {
const {flags} = this.parse(CMD)
this.log(flags.foo)
async run() {
const {flags} = this.parse(CMD)
this.log(flags.foo)
}
}
}

await CMD.run(['--foo=bar'])
expect(ctx.stdout).to.equal('bar\n')
})
await CMD.run(['--foo=bar'])
expect(ctx.stdout).to.equal('bar\n')
})
})

describe('version', () => {
fancy
.stdout()
.add('config', () => Config.load())
.do(async () => {
await Command.run(['--version'])
})
.catch(/EEXIT: 0/)
.it('shows version', ctx => {
expect(ctx.stdout).to.equal(`${ctx.config.userAgent}\n`)
})
.stdout()
.add('config', () => Config.load())
.do(async () => {
await Command.run(['--version'])
})
.catch(/EEXIT: 0/)
.it('shows version', ctx => {
expect(ctx.stdout).to.equal(`${ctx.config.userAgent}\n`)
})
})

describe('help', () => {
fancy
.stdout()
.do(() => {
class CMD extends Command {
static flags = {help: flags.help()}
}
return CMD.run(['--help'])
})
.catch(/EEXIT: 0/)
.it('--help', ctx => {
expect(ctx.stdout).to.equal(`test command
.stdout()
.do(() => {
class CMD extends Command {
static flags = {help: flags.help()}
}
return CMD.run(['--help'])
})
.catch(/EEXIT: 0/)
.it('--help', ctx => {
expect(ctx.stdout).to.equal(`test command
USAGE
$ @oclif/command
OPTIONS
--help show CLI help
`)
})
})

fancy
.stdout()
.do(async () => {
class CMD extends Command {}
await CMD.run(['-h'])
})
.catch(/EEXIT: 0/)
.it('-h', ctx => {
.stdout()
.do(async () => {
class CMD extends Command {}
await CMD.run(['-h'])
})
.catch(/EEXIT: 0/)
.it('-h', ctx => {
// expect(process.exitCode).to.equal(0)
expect(ctx.stdout).to.equal(`test command
expect(ctx.stdout).to.equal(`test command
USAGE
$ @oclif/command
`)
})
})
})

describe('.log()', () => {
fancy
.stdout()
.do(async () => {
class CMD extends Command {
async run() { this.log('json output: %j', {a: 'foobar'}) }
}
await CMD.run([])
})
.do(ctx => expect(ctx.stdout).to.equal('json output: {"a":"foobar"}\n'))
.it('uses util.format()')
.stdout()
.do(async () => {
class CMD extends Command {
async run() { this.log('json output: %j', {a: 'foobar'}) }
}
await CMD.run([])
})
.do(ctx => expect(ctx.stdout).to.equal('json output: {"a":"foobar"}\n'))
.it('uses util.format()')
})
})
28 changes: 14 additions & 14 deletions test/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ const version = `@oclif/command/${pjson.version} ${process.platform}-${process.a

describe('main', () => {
fancy
.stdout()
.do(() => Main.run(['plugins']))
.do(output => expect(output.stdout).to.equal('no plugins installed\n'))
.it('runs plugins')
.stdout()
.do(() => Main.run(['plugins']))
.do(output => expect(output.stdout).to.equal('no plugins installed\n'))
.it('runs plugins')

fancy
.stdout()
.do(() => Main.run(['-v']))
.catch('EEXIT: 0')
.do(output => expect(output.stdout).to.equal(version + '\n'))
.it('runs -v')
.stdout()
.do(() => Main.run(['-v']))
.catch('EEXIT: 0')
.do(output => expect(output.stdout).to.equal(version + '\n'))
.it('runs -v')

fancy
.stdout()
.do(() => Main.run(['-h']))
.catch('EEXIT: 0')
.do(output => expect(output.stdout).to.equal(`oclif base command
.stdout()
.do(() => Main.run(['-h']))
.catch('EEXIT: 0')
.do(output => expect(output.stdout).to.equal(`oclif base command
VERSION
${version}
Expand All @@ -36,5 +36,5 @@ COMMANDS
plugins list installed plugins
`))
.it('runs -h')
.it('runs -h')
})

0 comments on commit d561bbf

Please sign in to comment.