Merged in fix/3697-prettier-configs (pull request #3396)
fix(SW-3691): Setup one prettier config for whole repo * Setup prettierrc in root and remove other configs Approved-by: Joakim Jäderberg Approved-by: Linus Flood
This commit is contained in:
@@ -1,69 +1,69 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { imageLoader } from './imageLoader'
|
||||
describe('imageLoader', () => {
|
||||
it('should generate the correct image URL for absolute URLs', () => {
|
||||
import { describe, it, expect } from "vitest"
|
||||
import { imageLoader } from "./imageLoader"
|
||||
describe("imageLoader", () => {
|
||||
it("should generate the correct image URL for absolute URLs", () => {
|
||||
const loader = imageLoader({ dimensions: { width: 800, height: 600 } })
|
||||
const url = loader({
|
||||
quality: 80,
|
||||
src: 'https://example.com/image.jpg',
|
||||
src: "https://example.com/image.jpg",
|
||||
width: 800,
|
||||
})
|
||||
|
||||
expect(url).toBe(
|
||||
'https://img.scandichotels.com/.netlify/images?url=https://example.com/image.jpg&w=800&q=80'
|
||||
"https://img.scandichotels.com/.netlify/images?url=https://example.com/image.jpg&w=800&q=80"
|
||||
)
|
||||
})
|
||||
|
||||
it('should generate the correct image URL for relative URLs', () => {
|
||||
it("should generate the correct image URL for relative URLs", () => {
|
||||
const loader = imageLoader({ dimensions: { width: 800, height: 600 } })
|
||||
const url = loader({
|
||||
quality: 80,
|
||||
src: '/image.jpg',
|
||||
src: "/image.jpg",
|
||||
width: 800,
|
||||
})
|
||||
|
||||
expect(url).toBe('/image.jpg?w=800&q=80')
|
||||
expect(url).toBe("/image.jpg?w=800&q=80")
|
||||
})
|
||||
|
||||
it('should compensate for landscape 3:2 images', () => {
|
||||
it("should compensate for landscape 3:2 images", () => {
|
||||
const loader = imageLoader({ dimensions: { width: 6000, height: 4000 } })
|
||||
const url = loader({
|
||||
src: '/image.jpg',
|
||||
src: "/image.jpg",
|
||||
width: 400,
|
||||
})
|
||||
|
||||
expect(url).toBe('/image.jpg?w=600')
|
||||
expect(url).toBe("/image.jpg?w=600")
|
||||
})
|
||||
|
||||
it('should compensate for landscape ~3:2 images', () => {
|
||||
it("should compensate for landscape ~3:2 images", () => {
|
||||
const loader = imageLoader({ dimensions: { width: 7952, height: 5304 } })
|
||||
const url = loader({
|
||||
src: '/image.jpg',
|
||||
src: "/image.jpg",
|
||||
width: 400,
|
||||
})
|
||||
|
||||
expect(url).toBe('/image.jpg?w=600')
|
||||
expect(url).toBe("/image.jpg?w=600")
|
||||
})
|
||||
|
||||
it('should compensate for standing 2:3 images', () => {
|
||||
it("should compensate for standing 2:3 images", () => {
|
||||
const loader = imageLoader({ dimensions: { width: 4000, height: 6000 } })
|
||||
const url = loader({
|
||||
src: '/image.jpg',
|
||||
src: "/image.jpg",
|
||||
width: 800,
|
||||
})
|
||||
|
||||
expect(url).toBe('/image.jpg?w=800')
|
||||
expect(url).toBe("/image.jpg?w=800")
|
||||
})
|
||||
|
||||
it('should compensate for landscape 2:1 images', () => {
|
||||
it("should compensate for landscape 2:1 images", () => {
|
||||
const loader = imageLoader({ dimensions: { width: 2000, height: 1000 } })
|
||||
const url = loader({
|
||||
src: '/image.jpg',
|
||||
src: "/image.jpg",
|
||||
width: 800,
|
||||
})
|
||||
|
||||
// used to fetch an image 800x400 image but we, probably, render it with a height of 533
|
||||
|
||||
expect(url).toBe('/image.jpg?w=1200')
|
||||
expect(url).toBe("/image.jpg?w=1200")
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user