Skip to content

Commit

Permalink
Refactor naming of test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
leung018 committed Jun 12, 2024
1 parent 1bc8695 commit 4ce11e8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/repo/question_set.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ describe('LocalStorageQuestionSetRepo', () => {
expect(repo.getQuestionSetByName(questionSet.name)).toEqual(questionSet)
})

it("should throw error when question set name doesn't exist", () => {
it("should throw error when question set name doesn't exist for getting question set by name", () => {
expect(() => repo.getQuestionSetByName('unknown')).toThrowCustomError(
GetQuestionSetError,
'QUESTION_SET_NOT_FOUND',
)
})

it('should throw error when question set name is taken by other questionSet', () => {
it('should throw error when upserting a question set that its name is taken by other question set', () => {
repo.upsertQuestionSet(questionSet)

const anotherQuestionSet = new QuestionSetBuilderForTest()
Expand All @@ -58,25 +58,25 @@ describe('LocalStorageQuestionSetRepo', () => {
expect(repo.getQuestionSetById(questionSet.id)).toEqual(questionSet)
})

it("should throw error when question set id doesn't exist", () => {
it("should throw error when question set id doesn't exist for getting question set by id", () => {
expect(() => repo.getQuestionSetById('unknown_id')).toThrowCustomError(
GetQuestionSetError,
'QUESTION_SET_NOT_FOUND',
)
})

it('should get all question sets for added', () => {
it('should able to get all question sets for added', () => {
const questionSet2 = new QuestionSetBuilderForTest().setName('2').build()
repo.upsertQuestionSet(questionSet)
repo.upsertQuestionSet(questionSet2)
expect(repo.getQuestionSets()).toEqual([questionSet, questionSet2])
})

it('should get empty list for getQuestionSets when no question set added', () => {
it('should return empty list for getting all question sets when no question set added', () => {
expect(repo.getQuestionSets()).toEqual([])
})

it('should update questionSet', () => {
it('should able to update existing question set', () => {
repo.upsertQuestionSet(questionSet)

const updatedQuestionSet = {
Expand All @@ -90,7 +90,7 @@ describe('LocalStorageQuestionSetRepo', () => {
)
})

it('should able to delete existing questionSet', () => {
it('should able to delete existing question set', () => {
repo.upsertQuestionSet(questionSet)

const questionSetToBeDeleted = new QuestionSetBuilderForTest()
Expand Down

0 comments on commit 4ce11e8

Please sign in to comment.