Skip to content

Commit f9f2f50

Browse files
authored
Added test for secure placeholder (#291)
1 parent 2ebb30e commit f9f2f50

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

projects/angular-cld/src/lib/cloudinary-image.component.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,37 @@ describe('CloudinaryImage', () => {
649649
expect(img.getAttribute('style')).toEqual(jasmine.stringMatching('opacity: 0; position: absolute;'));
650650
});
651651
});
652+
describe('placeholder with secure', () => {
653+
@Component({
654+
template: `
655+
<cl-image public-id="sample.jpg" secure="true">
656+
<cl-placeholder></cl-placeholder>
657+
</cl-image>`
658+
})
659+
class TestComponent {}
660+
661+
let fixture: ComponentFixture<TestComponent>;
662+
let placeholder: DebugElement[];
663+
let testLocalCloudinary: Cloudinary = new Cloudinary(require('cloudinary-core'),
664+
{ cloud_name: '@@fake_angular2_sdk@@', client_hints: true } as CloudinaryConfiguration);
665+
beforeEach(fakeAsync(() => {
666+
fixture = TestBed.configureTestingModule({
667+
declarations: [CloudinaryTransformationDirective, CloudinaryImage, TestComponent, LazyLoadDirective, CloudinaryPlaceHolder],
668+
providers: [{ provide: Cloudinary, useValue: testLocalCloudinary }]
669+
}).createComponent(TestComponent);
670+
671+
fixture.detectChanges(); // initial binding
672+
// all elements with an attached CloudinaryImage
673+
placeholder = fixture.debugElement.queryAll(By.directive(CloudinaryPlaceHolder));
674+
tick();
675+
fixture.detectChanges();
676+
}));
677+
678+
it('placeholder should have secure URL', () => {
679+
const placeholderImg = placeholder[0].children[0].nativeElement as HTMLImageElement;
680+
expect(placeholderImg.getAttribute('src')).toEqual('https://res.cloudinary.com/@@fake_angular2_sdk@@/image/upload/e_blur:2000,f_auto,q_1/sample.jpg');
681+
});
682+
});
652683
describe('cl-image with placeholder and html style', () => {
653684
@Component({
654685
template: `<div style="margin-top: 4000px"></div>

0 commit comments

Comments
 (0)