Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unused mask extension property #309

Merged
merged 2 commits into from
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Not released

Remove maskEnabled property and control the mask extension activation by maskId [#309](https://github.com/CartoDB/carto-react/pull/309)

## 1.2

### 1.2.1-beta.0 (2022-02-01)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import { getMaskExtensionProps } from '../../src/hooks/maskExtensionUtil';
describe('mask-extension-util', () => {
test('correct values without maskPolygon', () => {
const myMaskPolygon = undefined;
const { maskId, maskEnabled, extensions } = getMaskExtensionProps(myMaskPolygon);
const { maskId, extensions } = getMaskExtensionProps(myMaskPolygon);

expect(maskId).toEqual(MASK_ID);
expect(maskEnabled).toEqual(false);
expect(maskId).toEqual(false);
expect(extensions[0]).toBeInstanceOf(MaskExtension);
});

Expand All @@ -20,10 +19,9 @@ describe('mask-extension-util', () => {
[-41.484375, 53.330872983017066],
[-41.484375, 35.17380831799959]
];
const { maskId, maskEnabled, extensions } = getMaskExtensionProps(myMaskPolygon);
const { maskId, extensions } = getMaskExtensionProps(myMaskPolygon);

expect(maskId).toEqual(MASK_ID);
expect(maskEnabled).toEqual(true);
expect(extensions[0]).toBeInstanceOf(MaskExtension);
});
});
13 changes: 3 additions & 10 deletions packages/react-api/__tests__/hooks/useCartoLayerProps.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DataFilterExtension, MaskExtension } from '@deck.gl/extensions';
import { MAP_TYPES, API_VERSIONS } from '@deck.gl/carto';
import { MASK_ID } from '@carto/react-core/';
import { renderHook } from '@testing-library/react-hooks';
import useCartoLayerProps from '../../src/hooks/useCartoLayerProps';
import { mockReduxHooks, mockClear } from '../mockReduxHooks';
Expand All @@ -21,8 +20,7 @@ describe('useCartoLayerProps', () => {
'updateTriggers',
'getFilterValue',
'extensions',
'maskId',
'maskEnabled'
'maskId'
];

describe('when maps_api_version is V2', () => {
Expand Down Expand Up @@ -211,15 +209,10 @@ describe('useCartoLayerProps', () => {
expect(result.current.updateTriggers).toHaveProperty('getFilterValue');
});

test('maskEnabled should be present and be false by default', () => {
const { result } = renderHook(() => useCartoLayerProps({}));
expect(result.current.maskEnabled).toEqual(false);
});

test('maskId should be present and should have the correct value', () => {
test('maskId should be present should be present and be false by default', () => {
const { result } = renderHook(() => useCartoLayerProps({}));

expect(result.current.maskId).toEqual(MASK_ID);
expect(result.current.maskId).toEqual(false);
});
});

Expand Down
3 changes: 1 addition & 2 deletions packages/react-api/src/hooks/maskExtensionUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ const maskExtension = new MaskExtension();

export function getMaskExtensionProps(maskPolygon) {
return {
maskId: MASK_ID,
maskEnabled: Boolean(maskPolygon && maskPolygon.length),
maskId: Boolean(maskPolygon && maskPolygon.length) && MASK_ID,
extensions: [maskExtension]
};
}