import { previewFormat, previewPath, formatPath } from './path';

describe('Path format component', () => {
  test('path format adding /', () => {
    const path = formatPath('test/link');
    expect(typeof path).toEqual('string');

    expect(path).toBe('/test/link');
  });

  test('path format keep initial /', () => {
    const path = formatPath('/test/link');
    expect(typeof path).toEqual('string');

    expect(path).toBe('/test/link');
  });

  test('preview mode path format removes initial /', () => {
    const path = previewFormat('/test/link');
    expect(typeof path).toEqual('string');

    expect(path).toBe('test/link');
  });

  test('preview mode path navigation removes initial / on path param', () => {
    const path = previewPath('/test/link');
    expect(typeof path).toEqual('string');

    expect(path).toBe('/preview?path=test/link&market_id=null');
  });

  test('preview mode path navigation keep no initial / on path param', () => {
    const path = previewPath('test/link');

    expect(typeof path).toEqual('string');
    expect(path).toBe('/preview?path=test/link&market_id=null');
  });
});
