Skip to content

Commit 05003fd

Browse files
authored
Added test for normarlized user variables (#280)
1 parent 1767aea commit 05003fd

File tree

3 files changed

+35
-2
lines changed

3 files changed

+35
-2
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"@types/jasminewd2": "2.0.8",
4141
"@types/node": "^8.9.5",
4242
"bundlewatch": "0.2.6",
43-
"cloudinary-core": "2.8.2",
43+
"cloudinary-core": "2.9.0",
4444
"codelyzer": "4.2.1",
4545
"jasmine-core": "2.99.1",
4646
"jasmine-spec-reporter": "4.2.1",

projects/angular-cld/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"@angular/core": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0 || ^9.0.0"
77
},
88
"devDependencies": {
9-
"cloudinary-core": "^2.8.1",
9+
"cloudinary-core": "^2.9.0",
1010
"typescript": "^2.9.2"
1111
}
1212
}

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,39 @@ describe('CloudinaryImage', () => {
341341
});
342342
});
343343

344+
describe('should support user variables with keyword $width', () => {
345+
@Component({
346+
template:
347+
`
348+
<cl-image public-id="sample">
349+
<cl-transformation variables="[['$width','150']]"></cl-transformation>
350+
<cl-transformation width="$width" crop="crop" ></cl-transformation>
351+
</cl-image>
352+
`
353+
})
354+
class TestComponent { }
355+
356+
let fixture: ComponentFixture<TestComponent>;
357+
let des: DebugElement; // the elements w/ the directive
358+
359+
beforeEach(() => {
360+
fixture = TestBed.configureTestingModule({
361+
declarations: [CloudinaryTransformationDirective, CloudinaryImage, TestComponent],
362+
providers: [{ provide: Cloudinary, useValue: localCloudinary }]
363+
}).createComponent(TestComponent);
364+
365+
fixture.detectChanges(); // initial binding
366+
367+
// Our element under test, which is attached to CloudinaryImage
368+
des = fixture.debugElement.query(By.directive(CloudinaryImage));
369+
});
370+
371+
it('creates an img element with user variables $width', () => {
372+
const img = des.children[0].nativeElement as HTMLImageElement;
373+
expect(img.attributes.getNamedItem('src').value).toEqual('http://res.cloudinary.com/@@fake_angular2_sdk@@/image/upload/$width_150/c_crop,w_$width/sample');
374+
});
375+
});
376+
344377
describe('Sample code presented in README', () => {
345378
@Component({
346379
template:

0 commit comments

Comments
 (0)