mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 04:14:21 +08:00
test(img): allow datauris
This commit is contained in:
@ -189,8 +189,14 @@ export class Img implements OnDestroy {
|
|||||||
// update to the new src
|
// update to the new src
|
||||||
this._src = newSrc;
|
this._src = newSrc;
|
||||||
|
|
||||||
// reset any existing datauri we might be holding onto
|
if (newSrc.indexOf('data:') === 0) {
|
||||||
this._tmpDataUri = null;
|
// they're using an actual datauri already
|
||||||
|
this._tmpDataUri = newSrc;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// reset any existing datauri we might be holding onto
|
||||||
|
this._tmpDataUri = null;
|
||||||
|
}
|
||||||
|
|
||||||
// run update to kick off requests or render if everything is good
|
// run update to kick off requests or render if everything is good
|
||||||
this.update();
|
this.update();
|
||||||
|
@ -51,6 +51,20 @@
|
|||||||
|
|
||||||
</ion-item>
|
</ion-item>
|
||||||
|
|
||||||
|
<ion-item>
|
||||||
|
|
||||||
|
<ion-avatar item-left>
|
||||||
|
<ion-img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw=="></ion-img>
|
||||||
|
</ion-avatar>
|
||||||
|
|
||||||
|
Datauri
|
||||||
|
|
||||||
|
<ion-thumbnail item-right>
|
||||||
|
<ion-img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw=="></ion-img>
|
||||||
|
</ion-thumbnail>
|
||||||
|
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
<ion-item>
|
<ion-item>
|
||||||
|
|
||||||
<ion-thumbnail item-left>
|
<ion-thumbnail item-left>
|
||||||
|
@ -42,6 +42,14 @@ describe('Img', () => {
|
|||||||
expect(img._tmpDataUri).toEqual(null);
|
expect(img._tmpDataUri).toEqual(null);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should set datauri src', () => {
|
||||||
|
spyOn(img, 'update');
|
||||||
|
img.src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==';
|
||||||
|
expect(img.src).toEqual('data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==');
|
||||||
|
expect(img._tmpDataUri).toEqual(`data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==`);
|
||||||
|
expect(img.update).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('should set src', () => {
|
it('should set src', () => {
|
||||||
spyOn(img, 'update');
|
spyOn(img, 'update');
|
||||||
img.src = 'image.jpg';
|
img.src = 'image.jpg';
|
||||||
|
Reference in New Issue
Block a user