Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tests for PR#3811 #3812

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions src/services/codecovAI/space.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import { SpaceTopic, CookingTopic, TechnologyTopic, _getRandomTopic } from './space'

Check failure on line 1 in src/services/codecovAI/space.test.ts

View workflow job for this annotation

GitHub Actions / Run Type Checker

File '/home/runner/work/gazebo/gazebo/src/services/codecovAI/space.ts' is not a module.

Check failure on line 1 in src/services/codecovAI/space.test.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Production

File '/home/runner/work/gazebo/gazebo/src/services/codecovAI/space.ts' is not a module.

Check failure on line 1 in src/services/codecovAI/space.test.ts

View workflow job for this annotation

GitHub Actions / Upload Bundle Stats - Staging

File '/home/runner/work/gazebo/gazebo/src/services/codecovAI/space.ts' is not a module.

describe('Topic implementations', () => {
describe('SpaceTopic', () => {
const topic = new SpaceTopic()

Check failure on line 5 in src/services/codecovAI/space.test.ts

View workflow job for this annotation

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts

TypeError: SpaceTopic is not a constructor ❯ src/services/codecovAI/space.test.ts:5:19

it('has the correct id and name', () => {
expect(topic.id).toBe(1)
expect(topic.name).toBe('Space')
})

it('returns a fact about space', () => {
const validFacts = [
'The universe is expanding at an accelerating rate.',
'Black holes can warp space and time.',
'Stars are born in cosmic nurseries called nebulae.',
]

const fact = topic.getFact()
expect(validFacts).toContain(fact)
})
})

describe('CookingTopic', () => {
const topic = new CookingTopic()

it('has the correct id and name', () => {
expect(topic.id).toBe(2)
expect(topic.name).toBe('Cooking')
})

it('returns a fact about cooking', () => {
const validFacts = [
'Searing meat locks in its juices.',
'A pinch of salt enhances sweet flavors.',
'Baking requires precise measurements to succeed.',
]

const fact = topic.getFact()
expect(validFacts).toContain(fact)
})
})

describe('TechnologyTopic', () => {
const topic = new TechnologyTopic()

it('has the correct id and name', () => {
expect(topic.id).toBe(3)
expect(topic.name).toBe('Technology')
})

it('returns a fact about technology', () => {
const validFacts = [
"Moore's law predicts the doubling of transistors every couple of years.",
'Artificial intelligence is transforming numerous industries.',
'Quantum computing promises to revolutionize cryptography.',
]

const fact = topic.getFact()
expect(validFacts).toContain(fact)
})
})
})

describe('_getRandomTopic', () => {
it('returns a valid Topic instance', () => {
const topic = _getRandomTopic()

expect(topic).toBeDefined()
expect(topic.id).toBeGreaterThan(0)
expect(typeof topic.name).toBe('string')
expect(topic.name.length).toBeGreaterThan(0)

const fact = topic.getFact()
expect(typeof fact).toBe('string')
})
})
Loading