diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-05 00:09:14 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-05-05 00:09:14 +0300 |
commit | ceb5cdd5c3293d290c1ae42a86175ac4f51b4408 (patch) | |
tree | 340743b21d708a6c06c5d402c0b697d8b89d9b06 /spec/frontend/lib | |
parent | bd979acf95124119d41f75d34cab231229f4dd81 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/lib')
-rw-r--r-- | spec/frontend/lib/utils/css_utils_spec.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/css_utils_spec.js b/spec/frontend/lib/utils/css_utils_spec.js new file mode 100644 index 00000000000..dcaeb075c93 --- /dev/null +++ b/spec/frontend/lib/utils/css_utils_spec.js @@ -0,0 +1,22 @@ +import { getCssClassDimensions } from '~/lib/utils/css_utils'; + +describe('getCssClassDimensions', () => { + const mockDimensions = { width: 1, height: 2 }; + let actual; + + beforeEach(() => { + jest.spyOn(Element.prototype, 'getBoundingClientRect').mockReturnValue(mockDimensions); + actual = getCssClassDimensions('foo bar'); + }); + + it('returns the measured width and height', () => { + expect(actual).toEqual(mockDimensions); + }); + + it('measures an element with the given classes', () => { + expect(Element.prototype.getBoundingClientRect).toHaveBeenCalledTimes(1); + + const [tempElement] = Element.prototype.getBoundingClientRect.mock.contexts; + expect([...tempElement.classList]).toEqual(['foo', 'bar']); + }); +}); |