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 #3813

Closed
Changes from 1 commit
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
Next Next commit
Add Tests for PR#3811
rohitvinnakota-codecov committed Mar 17, 2025
commit 10e725d7a6306ef76aaa77d24642c964fcd6a579
76 changes: 76 additions & 0 deletions src/services/codecovAI/space.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import { describe, expect, it, vi, beforeEach } from 'vitest'

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

GitHub Actions / Run Lint

'beforeEach' is defined but never used. Allowed unused vars must match /^_/u

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

GitHub Actions / Run Lint

'vi' is defined but never used. Allowed unused vars must match /^_/u

// Import the functions and classes we're testing
import { SpaceTopic, CookingTopic, TechnologyTopic, _getRandomTopic } from './space'

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

GitHub Actions / Run Type Checker

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

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

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 4 in src/services/codecovAI/space.test.ts

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', () => {
it('has the correct id and name', () => {
const topic = new SpaceTopic()

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

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts > Topic implementations > SpaceTopic > has the correct id and name

TypeError: SpaceTopic is not a constructor ❯ src/services/codecovAI/space.test.ts:9:21
expect(topic.id).toBe(1)
expect(topic.name).toBe('Space')
})

it('returns a fact about space', () => {
const topic = new SpaceTopic()

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

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts > Topic implementations > SpaceTopic > returns a fact about space

TypeError: SpaceTopic is not a constructor ❯ src/services/codecovAI/space.test.ts:15:21
const fact = topic.getFact()
const possibleFacts = [
'The universe is expanding at an accelerating rate.',
'Black holes can warp space and time.',
'Stars are born in cosmic nurseries called nebulae.',
]
expect(possibleFacts).toContain(fact)
})
})

describe('CookingTopic', () => {
it('has the correct id and name', () => {
const topic = new CookingTopic()

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

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts > Topic implementations > CookingTopic > has the correct id and name

TypeError: CookingTopic is not a constructor ❯ src/services/codecovAI/space.test.ts:28:21
expect(topic.id).toBe(2)
expect(topic.name).toBe('Cooking')
})

it('returns a fact about cooking', () => {
const topic = new CookingTopic()

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

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts > Topic implementations > CookingTopic > returns a fact about cooking

TypeError: CookingTopic is not a constructor ❯ src/services/codecovAI/space.test.ts:34:21
const fact = topic.getFact()
const possibleFacts = [
'Searing meat locks in its juices.',
'A pinch of salt enhances sweet flavors.',
'Baking requires precise measurements to succeed.',
]
expect(possibleFacts).toContain(fact)
})
})

describe('TechnologyTopic', () => {
it('has the correct id and name', () => {
const topic = new TechnologyTopic()

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

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts > Topic implementations > TechnologyTopic > has the correct id and name

TypeError: TechnologyTopic is not a constructor ❯ src/services/codecovAI/space.test.ts:47:21
expect(topic.id).toBe(3)
expect(topic.name).toBe('Technology')
})

it('returns a fact about technology', () => {
const topic = new TechnologyTopic()

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

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts > Topic implementations > TechnologyTopic > returns a fact about technology

TypeError: TechnologyTopic is not a constructor ❯ src/services/codecovAI/space.test.ts:53:21
const fact = topic.getFact()
const possibleFacts = [
"Moore's law predicts the doubling of transistors every couple of years.",
'Artificial intelligence is transforming numerous industries.',
'Quantum computing promises to revolutionize cryptography.',
]
expect(possibleFacts).toContain(fact)
})
})
})

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

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

GitHub Actions / Test Runner #5 - Vitest

src/services/codecovAI/space.test.ts > _getRandomTopic > returns a valid Topic instance

TypeError: _getRandomTopic is not a function ❯ src/services/codecovAI/space.test.ts:67:19
expect(topic).toHaveProperty('id')
expect(topic).toHaveProperty('name')
expect(typeof topic.getFact).toBe('function')

const possibleTopics = [SpaceTopic, CookingTopic, TechnologyTopic]
const isValidTopicInstance = possibleTopics.some(TopicClass => topic instanceof TopicClass)
expect(isValidTopicInstance).toBe(true)
})
})