<commit_before>import { cit, create, provide, stubPipe, cms } from '../../../testing';
import { SeriesFeedsComponent } from './series-feeds.component';
import { SeriesModel, FeederFeedModel } from 'app/shared';
import { TabService } from 'ngx-prx-styleguide';

describe('SeriesFeedsComponent', () => {
  create(SeriesFeedsComponent);

  provide(TabService);

  cit('shows an error message if you have no podcast distribution', (fix, el, comp) => {
    const podcastUrl = 'http://some.where/your/podcast/1234';
    const series = cms().mock('prx:series', {});

    comp.load(new SeriesModel(null, series, false));
    fix.detectChanges();

    expect(el).toContainText('No feeds found');
  });

  cit('displays feeds', (fix, el, comp) => {
    const podcastUrl = 'http://some.where/your/podcast/1234';
    const series = cms().mock('prx:series', {});
    const [dist] = series.mockItems('prx:distributions', [{ kind: 'podcast', url: podcastUrl }]);
    const podcast = dist.mock(podcastUrl, { title: 'pod1' });
    podcast.mockItems('prx:feeds', [
      { id: 1, slug: '', fileName: 'default.xml' },
      { id: 2, title: 'Some Private Feed', slug: 'private', fileName: 'private.xml' },
      { id: 3, title: 'Some Public Feed', slug: 'public', fileName: 'public.xml' }
    ]);

    comp.load(new SeriesModel(null, series, false));
    fix.detectChanges();

    expect(el).toContainText('Default Feed');
    expect(el).toContainText('Some Private Feed');
    expect(el).toContainText('Some Public Feed');
  });

  cit('confirms urls changing', (fix, el, comp) => {
    const doc = cms().mock('prx:feed', { id: 1234, url: 'original-url' });
    const feed = new FeederFeedModel(null, doc);

    feed.set('url', 'updated-url');
    expect(comp.urlConfirm(feed)).toMatch(/are you sure you want to change/i);

    // pretend the original was blank
    feed.set('url', '', true);
    feed.set('url', 'updated-url');
    expect(comp.urlConfirm(feed)).toBeFalsy();
  });

  cit('confirms new-feed-urls changing', (fix, el, comp) => {
    const doc = cms().mock('prx:feed', { id: 1234, url: 'original-url', newFeedUrl: 'original-url' });
    const feed = new FeederFeedModel(null, doc);

    feed.set('newFeedUrl', 'updated-url');
    expect(comp.urlConfirm(feed)).toMatch(/are you sure you want to change/i);

    // also shows up if new feed url _was_ blank
    feed.set('newFeedUrl', '', true);
    feed.set('newFeedUrl', 'updated-url');
    expect(comp.urlConfirm(feed)).toMatch(/are you sure you want to change/i);
  });
});
<commit_msg>Unused var<commit_after>import { cit, create, provide, stubPipe, cms } from '../../../testing';
import { SeriesFeedsComponent } from './series-feeds.component';
import { SeriesModel, FeederFeedModel } from 'app/shared';
import { TabService } from 'ngx-prx-styleguide';

describe('SeriesFeedsComponent', () => {
  create(SeriesFeedsComponent);

  provide(TabService);

  cit('shows an error message if you have no podcast distribution', (fix, el, comp) => {
    const series = cms().mock('prx:series', { id: 'some-id' });

    comp.load(new SeriesModel(null, series, false));
    fix.detectChanges();

    expect(el).toContainText('No feeds found');
  });

  cit('displays feeds', (fix, el, comp) => {
    const podcastUrl = 'http://some.where/your/podcast/1234';
    const series = cms().mock('prx:series', {});
    const [dist] = series.mockItems('prx:distributions', [{ kind: 'podcast', url: podcastUrl }]);
    const podcast = dist.mock(podcastUrl, { title: 'pod1' });
    podcast.mockItems('prx:feeds', [
      { id: 1, slug: '', fileName: 'default.xml' },
      { id: 2, title: 'Some Private Feed', slug: 'private', fileName: 'private.xml' },
      { id: 3, title: 'Some Public Feed', slug: 'public', fileName: 'public.xml' }
    ]);

    comp.load(new SeriesModel(null, series, false));
    fix.detectChanges();

    expect(el).toContainText('Default Feed');
    expect(el).toContainText('Some Private Feed');
    expect(el).toContainText('Some Public Feed');
  });

  cit('confirms urls changing', (fix, el, comp) => {
    const doc = cms().mock('prx:feed', { id: 1234, url: 'original-url' });
    const feed = new FeederFeedModel(null, doc);

    feed.set('url', 'updated-url');
    expect(comp.urlConfirm(feed)).toMatch(/are you sure you want to change/i);

    // pretend the original was blank
    feed.set('url', '', true);
    feed.set('url', 'updated-url');
    expect(comp.urlConfirm(feed)).toBeFalsy();
  });

  cit('confirms new-feed-urls changing', (fix, el, comp) => {
    const doc = cms().mock('prx:feed', { id: 1234, url: 'original-url', newFeedUrl: 'original-url' });
    const feed = new FeederFeedModel(null, doc);

    feed.set('newFeedUrl', 'updated-url');
    expect(comp.urlConfirm(feed)).toMatch(/are you sure you want to change/i);

    // also shows up if new feed url _was_ blank
    feed.set('newFeedUrl', '', true);
    feed.set('newFeedUrl', 'updated-url');
    expect(comp.urlConfirm(feed)).toMatch(/are you sure you want to change/i);
  });
});

{'fraction_non_alphanumeric': 0.18600478468899523, 'fraction_numerical': 0.007177033492822967, 'mean_word_length': 3.9090019569471623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '6885847', 'n_tokens_mistral': 1687, 'n_tokens_neox': 1629, 'n_words': 398}