mirror of
https://gitlab.com/MrFry/mrfrys-node-server
synced 2025-04-01 20:24:18 +02:00
add question fix
This commit is contained in:
parent
1a76ca2536
commit
347952c6da
2 changed files with 51 additions and 3 deletions
48
src/tests/addQuestion.test.ts
Normal file
48
src/tests/addQuestion.test.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
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)
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue