generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #233 from Arquisoft/more_unit_testing
More unit testing
- Loading branch information
Showing
8 changed files
with
86 additions
and
213 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 was deleted.
Oops, something went wrong.
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,30 @@ | ||
import { getCategoryWithNumber, getCategoryColor, getCategoryColorWithNumber } from './categories'; | ||
|
||
describe('Test Category Functions', () => { | ||
test('getCategoryWithNumber should return correct category', () => { | ||
expect(getCategoryWithNumber(1)).toBe('Sports'); | ||
expect(getCategoryWithNumber(2)).toBe('Science'); | ||
}); | ||
|
||
test('getCategoryWithNumber should return undefined for non-existent number', () => { | ||
expect(getCategoryWithNumber(6)).toBeUndefined(); | ||
}); | ||
|
||
test('getCategoryColor should return correct color', () => { | ||
expect(getCategoryColor('Sports')).toBe('#1f71b3'); | ||
expect(getCategoryColor('Science')).toBe('#61a33a'); | ||
}); | ||
|
||
test('getCategoryColor should return undefined for non-existent category', () => { | ||
expect(getCategoryColor('Math')).toBeUndefined(); | ||
}); | ||
|
||
test('getCategoryColorWithNumber should return correct color for a number', () => { | ||
expect(getCategoryColorWithNumber(1)).toBe('#1f71b3'); | ||
expect(getCategoryColorWithNumber(2)).toBe('#61a33a'); | ||
}); | ||
|
||
test('getCategoryColorWithNumber should return undefined for non-existent number', () => { | ||
expect(getCategoryColorWithNumber(6)).toBeUndefined(); | ||
}); | ||
}); |
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,42 @@ | ||
const axios = require('axios'); | ||
import {expect, jest, test} from '@jest/globals'; | ||
|
||
import { | ||
getSportQuestions, | ||
getScienceQuestions, | ||
getHistoryQuestions, | ||
getGeographyQuestions, | ||
getEntertainmentQuestions | ||
} from './trivia_service'; | ||
|
||
jest.mock('axios', () => { | ||
return { | ||
get: () => {return {data: [{ | ||
"text": "What is the capital of France?", | ||
"answers": ["London", "Berlin", "Paris", "Madrid"], | ||
"correctAnswer": 2 | ||
}] }}}}) | ||
|
||
describe('Test Question Functions', () => { | ||
|
||
test('getSportQuestions should return a question', async () => { | ||
const question = await getSportQuestions(); | ||
expect(question.text).toBe("What is the capital of France?"); | ||
}); | ||
test('getSportQuestions should return a question', async () => { | ||
const question = await getScienceQuestions(); | ||
expect(question.text).toBe("What is the capital of France?"); | ||
}); | ||
test('getSportQuestions should return a question', async () => { | ||
const question = await getHistoryQuestions(); | ||
expect(question.text).toBe("What is the capital of France?"); | ||
}); | ||
test('getSportQuestions should return a question', async () => { | ||
const question = await getGeographyQuestions(); | ||
expect(question.text).toBe("What is the capital of France?"); | ||
}); | ||
test('getSportQuestions should return a question', async () => { | ||
const question = await getEntertainmentQuestions(); | ||
expect(question.text).toBe("What is the capital of France?"); | ||
}); | ||
}); |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.