-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add
reactStrictMode
option to enable strict mode render (#1241)
* feat: add `reactStrictMode` option and override `getConfig` and `configure` functions from DTL * feat: update types for overridden `getConfig` and `configure` functions * test: add tests for checking configure APIs support RTL option and do not degrade * refactor: use a wrapper option for simplicity * refactor: use same function for wrapping UI if needed * feat: enable strict mode render if `reactStrictMode` option is true * test: add tests for checking strict mode works and can be combine with wrapper --------- Co-authored-by: Sebastian Silbermann <[email protected]>
- Loading branch information
Showing
8 changed files
with
443 additions
and
174 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {configure, getConfig} from '../' | ||
|
||
describe('configuration API', () => { | ||
let originalConfig | ||
beforeEach(() => { | ||
// Grab the existing configuration so we can restore | ||
// it at the end of the test | ||
configure(existingConfig => { | ||
originalConfig = existingConfig | ||
// Don't change the existing config | ||
return {} | ||
}) | ||
}) | ||
|
||
afterEach(() => { | ||
configure(originalConfig) | ||
}) | ||
|
||
describe('DTL options', () => { | ||
test('configure can set by a plain JS object', () => { | ||
const testIdAttribute = 'not-data-testid' | ||
configure({testIdAttribute}) | ||
|
||
expect(getConfig().testIdAttribute).toBe(testIdAttribute) | ||
}) | ||
|
||
test('configure can set by a function', () => { | ||
// setup base option | ||
const baseTestIdAttribute = 'data-testid' | ||
configure({testIdAttribute: baseTestIdAttribute}) | ||
|
||
const modifiedPrefix = 'modified-' | ||
configure(existingConfig => ({ | ||
testIdAttribute: `${modifiedPrefix}${existingConfig.testIdAttribute}`, | ||
})) | ||
|
||
expect(getConfig().testIdAttribute).toBe( | ||
`${modifiedPrefix}${baseTestIdAttribute}`, | ||
) | ||
}) | ||
}) | ||
|
||
describe('RTL options', () => { | ||
test('configure can set by a plain JS object', () => { | ||
configure({reactStrictMode: true}) | ||
|
||
expect(getConfig().reactStrictMode).toBe(true) | ||
}) | ||
|
||
test('configure can set by a function', () => { | ||
configure(existingConfig => ({ | ||
reactStrictMode: !existingConfig.reactStrictMode, | ||
})) | ||
|
||
expect(getConfig().reactStrictMode).toBe(true) | ||
}) | ||
}) | ||
|
||
test('configure can set DTL and RTL options at once', () => { | ||
const testIdAttribute = 'not-data-testid' | ||
configure({testIdAttribute, reactStrictMode: true}) | ||
|
||
expect(getConfig().testIdAttribute).toBe(testIdAttribute) | ||
expect(getConfig().reactStrictMode).toBe(true) | ||
}) | ||
}) |
Oops, something went wrong.