-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: migrate to IMA Testing Library
- Loading branch information
1 parent
47c529a
commit 0cdfe97
Showing
14 changed files
with
312 additions
and
447 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 |
---|---|---|
|
@@ -9,4 +9,5 @@ | |
.eslintcache | ||
*.tgz | ||
**/.turbo | ||
.swc/ | ||
!itl.tgz |
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,20 @@ | ||
const { | ||
setImaTestingLibraryServerConfig, | ||
FALLBACK_APP_MAIN_PATH, | ||
FALLBACK_APPLICATION_FOLDER, | ||
} = require('@ima/testing-library/server'); | ||
|
||
const base = require('./jest.config.base.js'); | ||
|
||
setImaTestingLibraryServerConfig({ | ||
applicationFolder: FALLBACK_APPLICATION_FOLDER, | ||
}); | ||
|
||
module.exports = { | ||
...base, | ||
preset: '@ima/testing-library', | ||
moduleNameMapper: { | ||
'app/main': FALLBACK_APP_MAIN_PATH, | ||
}, | ||
setupFiles: ['<rootDir>/../../jestSetup.itl.js'], | ||
}; |
File renamed without changes.
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 |
---|---|---|
@@ -1,20 +1,5 @@ | ||
const { | ||
setImaTestingLibraryServerConfig, | ||
FALLBACK_APP_MAIN_PATH, | ||
FALLBACK_APPLICATION_FOLDER, | ||
} = require('@ima/testing-library/server'); | ||
|
||
const base = require('../../jest.config.base.js'); | ||
|
||
setImaTestingLibraryServerConfig({ | ||
applicationFolder: FALLBACK_APPLICATION_FOLDER, | ||
}); | ||
const itl = require('../../jest.config.itl.js'); | ||
|
||
module.exports = { | ||
...base, | ||
preset: '@ima/testing-library', | ||
moduleNameMapper: { | ||
'app/main': FALLBACK_APP_MAIN_PATH, | ||
}, | ||
setupFiles: ['./jestSetup.js'], | ||
...itl, | ||
}; |
5 changes: 0 additions & 5 deletions
5
packages/plugin-atoms/src/__tests__/__snapshots__/mountSpec.js.snap
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
packages/plugin-atoms/src/components/__tests__/IframeSpec.jsx
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,38 @@ | ||
import { renderWithContext, waitFor } from '@ima/testing-library'; | ||
|
||
import { Iframe, Visibility } from '../../main'; | ||
|
||
describe('Iframe', () => { | ||
it('should render with noscript tag by default', async () => { | ||
const { container } = await renderWithContext( | ||
<Iframe src='example.html' /> | ||
); | ||
|
||
expect(container.querySelector('noscript')).toBeInTheDocument(); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
|
||
it('should render without noscript tag if visible', async () => { | ||
const { app, container } = await renderWithContext( | ||
<Iframe src='example.html' /> | ||
); | ||
|
||
// Mock getBoundingClientRect to simulate visibility | ||
container.firstChild.getBoundingClientRect = jest.fn(() => ({ | ||
width: 100, | ||
height: 100, | ||
top: 0, | ||
left: 0, | ||
bottom: 100, | ||
right: 100, | ||
})); | ||
app.oc.get(Visibility).notify(); // Trigger visibility observer | ||
|
||
// The component needs to re-render to remove noscript tag, there is no generic way to wait for it, | ||
// so we need to wait for the noscript tag to disappear | ||
await waitFor(() => | ||
expect(container.querySelector('noscript')).not.toBeInTheDocument() | ||
); | ||
expect(container.firstChild).toMatchSnapshot(); | ||
}); | ||
}); |
25 changes: 25 additions & 0 deletions
25
packages/plugin-atoms/src/components/__tests__/__snapshots__/IframeSpec.jsx.snap
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,25 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Iframe should render with noscript tag by default 1`] = ` | ||
<div | ||
class="atm-iframe atm-overflow atm-placeholder" | ||
style="width: auto; height: auto;" | ||
> | ||
<noscript> | ||
<iframe src="example.html" name="example.html" width="auto" height="auto" class="atm-fill" ></iframe> | ||
</noscript> | ||
</div> | ||
`; | ||
|
||
exports[`Iframe should render without noscript tag if visible 1`] = ` | ||
<div | ||
class="atm-iframe atm-overflow" | ||
style="width: auto; height: auto;" | ||
> | ||
<iframe | ||
class="atm-fill" | ||
name="example.html" | ||
src="example.html" | ||
/> | ||
</div> | ||
`; |
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 |
---|---|---|
@@ -1,10 +1,5 @@ | ||
const base = require('../../jest.config.base.js'); | ||
const itl = require('../../jest.config.itl.js'); | ||
|
||
module.exports = { | ||
...base, | ||
testEnvironment: 'jsdom', | ||
setupFiles: ['<rootDir>/jestSetupFile.js'], | ||
snapshotSerializers: [ | ||
'<rootDir>/../../node_modules/enzyme-to-json/serializer', | ||
], | ||
...itl, | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.