fix(tests): grid
This commit is contained in:
@@ -11,8 +11,8 @@ describe('Advanced Flow Rendering', () => {
|
|||||||
it('renders a grid', () => {
|
it('renders a grid', () => {
|
||||||
cy.get('.react-flow__grid');
|
cy.get('.react-flow__grid');
|
||||||
|
|
||||||
const gridStroke = Cypress.$('.react-flow__grid path').attr('stroke');
|
const gridStroke = Cypress.$('.react-flow__grid path').attr('fill');
|
||||||
expect(gridStroke).to.equal('#aaa');
|
expect(gridStroke).to.equal('#888');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('connects nodes', () => {
|
it('connects nodes', () => {
|
||||||
|
|||||||
@@ -8,8 +8,11 @@ describe('Basic Flow Rendering', () => {
|
|||||||
cy.get('.react-flow__node').children('div').children('.react-flow__handle');
|
cy.get('.react-flow__node').children('div').children('.react-flow__handle');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not render a grid', () => {
|
it('renders a grid', () => {
|
||||||
cy.get('.react-flow__grid').should('not.exist');
|
cy.get('.react-flow__grid');
|
||||||
|
|
||||||
|
const gridStroke = Cypress.$('.react-flow__grid path').attr('stroke');
|
||||||
|
expect(gridStroke).to.equal('#eee');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('selects a node', () => {
|
it('selects a node', () => {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const createGridDots = (width, height, xOffset, yOffset, gap, size) => {
|
|||||||
return values.join(' ');
|
return values.join(' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
const Grid = memo(({gap, color, size, style, className, gridStyle}) => {
|
const Grid = memo(({gap, color, size, style, className, backgroundType}) => {
|
||||||
const {
|
const {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
@@ -46,7 +46,7 @@ const Grid = memo(({gap, color, size, style, className, gridStyle}) => {
|
|||||||
|
|
||||||
const xOffset = x % scaledGap;
|
const xOffset = x % scaledGap;
|
||||||
const yOffset = y % scaledGap;
|
const yOffset = y % scaledGap;
|
||||||
const isLines = gridStyle === 'lines';
|
const isLines = backgroundType === 'lines';
|
||||||
const path = isLines
|
const path = isLines
|
||||||
? createGridLines(width, height, xOffset, yOffset, scaledGap)
|
? createGridLines(width, height, xOffset, yOffset, scaledGap)
|
||||||
: createGridDots(width, height, xOffset, yOffset, scaledGap, size);
|
: createGridDots(width, height, xOffset, yOffset, scaledGap, size);
|
||||||
@@ -69,16 +69,16 @@ Grid.propTypes = {
|
|||||||
size: PropTypes.number,
|
size: PropTypes.number,
|
||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
gridStyle: PropTypes.oneOf(['lines', 'dots']),
|
backgroundType: PropTypes.oneOf(['lines', 'dots']),
|
||||||
};
|
};
|
||||||
|
|
||||||
Grid.defaultProps = {
|
Grid.defaultProps = {
|
||||||
gap: 24,
|
gap: 24,
|
||||||
color: '#999',
|
color: '#aaa',
|
||||||
size: .5,
|
size: .5,
|
||||||
style: {},
|
style: {},
|
||||||
className: null,
|
className: null,
|
||||||
gridStyle: 'dots',
|
backgroundType: 'dots',
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Grid;
|
export default Grid;
|
||||||
|
|||||||
@@ -12,7 +12,13 @@ const BackgroundRenderer = memo(({
|
|||||||
backgroundType, ...rest
|
backgroundType, ...rest
|
||||||
}) => {
|
}) => {
|
||||||
const BackgroundComponent = bgComponents[backgroundType];
|
const BackgroundComponent = bgComponents[backgroundType];
|
||||||
return <BackgroundComponent {...rest} />
|
|
||||||
|
return (
|
||||||
|
<BackgroundComponent
|
||||||
|
backgroundType={backgroundType}
|
||||||
|
{...rest}
|
||||||
|
/>
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
BackgroundRenderer.displayName = 'BackgroundRenderer';
|
BackgroundRenderer.displayName = 'BackgroundRenderer';
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ ReactFlow.defaultProps = {
|
|||||||
connectionLineStyle: {},
|
connectionLineStyle: {},
|
||||||
deleteKeyCode: 8,
|
deleteKeyCode: 8,
|
||||||
selectionKeyCode: 16,
|
selectionKeyCode: 16,
|
||||||
backgroundColor: '#999',
|
backgroundColor: '#eee',
|
||||||
backgroundGap: 24,
|
backgroundGap: 24,
|
||||||
showBackground: true,
|
showBackground: true,
|
||||||
backgroundType: 'dots'
|
backgroundType: 'dots'
|
||||||
|
|||||||
Reference in New Issue
Block a user