Skip to content

Commit

Permalink
Added test for secure placeholder (#291)
Browse files Browse the repository at this point in the history
  • Loading branch information
strausr authored Aug 12, 2020
1 parent 2ebb30e commit f9f2f50
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions projects/angular-cld/src/lib/cloudinary-image.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,37 @@ describe('CloudinaryImage', () => {
expect(img.getAttribute('style')).toEqual(jasmine.stringMatching('opacity: 0; position: absolute;'));
});
});
describe('placeholder with secure', () => {
@Component({
template: `
<cl-image public-id="sample.jpg" secure="true">
<cl-placeholder></cl-placeholder>
</cl-image>`
})
class TestComponent {}

let fixture: ComponentFixture<TestComponent>;
let placeholder: DebugElement[];
let testLocalCloudinary: Cloudinary = new Cloudinary(require('cloudinary-core'),
{ cloud_name: '@@fake_angular2_sdk@@', client_hints: true } as CloudinaryConfiguration);
beforeEach(fakeAsync(() => {
fixture = TestBed.configureTestingModule({
declarations: [CloudinaryTransformationDirective, CloudinaryImage, TestComponent, LazyLoadDirective, CloudinaryPlaceHolder],
providers: [{ provide: Cloudinary, useValue: testLocalCloudinary }]
}).createComponent(TestComponent);

fixture.detectChanges(); // initial binding
// all elements with an attached CloudinaryImage
placeholder = fixture.debugElement.queryAll(By.directive(CloudinaryPlaceHolder));
tick();
fixture.detectChanges();
}));

it('placeholder should have secure URL', () => {
const placeholderImg = placeholder[0].children[0].nativeElement as HTMLImageElement;
expect(placeholderImg.getAttribute('src')).toEqual('https://res.cloudinary.com/@@fake_angular2_sdk@@/image/upload/e_blur:2000,f_auto,q_1/sample.jpg');
});
});
describe('cl-image with placeholder and html style', () => {
@Component({
template: `<div style="margin-top: 4000px"></div>
Expand Down

0 comments on commit f9f2f50

Please sign in to comment.