Skip to content

Commit

Permalink
fix: tests & typo
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Nov 8, 2020
1 parent 7e3f80b commit 6f06e65
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 19 deletions.
1 change: 0 additions & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export default {
}
],
providers: {
ipx: false,
twicpics: {
baseURL: 'https://i5acur1u.twic.pics'
},
Expand Down
2 changes: 1 addition & 1 deletion src/providers/ipx/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default <RuntimeProvider> {
const adapter = predictAdapter(src)

const operationsString = operations.join(',') || '_'
const url = cleanDoubleSlashes(`/_image/local/${adapter}/${modifiers.format || '_'}/${operationsString}/${src}`)
const url = cleanDoubleSlashes(`/_image/ipx/${adapter}/${modifiers.format || '_'}/${operationsString}/${src}`)

return {
url,
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/nuxt-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ export default {
mixins: [nuxtImageMixin],
computed: {
generatedSrcset () {
if (!Array.isArray(this.source) || this.source.length < 2) {
if (!Array.isArray(this.sources) || this.sources.length < 2) {
return undefined
}
return this.sources.map(({ width, url }) => width ? `${url} ${width}w` : url).join(', ')
},
generatedSizes () {
if (!Array.isArray(this.source) || this.source.length < 2) {
if (!Array.isArray(this.sources) || this.sources.length < 2) {
return undefined
}
return this.sources.map(({ width, media }) => media ? `${media} ${width}px` : `${width}px`).reverse().join(', ')
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/no-ssr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('browser', () => {
page.goto(url('/'))
const body = await page.innerHTML('body')
expect(body).not.toContain('/_/w_30/2000px-Aconcagua2016.jpg')
const placeholderRequest = requests.find(request => request.match('/_image/local/_/w_30/2000px-Aconcagua2016.jpg'))
const placeholderRequest = requests.find(request => request.match('/_image/ipx/_/w_30/2000px-Aconcagua2016.jpg'))
expect(placeholderRequest).not.toBeNull()
const positiveRequest = requests.find(request => request.match('2000px-Aconcagua2016.jpg'))
expect(positiveRequest).not.toBeNull()
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/ssr.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('browser', () => {
page.goto(url('/'))
// temporally commented
// const body = await page.innerHTML('body')
// expect(body).toContain('/_image/local/local/_/w_30/2000px-Aconcagua2016.jpg')
// expect(body).toContain('/_image/ipx/local/_/w_30/2000px-Aconcagua2016.jpg')
const positiveRequest = requests.find(request => request.match('2000px-Aconcagua2016.jpg'))
expect(positiveRequest).not.toBeNull()
const negativeRequest = requests.find(request => request.match('1280px-K2_2006b.jpg'))
Expand Down
6 changes: 3 additions & 3 deletions test/unit/image.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Renders simple image', () => {
lazy: true,
width: 200,
height: 200,
sets: '200,500:500,900:900 (webp)'
sizes: '200,500:500,900:900 (webp)'
})
})

Expand All @@ -15,7 +15,7 @@ describe('Renders lazy=false', () => {
lazy: false,
width: '200px',
height: 200,
sets: [
sizes: [
{
width: 200
}, {
Expand All @@ -36,7 +36,7 @@ describe('Renders noscript', () => {
noScript: true,
width: 200,
height: 200,
sets: [
sizes: [
{
width: 200
}, {
Expand Down
6 changes: 3 additions & 3 deletions test/unit/picture.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ describe('Renders simple image', () => {
lazy: true,
width: 200,
height: 200,
sets: '200,500:500,900:900 (webp)'
sizes: '200,500:500,900:900 (webp)'
})
})

Expand All @@ -15,7 +15,7 @@ describe('Renders lazy=false', () => {
lazy: false,
width: '200px',
height: 200,
sets: [
sizes: [
{
width: 200
}, {
Expand All @@ -36,7 +36,7 @@ describe('Renders noscript', () => {
noScript: true,
width: 200,
height: 200,
sets: [
sizes: [
{
width: 200
}, {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Plugin', () => {

// temporally commented
// const placeholder = nuxtContext.$img.getPlaceholder('/test.png')
// expect(placeholder).toEqual('/_image/local/_/w_30/test.png')
// expect(placeholder).toEqual('/_image/ipx/_/w_30/test.png')
})

test('Generate Random Image', () => {
Expand Down
12 changes: 6 additions & 6 deletions test/unit/providers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,47 +8,47 @@ import imgix from '~/src/providers/imgix'
const images = [
{
args: ['/test.png', {}],
local: { isStatic: true, url: '/_image/local/local/_/_/test.png' },
local: { isStatic: true, url: '/_image/ipx/local/_/_/test.png' },
cloudinary: { url: '/test.png' },
twicpics: { url: '/test.png?twic=v1/' },
fastly: { url: '/test.png?' },
imgix: { url: '/test.png?' }
},
{
args: ['/test.png', { width: 200 }],
local: { isStatic: true, url: '/_image/local/local/_/w_200/test.png' },
local: { isStatic: true, url: '/_image/ipx/local/_/w_200/test.png' },
cloudinary: { url: '/w_200/test.png' },
twicpics: { url: '/test.png?twic=v1/cover=200x-' },
fastly: { url: '/test.png?width=200' },
imgix: { url: '/test.png?w=200' }
},
{
args: ['/test.png', { height: 200 }],
local: { isStatic: true, url: '/_image/local/local/_/h_200/test.png' },
local: { isStatic: true, url: '/_image/ipx/local/_/h_200/test.png' },
cloudinary: { url: '/h_200/test.png' },
twicpics: { url: '/test.png?twic=v1/cover=-x200' },
fastly: { url: '/test.png?height=200' },
imgix: { url: '/test.png?h=200' }
},
{
args: ['/test.png', { width: 200, height: 200 }],
local: { isStatic: true, url: '/_image/local/local/_/s_200_200/test.png' },
local: { isStatic: true, url: '/_image/ipx/local/_/s_200_200/test.png' },
cloudinary: { url: '/w_200,h_200/test.png' },
twicpics: { url: '/test.png?twic=v1/cover=200x200' },
fastly: { url: '/test.png?width=200&height=200' },
imgix: { url: '/test.png?w=200&h=200' }
},
{
args: ['/test.png', { width: 200, height: 200, fit: 'contain' }],
local: { isStatic: true, url: '/_image/local/local/_/s_200_200_contain/test.png' },
local: { isStatic: true, url: '/_image/ipx/local/_/s_200_200_contain/test.png' },
cloudinary: { url: '/w_200,h_200,c_scale/test.png' },
twicpics: { url: '/test.png?twic=v1/contain=200x200' },
fastly: { url: '/test.png?width=200&height=200&fit=bounds' },
imgix: { url: '/test.png?w=200&h=200&fit=fill' }
},
{
args: ['/test.png', { width: 200, height: 200, fit: 'contain', format: 'jpeg' }],
local: { isStatic: true, url: '/_image/local/local/jpeg/s_200_200_contain/test.png' },
local: { isStatic: true, url: '/_image/ipx/local/jpeg/s_200_200_contain/test.png' },
cloudinary: { url: '/w_200,h_200,c_scale,f_jpeg/test.png' },
twicpics: { url: '/test.png?twic=v1/format=jpeg/contain=200x200' },
fastly: { url: '/test.png?width=200&height=200&fit=bounds&format=jpeg' },
Expand Down

0 comments on commit 6f06e65

Please sign in to comment.