UNPKG

@instructure/quiz-grading

Version:

The Quiz React SDK by Instructure Inc.

39 lines (34 loc) 1.11 kB
import {fromJS} from 'immutable' import {expect, describe, it, vi} from 'vitest' import {mapStateToProps, mapDispatchToProps} from '../index' describe('Taking Sidebar Index', () => { describe('honorsSidebarProps', () => { const scrollToItemStub = vi.fn() const props = { scrollToItem: scrollToItemStub, } it('honors props if scrollToItem included', () => { let mapDTP = mapDispatchToProps(f => f, props) mapDTP.scrollToItem() expect(scrollToItemStub).toHaveBeenCalledOnce() }) it('honors props if sidebarOpen included', () => { const stateToProps = { quizSessions: fromJS({ activeQuizSessionId: '1', 1: { allowBacktracking: true, oneAtATimeType: 'question', }, }), sidebar: fromJS({ isOpen: true, }), } let mapDTP = mapStateToProps(stateToProps, {sidebarOpen: 'this is a prop'}) expect(mapDTP.sidebarOpen).toEqual('this is a prop') mapDTP = mapStateToProps(stateToProps, {}) expect(mapDTP.sidebarOpen).toBe(true) }) }) })