-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
2,852 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
# Common | ||
node_modules | ||
dist | ||
.nuxt | ||
coverage | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
root: true, | ||
extends: [ | ||
'@nuxtjs', | ||
'@nuxtjs/eslint-config-typescript' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ node_modules | |
cache/ | ||
dist/ | ||
ipx | ||
.DS_Store | ||
.DS_Store | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module.exports = { | ||
launch: { | ||
// to use google chrome, install puppeteer with PUPPETEER_SKIP_CHROMIUM_DOWNLOAD env | ||
// and uncomment next line | ||
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', | ||
args: [ | ||
'–no-sandbox', | ||
'–disable-setuid-sandbox' | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module.exports = { | ||
preset: 'jest-puppeteer', | ||
transform: { | ||
'^.+\\.ts$': 'ts-jest', | ||
'^.+\\.[jt]sx?$': 'babel-jest', | ||
}, | ||
moduleNameMapper: { | ||
'~image/(.*)': '<rootDir>/src/$1', | ||
'^.+\\.css$': '<rootDir>/test/fixture/utils/CSSStub.js' | ||
}, | ||
globals: { | ||
'ts-jest': { | ||
tsConfig: 'tsconfig.test.json', | ||
diagnostics: { | ||
ignoreCodes: [2345] | ||
} | ||
} | ||
}, | ||
collectCoverage: true, | ||
collectCoverageFrom: [ | ||
'src/**/*.ts' | ||
], | ||
coverageThreshold: { | ||
// global: { | ||
// branches: 100, | ||
// functions: 100, | ||
// lines: 100, | ||
// statements: 100 | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { setupTest } from '@nuxtjs/module-test-utils' | ||
|
||
describe('undefined config', () => { | ||
setupTest({ | ||
fixture: 'fixture/base', | ||
configFile: 'nuxt.config.ts', | ||
config: {} | ||
}) | ||
|
||
test('render index', () => { | ||
expect(true).toBeTruthy() | ||
}) | ||
}) | ||
|
||
describe('Custome Provider', () => { | ||
setupTest({ | ||
fixture: 'fixture/base', | ||
configFile: 'nuxt.config.ts', | ||
config: { | ||
image: { | ||
providers: { | ||
random: '~/providers/random' | ||
} | ||
} | ||
} | ||
}) | ||
|
||
test('built', () => { | ||
expect(true).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export default { | ||
components: true, | ||
modules: [ | ||
'../../src/module.ts' | ||
], | ||
buildModules: [ | ||
'@nuxt/typescript-build' | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<template> | ||
<div> | ||
It works | ||
<nuxt-image src="/2000px-Aconcagua2016.jpg" width="300px" height="200px" /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export default function (providerOptions) { | ||
return { | ||
runtime: require.resolve('./runtime'), | ||
runtimeOptions: providerOptions | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
|
||
export default { | ||
generateURL () { | ||
return { | ||
url: 'https://source.unsplash.com/random/600x400' | ||
} | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "ES2018", | ||
"module": "ESNext", | ||
"moduleResolution": "Node", | ||
"lib": [ | ||
"ESNext", | ||
"ESNext.AsyncIterable", | ||
"DOM" | ||
], | ||
"esModuleInterop": true, | ||
"allowJs": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
"noEmit": true, | ||
"baseUrl": ".", | ||
"paths": { | ||
"~/*": [ | ||
"./*" | ||
], | ||
"@/*": [ | ||
"./*" | ||
] | ||
}, | ||
"types": [ | ||
"@types/node", | ||
"@nuxt/types" | ||
] | ||
}, | ||
"exclude": [ | ||
"node_modules" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
module.exports = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const { generate, createContext, loadNuxt, loadFixture } = require('@nuxtjs/module-test-utils') | ||
|
||
describe('undefined config', () => { | ||
let nuxt | ||
beforeAll(async () => { | ||
createContext({ | ||
fixture: 'fixture/base', | ||
configFile: 'nuxt.config.ts' | ||
}) | ||
await loadFixture() | ||
await loadNuxt() | ||
await generate() | ||
}, 60000) | ||
|
||
afterAll(async () => { | ||
await nuxt.close() | ||
}) | ||
|
||
test('render index', () => { | ||
expect(true).toBeTruthy() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { setupTest, getContext } from '@nuxtjs/module-test-utils' | ||
|
||
describe('Plugin', () => { | ||
let testContext, plugin | ||
const nuxtContext = { | ||
nuxtState: { | ||
data: [{}] | ||
}, | ||
$img: null | ||
} | ||
|
||
setupTest({ | ||
fixture: 'fixture/base', | ||
configFile: 'nuxt.config.ts', | ||
server: true, | ||
config: { | ||
image: { | ||
presets: [ | ||
{ | ||
name: 'circle', | ||
modifiers: { | ||
r: '100' | ||
} | ||
} | ||
], | ||
providers: { | ||
local: {}, | ||
random: '~/providers/random', | ||
cloudinary: { | ||
baseURL: 'https://res.cloudinary.com/nuxt/image/upload' | ||
} | ||
} | ||
} | ||
} | ||
}) | ||
|
||
test('Generate LQIP', async () => { | ||
testContext = getContext() | ||
plugin = (await import(testContext.nuxt.options.buildDir + '/image.js')).default | ||
plugin(nuxtContext, (_, data) => { nuxtContext.$img = data }) | ||
|
||
const lqip = nuxtContext.$img.lqip('/test.png') | ||
expect(lqip).toEqual('/_image/local/_/w_30/test.png') | ||
}) | ||
|
||
test('Generate Random Image', () => { | ||
const image = nuxtContext.$img('random:/test.png') | ||
expect(image).toEqual('https://source.unsplash.com/random/600x400') | ||
}) | ||
|
||
test('Generate Circle Image with Cloudinary', () => { | ||
const image = nuxtContext.$img('cloudinary+circle:/test.png', {}) | ||
expect(image).toEqual('https://res.cloudinary.com/nuxt/image/upload/c_fit,r_100/test.png') | ||
}) | ||
|
||
test('Deny Invalid Images', () => { | ||
expect(() => nuxtContext.$img('test.png', {})).toThrow(Error) | ||
}) | ||
|
||
test('Deny undefined provider', () => { | ||
expect(() => nuxtContext.$img('invalid:/test.png', {})).toThrow(Error) | ||
}) | ||
|
||
test('Deny undefined preset', () => { | ||
expect(() => nuxtContext.$img('+invalid:/test.png', {})).toThrow(Error) | ||
}) | ||
}) |
Oops, something went wrong.