import React from 'react';
import { render, cleanup, fireEvent, screen, waitFor, shallow } from '@testing-library/react';
import { translate } from 'gatsby-core-theme/src/helpers/getters';
import * as Strings from './strings';

describe('Strings Helper', () => {
  test('capitalize()', () => {
    expect(Strings.capitalize('hello')).toEqual('Hello');
    expect(Strings.capitalize('hello world')).toEqual('Hello world');
  });

  test('anchorLink()', () => {
    expect(Strings.anchorLink('HEllo')).toEqual('hello');
    expect(Strings.anchorLink('HeLlo WorlD')).toEqual('hello-world');
  });

  // test('getLinkListFromPath()', () => {
  //   const pathLink = [
  //     {
  //       label: 'Sport',
  //       path: '/sport',
  //     },
  //   ];
  //   expect(Strings.getLinkListFromPath('/')).toEqual([]);
  //   expect(Strings.getLinkListFromPath('sport/brand')).toEqual(expect.arrayContaining(pathLink));
  // });
  test('leftTrim()', () => {
    expect(Strings.leftTrim(' hello   world')).toEqual('hello world');
  });

  test('truncateString()', () => {
    expect(Strings.truncateString('hello i think', 5)).toEqual('hello...');
    expect(Strings.truncateString('hello i think', 10)).toEqual('hello i...');
  });

  test('cleanHTML()', () => {
    expect(Strings.cleanHTML('<p>hello <a>i</a> think</p>')).toEqual('hello i think');
  });

  test('parseContentImageUrl()', () => {
    expect(
      Strings.parseContentImageUrl(
        'https://assets-srv.s3.eu-west-1.amazonaws.com/irishluck-jackpot.jpeg'
      )
    ).toEqual('https://cdn.images.com/irishluck-jackpot.jpeg');
  });
});
