import { describe, it, expect } from 'vitest';
import { buildAppShareDisplayUrl } from './appShareUrl';

// shareUrl は相対パス（/ui/app/:token）。表示時に origin を前置するだけの純関数。
describe('buildAppShareDisplayUrl', () => {
  it('prefixes the origin to a relative shareUrl', () => {
    expect(buildAppShareDisplayUrl('https://app.example.com', '/ui/app/abc')).toBe(
      'https://app.example.com/ui/app/abc',
    );
  });

  it('does not double a trailing slash on the origin', () => {
    expect(buildAppShareDisplayUrl('https://app.example.com/', '/ui/app/abc')).toBe(
      'https://app.example.com/ui/app/abc',
    );
  });

  it('passes absolute shareUrls through unchanged', () => {
    expect(buildAppShareDisplayUrl('https://app.example.com', 'https://other/x')).toBe(
      'https://other/x',
    );
  });
});
