mirror of
https://github.com/leon-ai/leon.git
synced 2024-09-20 14:27:40 +03:00
test(package/trend): GitHub module done
This commit is contained in:
parent
8997d69174
commit
1ba72b45b8
@ -80,7 +80,7 @@ def github(string, entities):
|
||||
}
|
||||
)
|
||||
|
||||
utils.output('end', 'done', utils.translate(answerkey, {
|
||||
utils.output('end', answerkey, utils.translate(answerkey, {
|
||||
'limit': limit,
|
||||
'tech': tech,
|
||||
'result': result
|
||||
|
@ -3,7 +3,7 @@
|
||||
describe('trend:github', async () => {
|
||||
test('forces limit', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Give me the 30 latest trends on GitHub')
|
||||
await global.nlu.process('Give me the 30 latest GitHub trends')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
@ -14,7 +14,106 @@ describe('trend:github', async () => {
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'limit_max',
|
||||
'reaching',
|
||||
'done'
|
||||
'today'
|
||||
])
|
||||
})
|
||||
|
||||
test('gives the 16 trends', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Give me the 16 latest GitHub trends')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
console.log(global.brain.finalOutput)
|
||||
|
||||
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(16)
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'reaching',
|
||||
'today'
|
||||
])
|
||||
})
|
||||
|
||||
test('gives the default number of trends of this week', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Give me the GitHub trends of this week')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
console.log(global.brain.finalOutput)
|
||||
|
||||
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(5)
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'reaching',
|
||||
'week'
|
||||
])
|
||||
})
|
||||
|
||||
test('gives the default number of trends of this month', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Give me the GitHub trends of this month')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
console.log(global.brain.finalOutput)
|
||||
|
||||
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(5)
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'reaching',
|
||||
'month'
|
||||
])
|
||||
})
|
||||
|
||||
test('gives the 7 trends for the Python language', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Give me the 7 GitHub trends for the Python language')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
console.log(global.brain.finalOutput)
|
||||
|
||||
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(7)
|
||||
expect(global.brain.finalOutput.speech.indexOf('Python')).not.toBe(-1)
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'reaching',
|
||||
'today_with_tech'
|
||||
])
|
||||
})
|
||||
|
||||
test('gives the 14 trends of this week for the JavaScript language', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Give me the 14 GitHub trends of this week for the JavaScript language')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
console.log(global.brain.finalOutput)
|
||||
|
||||
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(14)
|
||||
expect(global.brain.finalOutput.speech.indexOf('JavaScript')).not.toBe(-1)
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'reaching',
|
||||
'week_with_tech'
|
||||
])
|
||||
})
|
||||
|
||||
test('gives the default number of trends of this month for the CSS language', async () => {
|
||||
global.nlu.brain.execute = jest.fn()
|
||||
await global.nlu.process('Give me the GitHub trends of this month for the CSS language')
|
||||
|
||||
const [obj] = global.nlu.brain.execute.mock.calls
|
||||
await global.brain.execute(obj[0])
|
||||
|
||||
console.log(global.brain.finalOutput)
|
||||
|
||||
expect(global.brain.finalOutput.speech.split('</li>').length - 1).toBe(5)
|
||||
expect(global.brain.finalOutput.speech.indexOf('CSS')).not.toBe(-1)
|
||||
expect(global.brain.finalOutput.codes).toIncludeSameMembers([
|
||||
'reaching',
|
||||
'month_with_tech'
|
||||
])
|
||||
})
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user