-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving testing utilities out of connected draggable
- Loading branch information
1 parent
8db4a5e
commit c0557bf
Showing
13 changed files
with
215 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// @flow | ||
import type { | ||
OwnProps, | ||
} from '../../../../src/view/draggable/draggable-types'; | ||
import type { | ||
DraggableDimension, | ||
} from '../../../../src/types'; | ||
|
||
export default (dimension: DraggableDimension): OwnProps => ({ | ||
draggableId: dimension.descriptor.id, | ||
index: dimension.descriptor.index, | ||
isDragDisabled: false, | ||
disableInteractiveElementBlocking: false, | ||
children: () => null, | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// @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 { | ||
OwnProps, | ||
Selector, | ||
MapProps, | ||
} from '../../../../src/view/droppable/droppable-types'; | ||
import getOwnProps from './get-own-props'; | ||
import { getPreset } from '../../../utils/dimension'; | ||
|
||
const preset = getPreset(); | ||
const state = getStatePreset(); | ||
|
||
const execute = (droppable: DroppableDimension) => { | ||
const ownProps: OwnProps = getOwnProps(droppable); | ||
ownProps.isDropDisabled = true; | ||
const selector: Selector = makeMapStateToProps(); | ||
const defaultDisabledProps: MapProps = selector(state.idle, ownProps); | ||
const expected: MapProps = { | ||
isDraggingOver: false, | ||
draggingOverWith: null, | ||
placeholder: null, | ||
}; | ||
|
||
it('should have the expected disabled props while resting', () => { | ||
expect(defaultDisabledProps).toEqual(expected); | ||
}); | ||
|
||
// always dragging inside of home | ||
state.allPhases(preset.inHome1.descriptor.id).forEach((current: State) => { | ||
it(`should return disabled map props when in phase ${current.phase}`, () => { | ||
const result: MapProps = selector(current, ownProps); | ||
// memoization check | ||
expect(result).toBe(defaultDisabledProps); | ||
}); | ||
}); | ||
}; | ||
|
||
describe('home list', () => { | ||
execute(preset.home); | ||
}); | ||
|
||
describe('in foreign list', () => { | ||
execute(preset.foreign); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// @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 { | ||
OwnProps, | ||
Selector, | ||
MapProps, | ||
} from '../../../../src/view/droppable/droppable-types'; | ||
import getOwnProps from './get-own-props'; | ||
import { getPreset } from '../../../utils/dimension'; | ||
|
||
const preset = getPreset(); | ||
const state = getStatePreset(); | ||
|
||
const restingProps: MapProps = { | ||
isDraggingOver: false, | ||
draggingOverWith: null, | ||
placeholder: null, | ||
}; | ||
|
||
describe('home list', () => { | ||
const ownProps: OwnProps = getOwnProps(preset.home); | ||
it('should not break memoization between IDLE and PREPARING phases', () => { | ||
const selector: Selector = makeMapStateToProps(); | ||
|
||
const defaultProps: MapProps = selector(state.idle, ownProps); | ||
// checking value | ||
expect(defaultProps).toEqual(restingProps); | ||
// checking memoization | ||
expect(selector(state.preparing, ownProps)).toBe(defaultProps); | ||
}); | ||
|
||
describe('is dragging over', () => { | ||
it('should indicate that it is being dragged over', () => { | ||
const selector: Selector = makeMapStateToProps(); | ||
const props: MapProps = selector(state.dragging(preset.inHome1.descriptor.id), ownProps); | ||
|
||
const expected: MapProps = { | ||
isDraggingOver: true, | ||
draggingOverWith: preset.inHome1.descriptor.id, | ||
// no placeholder when dragging in own list | ||
placeholder: null, | ||
}; | ||
expect(props).toEqual(expected); | ||
}); | ||
|
||
it('should not break memoization between moves', () => { | ||
const selector: Selector = makeMapStateToProps(); | ||
const base: DraggingState = state.dragging(preset.inHome1.descriptor.id); | ||
}); | ||
}); | ||
|
||
describe('is not dragging over', () => { | ||
it('should indicate that it is not being dragged over', () => { | ||
|
||
}); | ||
|
||
it('should not break memoization between moves', () => { | ||
|
||
}); | ||
}); | ||
}); | ||
|
||
describe('foreign list', () => { | ||
// as above, but also that placeholder is there! | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// @flow | ||
import type { DroppableDimension } from '../../../../src/types'; | ||
import type { OwnProps } from '../../../../src/view/droppable/droppable-types'; | ||
|
||
export default (dimension: DroppableDimension): OwnProps => ({ | ||
droppableId: dimension.descriptor.id, | ||
type: dimension.descriptor.type, | ||
isDropDisabled: false, | ||
direction: dimension.axis.direction, | ||
ignoreContainerClipping: false, | ||
children: () => null, | ||
}); | ||
|
Oops, something went wrong.