UNPKG

@applicaster/zapp-react-native-utils

Version:

Applicaster Zapp React Native utilities package

55 lines (44 loc) 1.77 kB
import { layoutV2TypeMatcher } from "../layoutV2TypeMatcher"; import { SCREEN_TYPES } from "../itemTypes"; describe("layoutV2TypeMatcher", () => { describe("Item type matcher for layouts v2", () => { describe("for playable items", () => { const audioEntry = { id: "audioEntry", type: { value: "audio" } }; const videoEntry = { id: "videoEntry", type: { value: "video" } }; const customEntryWithVideoUrl = { id: "customEntryWithVideoUrl", type: { value: "movie" }, content: { type: "video/hls" }, }; it("returns playable type", () => { expect(layoutV2TypeMatcher(audioEntry)).toBe(SCREEN_TYPES.PLAYABLE); expect(layoutV2TypeMatcher(videoEntry)).toBe(SCREEN_TYPES.PLAYABLE); expect(layoutV2TypeMatcher(customEntryWithVideoUrl)).toBe( SCREEN_TYPES.PLAYABLE ); }); it("should return river type if playable has a type map", function () { expect(layoutV2TypeMatcher(videoEntry, { video: "foobar" })).toBe( SCREEN_TYPES.RIVER ); }); }); describe("for link items", () => { const linkEntry = { id: "linkEntry", type: { value: "link" } }; it("returns link type", () => { expect(layoutV2TypeMatcher(linkEntry)).toBe(SCREEN_TYPES.LINK); }); it("should return river type if link has a type map", () => { expect(layoutV2TypeMatcher(linkEntry, { link: "foobar" })).toBe( SCREEN_TYPES.RIVER ); }); }); describe("for others", () => { const customEntry = { id: "customEntry", type: { value: "custom" } }; it("returns river type", () => { expect(layoutV2TypeMatcher(customEntry)).toBe(SCREEN_TYPES.RIVER); }); }); }); });