<commit_before>import {
  inject,
  ComponentFixture,
  TestBed
} from '@angular/core/testing';
import {expect} from 'chai';
import {CloudinaryImageComponent} from '../src/cloudinary-image.component';
import {CloudinaryOptions} from '../src/cloudinary-options.class';
import {Ng2CloudinaryModule} from '../src';

describe('CloudinaryImage component', () => {

  beforeEach(() => {
    TestBed.configureTestingModule({imports: [Ng2CloudinaryModule]});
  });

  // it('should throw an error if CloudinaryOptions are not provided', () => {
  //   const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
  //   expect(fixture.detectChanges()).to.throw(Error, /CloudinaryOptions are required/);
  // });

  it('should create img DOM element', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    fixture.detectChanges();
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src=""');
  });

  it('should create img DOM element without publicId', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.publicId = null;
    fixture.detectChanges();

    let expectedImageUrl: string = '';
    expect(clImageComponent.imageUrl).to.equal(expectedImageUrl);
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src="' + expectedImageUrl + '"');
  });

  it('should create img DOM element with publicId', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.publicId = 'testPublicId';
    clImageComponent.ngOnChanges(null);
    fixture.detectChanges();

    let expectedImageUrl: string = 'https://res.cloudinary.com/ekito/image/upload/testPublicId.jpg';
    expect(clImageComponent.imageUrl).to.equal(expectedImageUrl);
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src="' + expectedImageUrl + '"');
  });

  it('should create img DOM element with transformations', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.height = 100;
    clImageComponent.width = 150;
    clImageComponent.publicId = 'testPublicId';
    clImageComponent.ngOnChanges(null);
    fixture.detectChanges();

    let expectedImageUrl: string = 'https://res.cloudinary.com/ekito/image/upload/h_100,w_150/testPublicId.jpg';
    expect(clImageComponent.imageUrl).to.equal(expectedImageUrl);
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src="' + expectedImageUrl + '"');
  });

  it('should create img DOM element with title and alt', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.publicId = 'testPublicId';
    clImageComponent.title = 'testTitle';
    clImageComponent.alt = 'testAlt';
    clImageComponent.ngOnChanges(null);
    fixture.detectChanges();

    let expectedImageUrl: string = 'https://res.cloudinary.com/ekito/image/upload/testPublicId.jpg';<commit_msg>Updated tests - as .jpg NOT expected, if no format set<commit_after>import {
  inject,
  ComponentFixture,
  TestBed
} from '@angular/core/testing';
import {expect} from 'chai';
import {CloudinaryImageComponent} from '../src/cloudinary-image.component';
import {CloudinaryOptions} from '../src/cloudinary-options.class';
import {Ng2CloudinaryModule} from '../src';

describe('CloudinaryImage component', () => {

  beforeEach(() => {
    TestBed.configureTestingModule({imports: [Ng2CloudinaryModule]});
  });

  // it('should throw an error if CloudinaryOptions are not provided', () => {
  //   const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
  //   expect(fixture.detectChanges()).to.throw(Error, /CloudinaryOptions are required/);
  // });

  it('should create img DOM element', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    fixture.detectChanges();
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src=""');
  });

  it('should create img DOM element without publicId', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.publicId = null;
    fixture.detectChanges();

    let expectedImageUrl: string = '';
    expect(clImageComponent.imageUrl).to.equal(expectedImageUrl);
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src="' + expectedImageUrl + '"');
  });

  it('should create img DOM element with publicId', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.publicId = 'testPublicId';
    clImageComponent.ngOnChanges(null);
    fixture.detectChanges();

    let expectedImageUrl: string = 'https://res.cloudinary.com/ekito/image/upload/testPublicId';
    expect(clImageComponent.imageUrl).to.equal(expectedImageUrl);
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src="' + expectedImageUrl + '"');
  });

  it('should create img DOM element with transformations', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.height = 100;
    clImageComponent.width = 150;
    clImageComponent.publicId = 'testPublicId';
    clImageComponent.ngOnChanges(null);
    fixture.detectChanges();

    let expectedImageUrl: string = 'https://res.cloudinary.com/ekito/image/upload/h_100,w_150/testPublicId';
    expect(clImageComponent.imageUrl).to.equal(expectedImageUrl);
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('img');
    expect(fixture.nativeElement.innerHTML.trim()).to.contain('src="' + expectedImageUrl + '"');
  });

  it('should create img DOM element with title and alt', () => {
    const fixture: ComponentFixture<CloudinaryImageComponent> = TestBed.createComponent(CloudinaryImageComponent);
    const clImageComponent: CloudinaryImageComponent = fixture.componentInstance;
    clImageComponent.cloudName = 'ekito';
    clImageComponent.publicId = 'testPublicId';
    clImageComponent.title = 'testTitle';
    clImageComponent.alt = 'testAlt';
    clImageComponent.ngOnChanges(null);
    fixture.detectChanges();

    let expectedImageUrl: string = 'https://res.cloudinary.com/ekito/image/upload/testPublicId';
{'fraction_non_alphanumeric': 0.13071576636995488, 'fraction_numerical': 0.003414217778319717, 'mean_word_length': 5.417840375586854, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 31, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, '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': '1546208', 'n_tokens_mistral': 2303, 'n_tokens_neox': 2244, 'n_words': 372}