-
-
Notifications
You must be signed in to change notification settings - Fork 847
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add some for backgroundlayer (#591)
* add tests for Backgroundlayer * linting
- Loading branch information
Showing
8 changed files
with
100 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
import {render} from 'react-native-testing-library'; | ||
|
||
import BackgroundLayer from '../../javascript/components/BackgroundLayer'; | ||
|
||
export const NATIVE_MODULE_NAME = 'RCTMGLBackgroundLayer'; | ||
|
||
describe('BackgroundLayer', () => { | ||
test('renders correctly with default props', () => { | ||
const {queryByTestId} = render(<BackgroundLayer />); | ||
|
||
const backgroundLayer = queryByTestId('rctmglBackgroundLayer'); | ||
const {props} = backgroundLayer; | ||
|
||
expect(props.sourceID).toStrictEqual('DefaultSourceID'); | ||
}); | ||
|
||
test('renders correctly with custom props', () => { | ||
const testProps = { | ||
id: 'customId', | ||
sourceID: 'customSourceId', | ||
sourceLayerID: 'customSourceLayerId', | ||
aboveLayerID: 'customAboveLayerId', | ||
belowLayerID: 'customBelowLayerId', | ||
layerIndex: 0, | ||
filter: ['==', 'arbitraryFilter', true], | ||
minZoomLevel: 3, | ||
maxZoomLevel: 8, | ||
style: {visibility: 'none'}, | ||
}; | ||
|
||
const {queryByTestId} = render(<BackgroundLayer {...testProps} />); | ||
const backgroundLayer = queryByTestId('rctmglBackgroundLayer'); | ||
const {props} = backgroundLayer; | ||
|
||
expect(props.id).toStrictEqual(testProps.id); | ||
expect(props.sourceID).toStrictEqual(testProps.sourceID); | ||
expect(props.sourceLayerID).toStrictEqual(testProps.sourceLayerID); | ||
expect(props.aboveLayerID).toStrictEqual(testProps.aboveLayerID); | ||
expect(props.belowLayerID).toStrictEqual(testProps.belowLayerID); | ||
expect(props.layerIndex).toStrictEqual(testProps.layerIndex); | ||
expect(props.filter).toStrictEqual(testProps.filter); | ||
expect(props.minZoomLevel).toStrictEqual(testProps.minZoomLevel); | ||
expect(props.maxZoomLevel).toStrictEqual(testProps.maxZoomLevel); | ||
expect(props.reactStyle).toStrictEqual({ | ||
visibility: { | ||
styletype: 'constant', | ||
stylevalue: {type: 'string', value: testProps.style.visibility}, | ||
}, | ||
}); | ||
}); | ||
}); |
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
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