mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2026-03-25 21:43:03 -04:00
This is a followup to !10524. In addition I changed that the tooltip triggers for the whole height, instead for only the bar height, because otherwise it is esp for small bars nearly impossible to get the tooltip to open. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/10556 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Beowulf <beowulf@beocode.eu> Co-committed-by: Beowulf <beowulf@beocode.eu>
28 lines
1,020 B
JavaScript
28 lines
1,020 B
JavaScript
// Copyright 2025 The Forgejo Authors. All rights reserved.
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
import {flushPromises, mount} from '@vue/test-utils';
|
|
import RepoActivityTopAuthors from './RepoActivityTopAuthors.vue';
|
|
import {expect, test, vi} from 'vitest';
|
|
|
|
test('calc image size and shift', async () => {
|
|
vi.spyOn(RepoActivityTopAuthors.methods, 'init').mockResolvedValue({});
|
|
|
|
const repoActivityTopAuthors = mount(RepoActivityTopAuthors, {
|
|
props: {
|
|
locale: {
|
|
commitActivity: '',
|
|
},
|
|
},
|
|
});
|
|
await flushPromises();
|
|
|
|
const square = repoActivityTopAuthors.vm.calcImageSizeAndShift({naturalWidth: 50, naturalHeight: 50});
|
|
expect(square).toEqual([20, 20, 0, 0]);
|
|
|
|
const portrait = repoActivityTopAuthors.vm.calcImageSizeAndShift({naturalWidth: 5, naturalHeight: 50});
|
|
expect(portrait).toEqual([2, 20, 9, 0]);
|
|
|
|
const landscape = repoActivityTopAuthors.vm.calcImageSizeAndShift({naturalWidth: 500, naturalHeight: 5});
|
|
expect(landscape).toEqual([20, 0.2, 0, 9.9]);
|
|
});
|