mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2026-04-28 03:07:38 +02:00
49 lines
1.2 KiB
TypeScript
49 lines
1.2 KiB
TypeScript
import { addQuestion, createQuestion } from '../utils/classes'
|
|
import { Subject, Question } from '../types/basicTypes'
|
|
|
|
const question: Question = createQuestion('asd', 'asd', { type: 'simple' })
|
|
|
|
test('Adds questions to empty db', () => {
|
|
const emptyDb: Subject[] = []
|
|
addQuestion(emptyDb, 'test subject', question)
|
|
expect(emptyDb.length).toBe(1)
|
|
})
|
|
|
|
test('Adds questions next to existing', () => {
|
|
const db: Subject[] = [
|
|
{
|
|
Name: 'test subject',
|
|
Questions: [question],
|
|
},
|
|
]
|
|
addQuestion(db, 'another something', question)
|
|
expect(db.length).toBe(2)
|
|
})
|
|
|
|
test('Does not add new subject, multiple new questions', () => {
|
|
const db: Subject[] = [
|
|
{
|
|
Name: 'test subject',
|
|
Questions: [question],
|
|
},
|
|
]
|
|
addQuestion(db, 'test subject', question)
|
|
addQuestion(db, 'test subject', question)
|
|
addQuestion(db, 'test subject', question)
|
|
addQuestion(db, 'test subject', question)
|
|
expect(db.length).toBe(1)
|
|
})
|
|
|
|
test('Adds new subjects, multiple new questions', () => {
|
|
const db: Subject[] = [
|
|
{
|
|
Name: 'test subject',
|
|
Questions: [question],
|
|
},
|
|
]
|
|
addQuestion(db, 'gfjdkglfd', question)
|
|
addQuestion(db, ' somrthing test ', question)
|
|
addQuestion(db, 'aaaaaaaa', question)
|
|
expect(db.length).toBe(4)
|
|
})
|