Skip to content

Commit

Permalink
test: updated test and changes after review
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Apr 22, 2024
1 parent 0440dfe commit 34874a4
Show file tree
Hide file tree
Showing 6 changed files with 88 additions and 76 deletions.
42 changes: 21 additions & 21 deletions src/lib/image-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
TransformData,
} from './types';

export class imageTransform {
export class ImageTransform {
obj: TransformData = {};

/**
Expand All @@ -26,7 +26,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
auto(): imageTransform {
auto(): ImageTransform {
this.obj.auto = 'webp';

return this;
Expand All @@ -44,7 +44,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
quality(qualityNum: number): imageTransform {
quality(qualityNum: number): ImageTransform {
this.obj.quality = qualityNum.toString();

return this;
Expand All @@ -62,7 +62,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
format(format: Format): imageTransform {
format(format: Format): ImageTransform {
this.obj.format = format;

return this;
Expand Down Expand Up @@ -93,7 +93,7 @@ export class imageTransform {
width?: string | number;
height?: string | number;
disable?: string;
}): imageTransform {
}): ImageTransform {
if (width) this.obj.width = width.toString();
if (height) this.obj.height = height.toString();
if (disable) this.obj.disable = 'upscale';
Expand Down Expand Up @@ -159,7 +159,7 @@ export class imageTransform {
cropBy?: CropBy;
safe?: boolean;
smart?: boolean;
}): imageTransform {
}): ImageTransform {
switch (cropBy) {
case CropBy.DEFAULT: {
this.obj.crop = [width.toString(), height.toString()];
Expand Down Expand Up @@ -195,7 +195,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
fit(type: FitBy): imageTransform {
fit(type: FitBy): ImageTransform {
this.obj.fit = type;

return this;
Expand Down Expand Up @@ -223,7 +223,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
trim(trimValues: number | number[]): imageTransform {
trim(trimValues: number | number[]): ImageTransform {
this.obj.trim = trimValues.toString();

return this;
Expand All @@ -243,7 +243,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
orient(orientType: Orientation): imageTransform {
orient(orientType: Orientation): ImageTransform {
this.obj.orient = orientType.toString();

return this;
Expand Down Expand Up @@ -300,7 +300,7 @@ export class imageTransform {
width?: string | number;
height?: string | number;
pad?: number | number[];
}): imageTransform {
}): ImageTransform {
this.obj.overlay = relativeURL;
if (align) this.obj['overlay-align'] = align.toString();
if (repeat) this.obj['overlay-repeat'] = repeat.toString();
Expand Down Expand Up @@ -328,7 +328,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
padding(padding: number | number[]): imageTransform {
padding(padding: number | number[]): ImageTransform {
this.obj.pad = padding.toString();

return this;
Expand All @@ -351,7 +351,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
bgColor(color: string | number[]): imageTransform {
bgColor(color: string | number[]): ImageTransform {
this.obj['bg-color'] = color.toString();

return this;
Expand All @@ -369,7 +369,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
dpr(dprValue: number): imageTransform {
dpr(dprValue: number): ImageTransform {
this.obj.dpr = dprValue.toString();

return this;
Expand All @@ -387,7 +387,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
blur(blurValue: number): imageTransform {
blur(blurValue: number): ImageTransform {
this.obj.blur = blurValue.toString();

return this;
Expand All @@ -405,7 +405,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
frame(): imageTransform {
frame(): ImageTransform {
this.obj.frame = '1';

return this;
Expand All @@ -425,7 +425,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
sharpen(amount: number, radius: number, threshold: number): imageTransform {
sharpen(amount: number, radius: number, threshold: number): ImageTransform {
this.obj.sharpen = [`a${amount}`, `r${radius}`, `t${threshold}`].toString();

return this;
Expand All @@ -443,7 +443,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
saturation(saturationValue: number): imageTransform {
saturation(saturationValue: number): ImageTransform {
this.obj.saturation = saturationValue.toString();

return this;
Expand All @@ -461,7 +461,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
contrast(contrastValue: number): imageTransform {
contrast(contrastValue: number): ImageTransform {
this.obj.contrast = contrastValue.toString();

return this;
Expand All @@ -479,7 +479,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
brightness(brightnessValue: number): imageTransform {
brightness(brightnessValue: number): ImageTransform {
this.obj.brightness = brightnessValue.toString();

return this;
Expand All @@ -499,7 +499,7 @@ export class imageTransform {
*
* const transformURL = url.transform(transformObj);
*/
resizeFilter(type: ResizeFilter): imageTransform {
resizeFilter(type: ResizeFilter): ImageTransform {
this.obj['resize-filter'] = type;

return this;
Expand Down Expand Up @@ -540,7 +540,7 @@ export class imageTransform {
xval?: string | number;
yval?: string | number;
canvasBy?: CanvasBy;
}): imageTransform {
}): ImageTransform {
switch (canvasBy) {
case CanvasBy.DEFAULT: {
this.obj.canvas = [width.toString(), height.toString()];
Expand Down
6 changes: 3 additions & 3 deletions src/lib/string-extensions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { imageTransform } from './image-transform';
import { ImageTransform } from './image-transform';

declare global {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface String {
transform(imageTransform: imageTransform): string;
transform(imageTransform: ImageTransform): string;
}
}

String.prototype.transform = function (imageTransform: imageTransform): string {
String.prototype.transform = function (imageTransform:ImageTransform): string {
let result = this.toString();
const queryString = Object.entries(Object.assign({}, imageTransform.obj))
.map(([key, value]) => `${key}=${value}`)
Expand Down
12 changes: 9 additions & 3 deletions test/api/entry-queryables.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,16 @@ describe('Query Operators API test cases', () => {
});

it('should check for include reference', async () => {
const query = makeEntries('contenttype_uid').includeReference('abc').query()
const query = makeEntries('contenttype_uid2').includeReference('test3').query()
const result = await query.find<TEntry>()
if (query) {
console.log("🚀 ~ it ~ query._p:", query._queryParams)
if (result.entries) {
expect(result.entries.length).toBeGreaterThan(0);
expect(result.entries[0].reference).toBeDefined();
expect(result.entries[0]._version).toBeDefined();
expect(result.entries[0].title).toBeDefined();
expect(result.entries[0].uid).toBeDefined();
expect(result.entries[0].created_at).toBeDefined();

}
});
});
Expand Down
6 changes: 6 additions & 0 deletions test/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface TEntry {
publish_details: PublishDetails;
author: Author[];
url: string;
reference?: Reference[]
}


Expand All @@ -29,6 +30,11 @@ interface Author {
_content_type_uid: string;
}

interface Reference {
uid: string;
_content_type_uid: string;
}

export interface TAsset {
_version: number;
uid: string;
Expand Down
Loading

0 comments on commit 34874a4

Please sign in to comment.