Skip to content

Commit

Permalink
fix(test): added unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
bittricky committed May 31, 2024
1 parent 370779e commit 2d64382
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 30 deletions.
72 changes: 72 additions & 0 deletions test/commands/generate.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import {runCommand} from '@oclif/test'
import {expect} from 'chai'

describe('Generate Command', () => {
it('should generate Powerball numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'powerball'])
expect(result.stdout).to.match(/Here are your powerball numbers: (\d+, ){5}\d+/)
})

it('should generate Mega Millions numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'megamillions'])
expect(result.stdout).to.match(/Here are your megamillions numbers: (\d+, ){5}\d+/)
})

it('should generate EuroMillions numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'euromillions'])
expect(result.stdout).to.match(/Here are your euromillions numbers: (\d+, ){4}\d+, \d+, \d+/)
})

it('should generate UK Lotto numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'uklotto'])
expect(result.stdout).to.match(/Here are your uklotto numbers: (\d+, ){5}\d+/)
})

it('should generate El Gordo numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'elgordo'])
expect(result.stdout).to.match(/Here are your elgordo numbers: (\d+, ){4}\d+/)
})

it('should generate SuperEnalotto numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'superenalotto'])
expect(result.stdout).to.match(/Here are your superenalotto numbers: (\d+, ){5}\d+/)
})

it('should generate Australian Powerball numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'auspowerball'])
expect(result.stdout).to.match(/Here are your auspowerball numbers: (\d+, ){7}\d+/)
})

it('should generate Oz Lotto numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'ozlotto'])
expect(result.stdout).to.match(/Here are your ozlotto numbers: (\d+, ){6}\d+/)
})

it('should generate Canada Lotto 6/49 numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'canada649'])
expect(result.stdout).to.match(/Here are your canada649 numbers: (\d+, ){5}\d+/)
})

it('should generate Canada Lotto Max numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'canadamax'])
expect(result.stdout).to.match(/Here are your canadamax numbers: (\d+, ){6}\d+/)
})

it('should generate France Loto numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'franceloto'])
expect(result.stdout).to.match(/Here are your franceloto numbers: (\d+, ){4}\d+, \d+/)
})

it('should generate German Lotto numbers', async () => {
const result = await runCommand(['generate', '--lotto', 'germanlotto'])
expect(result.stdout).to.match(/Here are your germanlotto numbers: (\d+, ){5}\d+, \d+/)
})

it('should throw an error for unsupported lottery type', async () => {
try {
await runCommand(['generate', '--lotto', 'unsupported'])
} catch (error) {
expect(error.message).to.include('Unsupported lottery')
}
})
})
30 changes: 0 additions & 30 deletions test/commands/generate.ts

This file was deleted.

0 comments on commit 2d64382

Please sign in to comment.