Skip to content

Commit

Permalink
Add tests for isSupportedActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
sultanofcardio committed Jan 31, 2024
1 parent 4871f22 commit dc3ac26
Showing 1 changed file with 62 additions and 1 deletion.
63 changes: 62 additions & 1 deletion src/entities/activity/lib/helpers.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,67 @@
import { hasAdditionalResponse, requiresAdditionalResponse, supportsAdditionalResponseField } from "./helpers"
import {
hasAdditionalResponse,
isSupportedActivity,
requiresAdditionalResponse,
supportsAdditionalResponseField,
} from "./helpers"

import { ItemResponseTypeDTO } from "~/shared/api"

describe("Activity helpers", () => {
describe("isSupportedActivity", () => {
it("Returns false if no response types are provided", () => {
expect(isSupportedActivity()).toEqual(false)
})

it("Returns false for unsupported response types", () => {
const unsupportedResponseTypes: ItemResponseTypeDTO[] = [
"geolocation",
"drawing",
"photo",
"video",
"sliderRows",
"singleSelectRows",
"multiSelectRows",
"audio",
]

expect(isSupportedActivity(unsupportedResponseTypes)).toEqual(false)
})

it("Returns false for a mix of supported and unsupported response types", () => {
const mixedResponseTypes: ItemResponseTypeDTO[] = [
"text",
"geolocation",
"drawing",
"photo",
"video",
"sliderRows",
"singleSelectRows",
"multiSelectRows",
"audio",
]

expect(isSupportedActivity(mixedResponseTypes)).toEqual(false)
})

it("Returns true if all response types are supported", () => {
const supportedResponseTypes: ItemResponseTypeDTO[] = [
"text",
"singleSelect",
"multiSelect",
"slider",
"numberSelect",
"message",
"date",
"time",
"timeRange",
"audioPlayer",
]

expect(isSupportedActivity(supportedResponseTypes)).toEqual(true)
})
})

describe("supportsAdditionalResponseField", () => {
it("Text item should return false", () => {
expect(supportsAdditionalResponseField({ responseType: "text" })).toEqual(false)
Expand Down

0 comments on commit dc3ac26

Please sign in to comment.