Skip to content

Commit

Permalink
connected droppable
Browse files Browse the repository at this point in the history
  • Loading branch information
alexreardon committed Jun 19, 2018
1 parent c0557bf commit 25d6f85
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion test/unit/view/connected-droppable/dragging.spec.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
// @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,
MapProps,
} 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();
Expand All @@ -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', () => {
Expand Down Expand Up @@ -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);
});
});
});
Expand Down

0 comments on commit 25d6f85

Please sign in to comment.