<commit_before>/* global describe, expect, mount, shallow, test */

import React from 'react';

import Thumb from '../components/thumb';

describe('View Album - Thumb (React Component)', () => {
  const item = {
    mediaPath: 'c',
    thumbCaption: 'a',
    thumbPath: 'b',
  };

  test('* Thumbnail image and caption', () => {
    const wrapper = shallow(<Thumb item={item} />);

    expect(wrapper.contains(
      <img src={item.thumbPath} alt={item.thumbCaption} title={item.caption} />,
    )).toBeTruthy();

    expect(wrapper.contains(
      <div className="albumBoxPhotoCaption">
        {item.thumbCaption}
      </div>,
    )).toBeTruthy();
  });

  test('* Thumbnail missing geocode', () => {
    const wrapper = mount(<Thumb item={item} />);
    const liProps = wrapper.find('li').props();

    expect(liProps['data-lon']).toBeFalsy();
    expect(liProps['data-lat']).toBeFalsy();
  });

  test('* Thumbnail has geocode', () => {
    item.geo = {
      lat: 1,
      lon: 0,
    };
    const wrapper = mount(<Thumb item={item} />);
    const liProps = wrapper.find('li').props();
    expect(liProps['data-lon']).toEqual(0);
    expect(liProps['data-lat']).toEqual(1);

    delete item.geo;
  });

  test('* Title - Photo City', () => {
    item.photoCity = 'Vancouver, BC';
    const wrapper = mount(<Thumb item={item} />);
    const { title } = wrapper.find('a').props();

    expect(title).toEqual(item.photoCity);

    delete item.photoCity;
  });

  test('* Reference - Wikipedia', () => {
    item.ref = {
      name: 'Vancouver_International_Airport',
      source: 'wikipedia',
    };
    const wrapper = mount(<Thumb item={item} />);
    const { title } = wrapper.find('a').props();
    const titleHtml = '<a href=\'https://en.wikipedia.org/wiki/Vancouver_International_Airport\' target=\'_blank\'>Wiki</a>';

    expect(title).toEqual(titleHtml);

    delete item.ref;
  });

  test('* Reference - YouTube', () => {
    item.ref = {
      name: 'YeeCunkIaco',
      source: 'youtube',
    };
    const wrapper = mount(<Thumb item={item} />);
    const { title } = wrapper.find('a').props();
    const titleHtml = '<a href=\'https://www.youtube.com/watch?v=YeeCunkIaco\' target=\'_blank\'>YouTube</a>';

    expect(title).toEqual(titleHtml);

    delete item.ref;
  });
});<commit_msg>test(Admin): Use jest beforeEach to make each test isolated<commit_after>/* global beforeEach, describe, expect, mount, shallow, test */

import React from 'react';

import Thumb from '../components/thumb';

describe('View Album - Thumb (React Component)', () => {
  let item = {};

  beforeEach(() => {
    item = {
      mediaPath: 'c',
      thumbCaption: 'a',
      thumbPath: 'b',
    };
  });

  test('* Thumbnail image and caption', () => {
    const wrapper = shallow(<Thumb item={item} />);

    expect(wrapper.contains(
      <img src={item.thumbPath} alt={item.thumbCaption} title={item.caption} />,
    )).toBeTruthy();

    expect(wrapper.contains(
      <div className="albumBoxPhotoCaption">
        {item.thumbCaption}
      </div>,
    )).toBeTruthy();
  });

  test('* Thumbnail missing geocode', () => {
    const wrapper = mount(<Thumb item={item} />);
    const liProps = wrapper.find('li').props();

    expect(liProps['data-lon']).toBeFalsy();
    expect(liProps['data-lat']).toBeFalsy();
  });

  test('* Thumbnail has geocode', () => {
    item.geo = {
      lat: 1,
      lon: 0,
    };

    const wrapper = mount(<Thumb item={item} />);
    const liProps = wrapper.find('li').props();
    expect(liProps['data-lon']).toEqual(0);
    expect(liProps['data-lat']).toEqual(1);
  });

  test('* Title - Photo City', () => {
    item.photoCity = 'Vancouver, BC';
    const wrapper = mount(<Thumb item={item} />);
    const { title } = wrapper.find('a').props();

    expect(title).toEqual(item.photoCity);
  });

  test('* Reference - Wikipedia', () => {
    item.ref = {
      name: 'Vancouver_International_Airport',
      source: 'wikipedia',
    };

    const wrapper = mount(<Thumb item={item} />);
    const { title } = wrapper.find('a').props();
    const titleHtml = '<a href=\'https://en.wikipedia.org/wiki/Vancouver_International_Airport\' target=\'_blank\'>Wiki</a>';

    expect(title).toEqual(titleHtml);
  });

  test('* Reference - YouTube', () => {
    item.ref = {
      name: 'YeeCunkIaco',
      source: 'youtube',
    };

    const wrapper = mount(<Thumb item={item} />);
    const { title } = wrapper.find('a').props();
    const titleHtml = '<a href=\'https://www.youtube.com/watch?v=YeeCunkIaco\' target=\'_blank\'>YouTube</a>';

    expect(title).toEqual(titleHtml);
  });
});
{'fraction_non_alphanumeric': 0.2008214440121055, 'fraction_numerical': 0.0017293558149589277, 'mean_word_length': 3.157232704402516, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 44, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1355405', 'n_tokens_mistral': 1554, 'n_tokens_neox': 1505, 'n_words': 293}