From 25d6f8566acee822ce5d79ec1eb34bce96b004de Mon Sep 17 00:00:00 2001 From: Alex Reardon Date: Wed, 20 Jun 2018 09:01:36 +1000 Subject: [PATCH] connected droppable --- .../view/connected-droppable/dragging.spec.js | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/test/unit/view/connected-droppable/dragging.spec.js b/test/unit/view/connected-droppable/dragging.spec.js index dcb93b71ff..a3cd0bc893 100644 --- a/test/unit/view/connected-droppable/dragging.spec.js +++ b/test/unit/view/connected-droppable/dragging.spec.js @@ -1,7 +1,7 @@ // @flow import getStatePreset from '../../../utils/get-simple-state-preset'; import { makeMapStateToProps } from '../../../../src/view/droppable/connected-droppable'; -import type { State, DroppableDimension } from '../../../../src/types'; +import type { State, DroppableDimension, DraggingState } from '../../../../src/types'; import type { OwnProps, Selector, @@ -9,6 +9,8 @@ import type { } from '../../../../src/view/droppable/droppable-types'; import getOwnProps from './get-own-props'; import { getPreset } from '../../../utils/dimension'; +import { move, type IsDraggingState } from '../../../utils/dragging-state'; +import noImpact from '../../../../src/state/no-impact'; const preset = getPreset(); const state = getStatePreset(); @@ -19,6 +21,10 @@ const restingProps: MapProps = { placeholder: null, }; +const execute = (ownProps: OwnProps) => { + +}; + describe('home list', () => { const ownProps: OwnProps = getOwnProps(preset.home); it('should not break memoization between IDLE and PREPARING phases', () => { @@ -48,16 +54,49 @@ describe('home list', () => { it('should not break memoization between moves', () => { const selector: Selector = makeMapStateToProps(); const base: DraggingState = state.dragging(preset.inHome1.descriptor.id); + + const first: IsDraggingState = move(base, { x: 1, y: 1 }); + const second: IsDraggingState = move(first, { x: 0, y: 1 }); + const third: IsDraggingState = move(second, { x: -1, y: 0 }); + const props1: MapProps = selector(first, ownProps); + const props2: MapProps = selector(second, ownProps); + const props3: MapProps = selector(third, ownProps); + + const expected: MapProps = { + isDraggingOver: true, + draggingOverWith: preset.inHome1.descriptor.id, + // no placeholder when dragging in own list + placeholder: null, + }; + expect(props1).toEqual(expected); + // memoization check + expect(props2).toBe(props1); + expect(props3).toBe(props1); }); }); describe('is not dragging over', () => { + const getNoWhere = (): DraggingState => ({ + ...state.dragging(preset.inHome1.descriptor.id), + impact: { ...noImpact }, + }); + it('should indicate that it is not being dragged over', () => { + const selector: Selector = makeMapStateToProps(); + const first: MapProps = selector(getNoWhere(), ownProps); + expect(first).toEqual(restingProps); }); it('should not break memoization between moves', () => { + const selector: Selector = makeMapStateToProps(); + + const first: MapProps = selector(getNoWhere(), ownProps); + expect(first).toEqual(restingProps); + expect(selector(move(getNoWhere(), { x: 1, y: 1 }), ownProps)).toBe(first); + expect(selector(move(getNoWhere(), { x: 1, y: 1 }), ownProps)).toBe(first); + expect(selector(move(getNoWhere(), { x: 1, y: 1 }), ownProps)).toBe(first); }); }); });