Download react-testing-library/src/__tests__/config.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.84 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/config.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/config.js
-
curl -L -o config.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-testing-library/src/__tests__/config.js
1.84 kB
| 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) | |
| }) | |
| }) | |