mirror of
https://github.com/nimbold/Firelink.git
synced 2026-08-09 02:40:21 +00:00
25 lines
1.2 KiB
TypeScript
25 lines
1.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import {
|
|
PROPERTIES_URL_PREVIEW_MAX_LENGTH,
|
|
shouldOfferPropertiesUrlExpansion,
|
|
shouldResetPropertiesUrlExpansion,
|
|
} from './propertiesUrl';
|
|
|
|
describe('Properties URL disclosure', () => {
|
|
it('offers expansion only for URLs longer than the preview budget', () => {
|
|
expect(shouldOfferPropertiesUrlExpansion('x'.repeat(PROPERTIES_URL_PREVIEW_MAX_LENGTH))).toBe(false);
|
|
expect(shouldOfferPropertiesUrlExpansion('x'.repeat(PROPERTIES_URL_PREVIEW_MAX_LENGTH + 1))).toBe(true);
|
|
});
|
|
|
|
it('resets expansion when the displayed download changes', () => {
|
|
expect(shouldResetPropertiesUrlExpansion('download-1', 'download-1')).toBe(false);
|
|
expect(shouldResetPropertiesUrlExpansion('download-1', 'download-2')).toBe(true);
|
|
expect(shouldResetPropertiesUrlExpansion(null, 'download-1')).toBe(true);
|
|
});
|
|
|
|
it('resets expansion when the displayed address changes', () => {
|
|
expect(shouldResetPropertiesUrlExpansion('download-1', 'download-1', 'magnet:?xt=old', 'magnet:?xt=old')).toBe(false);
|
|
expect(shouldResetPropertiesUrlExpansion('download-1', 'download-1', 'magnet:?xt=old', 'magnet:?xt=new')).toBe(true);
|
|
});
|
|
});
|