mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-08 12:23:54 -05:00
Add test for controlling height between states
The button shouldn't change its vertical position when the state changes. The text confirming the copy is just one line so setting height for both based on the API key, which can run to 2 lines makes sense. Explained in this PR: https://github.com/alphagov/notifications-admin/pull/2428
This commit is contained in:
@@ -54,6 +54,8 @@ describe('API key', () => {
|
||||
|
||||
describe("If copy command is available", () => {
|
||||
|
||||
let componentHeightOnLoad;
|
||||
|
||||
beforeAll(() => {
|
||||
|
||||
// assume copy command is available
|
||||
@@ -79,6 +81,10 @@ describe('API key', () => {
|
||||
|
||||
component = document.querySelector('[data-module=api-key]');
|
||||
|
||||
// mock DOM API called for element height
|
||||
componentHeightOnLoad = 50;
|
||||
jest.spyOn(component, 'offsetHeight', 'get').mockImplementation(() => componentHeightOnLoad);
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
@@ -111,6 +117,13 @@ describe('API key', () => {
|
||||
|
||||
});
|
||||
|
||||
test("It should set the component's minimum height based on its height when the page loads", () => {
|
||||
|
||||
// to prevent the position of the button moving when the state changes
|
||||
expect(window.getComputedStyle(component)['min-height']).toEqual(`${componentHeightOnLoad}px`);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("If you click the 'Copy API key to clipboard' button", () => {
|
||||
|
||||
Reference in New Issue
Block a user