-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
254 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,56 @@ | ||
const {expect, test} = require('@oclif/test') | ||
const { expect, test } = require('@oclif/test'); | ||
const mock = require('mock-require'); | ||
|
||
describe('games:all', () => { | ||
before(() => { | ||
mock('../../../src/fetchers/games', '../../mocks/fetchers/games'); | ||
mock( | ||
'../../../src/utils/run-with-spinner', | ||
'../../mocks/utils/run-with-spinner' | ||
); | ||
}); | ||
|
||
after(() => { | ||
mock.stop('../../../src/fetchers/games'); | ||
mock.stop('../../../src/utils/run-with-spinner'); | ||
}); | ||
|
||
test | ||
.stdout() | ||
.command(['games:all']) | ||
.it('runs hello', ctx => { | ||
expect(ctx.stdout).to.contain('hello world') | ||
}) | ||
.stdout() | ||
.command(['games:all']) | ||
.it('shows all games data', ctx => { | ||
const lines = ctx.stdout.split('\n'); | ||
|
||
expect(lines.length).to.equal(6); | ||
|
||
expect(lines[0]).to.equal('Ronda 4 - jueves 18 de abril'); | ||
expect(lines[1]).to.equal('\tTeam1 (1) - (3) Team2'); | ||
expect(lines[2]).to.equal('Ronda 5 - jueves 25 de abril'); | ||
expect(lines[3]).to.equal('\tTeam3 (2) - (4) Team4'); | ||
expect(lines[4]).to.equal('\tTeam4 () - () Team5'); | ||
expect(lines[5]).to.equal(''); | ||
}); | ||
|
||
test | ||
.stdout() | ||
.command(['games:all', '--name', 'jeff']) | ||
.it('runs hello --name jeff', ctx => { | ||
expect(ctx.stdout).to.contain('hello jeff') | ||
}) | ||
}) | ||
.stdout() | ||
.command(['games:all', '--game-site']) | ||
.it( | ||
'shows all games data including the game site when using --game-site', | ||
ctx => { | ||
const lines = ctx.stdout.split('\n'); | ||
|
||
expect(lines.length).to.equal(6); | ||
|
||
expect(lines[0]).to.equal('Ronda 4 - jueves 18 de abril'); | ||
expect(lines[1]).to.equal( | ||
'\tTeam1 (1) - (3) Team2 -> https://www.example1.com' | ||
); | ||
expect(lines[2]).to.equal('Ronda 5 - jueves 25 de abril'); | ||
expect(lines[3]).to.equal( | ||
'\tTeam3 (2) - (4) Team4 -> https://www.example2.com' | ||
); | ||
expect(lines[4]).to.equal('\tTeam4 () - () Team5'); | ||
expect(lines[5]).to.equal(''); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,54 @@ | ||
const {expect, test} = require('@oclif/test') | ||
const { expect, test } = require('@oclif/test'); | ||
const mock = require('mock-require'); | ||
|
||
describe('games:past', () => { | ||
before(() => { | ||
mock('../../../src/fetchers/games', '../../mocks/fetchers/games'); | ||
mock( | ||
'../../../src/utils/run-with-spinner', | ||
'../../mocks/utils/run-with-spinner' | ||
); | ||
}); | ||
|
||
after(() => { | ||
mock.stop('../../../src/fetchers/games'); | ||
mock.stop('../../../src/utils/run-with-spinner'); | ||
}); | ||
|
||
test | ||
.stdout() | ||
.command(['games:past']) | ||
.it('runs hello', ctx => { | ||
expect(ctx.stdout).to.contain('hello world') | ||
}) | ||
.stdout() | ||
.command(['games:past']) | ||
.it('shows all games data that have results', ctx => { | ||
const lines = ctx.stdout.split('\n'); | ||
|
||
expect(lines.length).to.equal(5); | ||
|
||
expect(lines[0]).to.equal('Ronda 4 - jueves 18 de abril'); | ||
expect(lines[1]).to.equal('\tTeam1 (1) - (3) Team2'); | ||
expect(lines[2]).to.equal('Ronda 5 - jueves 25 de abril'); | ||
expect(lines[3]).to.equal('\tTeam3 (2) - (4) Team4'); | ||
expect(lines[4]).to.equal(''); | ||
}); | ||
|
||
test | ||
.stdout() | ||
.command(['games:past', '--name', 'jeff']) | ||
.it('runs hello --name jeff', ctx => { | ||
expect(ctx.stdout).to.contain('hello jeff') | ||
}) | ||
}) | ||
.stdout() | ||
.command(['games:past', '--game-site']) | ||
.it( | ||
'shows all games data that have results including the game site when using --game-site', | ||
ctx => { | ||
const lines = ctx.stdout.split('\n'); | ||
|
||
expect(lines.length).to.equal(5); | ||
|
||
expect(lines[0]).to.equal('Ronda 4 - jueves 18 de abril'); | ||
expect(lines[1]).to.equal( | ||
'\tTeam1 (1) - (3) Team2 -> https://www.example1.com' | ||
); | ||
expect(lines[2]).to.equal('Ronda 5 - jueves 25 de abril'); | ||
expect(lines[3]).to.equal( | ||
'\tTeam3 (2) - (4) Team4 -> https://www.example2.com' | ||
); | ||
expect(lines[4]).to.equal(''); | ||
} | ||
); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
const {expect, test} = require('@oclif/test') | ||
const { expect, test } = require('@oclif/test'); | ||
const mock = require('mock-require'); | ||
|
||
describe('games:upcoming', () => { | ||
test | ||
.stdout() | ||
.command(['games:upcoming']) | ||
.it('runs hello', ctx => { | ||
expect(ctx.stdout).to.contain('hello world') | ||
}) | ||
before(() => { | ||
mock('../../../src/fetchers/games', '../../mocks/fetchers/games'); | ||
mock( | ||
'../../../src/utils/run-with-spinner', | ||
'../../mocks/utils/run-with-spinner' | ||
); | ||
}); | ||
|
||
after(() => { | ||
mock.stop('../../../src/fetchers/games'); | ||
mock.stop('../../../src/utils/run-with-spinner'); | ||
}); | ||
|
||
test | ||
.stdout() | ||
.command(['games:upcoming', '--name', 'jeff']) | ||
.it('runs hello --name jeff', ctx => { | ||
expect(ctx.stdout).to.contain('hello jeff') | ||
}) | ||
}) | ||
.stdout() | ||
.command(['games:upcoming']) | ||
.it("shows all games data that don't have results", ctx => { | ||
const lines = ctx.stdout.split('\n'); | ||
|
||
expect(lines.length).to.equal(4); | ||
|
||
expect(lines[0]).to.equal('Ronda 4 - jueves 18 de abril'); | ||
expect(lines[1]).to.equal('Ronda 5 - jueves 25 de abril'); | ||
expect(lines[2]).to.equal('\tTeam4 () - () Team5'); | ||
expect(lines[3]).to.equal(''); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
async function allGames() { | ||
return Promise.resolve([ | ||
{ | ||
isHeader: true, | ||
date: 'jueves 18 de abril', | ||
round: 'Ronda 4', | ||
}, | ||
{ | ||
isHeader: false, | ||
teamOne: 'Team1', | ||
teamOneResult: '1', | ||
teamTwo: 'Team2', | ||
teamTwoResult: '3', | ||
gameSite: 'https://www.example1.com', | ||
}, | ||
{ | ||
isHeader: true, | ||
date: 'jueves 25 de abril', | ||
round: 'Ronda 5', | ||
}, | ||
{ | ||
isHeader: false, | ||
teamOne: 'Team3', | ||
teamOneResult: '2', | ||
teamTwo: 'Team4', | ||
teamTwoResult: '4', | ||
gameSite: 'https://www.example2.com', | ||
}, | ||
{ | ||
isHeader: false, | ||
teamOne: 'Team4', | ||
teamOneResult: '', | ||
teamTwo: 'Team5', | ||
teamTwoResult: '', | ||
}, | ||
]); | ||
} | ||
|
||
async function pastGames() { | ||
return Promise.resolve([ | ||
{ | ||
isHeader: true, | ||
date: 'jueves 18 de abril', | ||
round: 'Ronda 4', | ||
}, | ||
{ | ||
isHeader: false, | ||
teamOne: 'Team1', | ||
teamOneResult: '1', | ||
teamTwo: 'Team2', | ||
teamTwoResult: '3', | ||
gameSite: 'https://www.example1.com', | ||
}, | ||
{ | ||
isHeader: true, | ||
date: 'jueves 25 de abril', | ||
round: 'Ronda 5', | ||
}, | ||
{ | ||
isHeader: false, | ||
teamOne: 'Team3', | ||
teamOneResult: '2', | ||
teamTwo: 'Team4', | ||
teamTwoResult: '4', | ||
gameSite: 'https://www.example2.com', | ||
}, | ||
]); | ||
} | ||
|
||
async function upcomingGames() { | ||
return Promise.resolve([ | ||
{ | ||
isHeader: true, | ||
date: 'jueves 18 de abril', | ||
round: 'Ronda 4', | ||
}, | ||
{ | ||
isHeader: true, | ||
date: 'jueves 25 de abril', | ||
round: 'Ronda 5', | ||
}, | ||
{ | ||
isHeader: false, | ||
teamOne: 'Team4', | ||
teamOneResult: '', | ||
teamTwo: 'Team5', | ||
teamTwoResult: '', | ||
}, | ||
]); | ||
} | ||
|
||
module.exports = { | ||
allGames, | ||
pastGames, | ||
upcomingGames, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = async function runWithSpinner(cb) { | ||
return cb(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters