Skip to content

Commit

Permalink
add: rollup commonjs plugin in karma config
Browse files Browse the repository at this point in the history
  • Loading branch information
awe committed Mar 10, 2018
1 parent 54f7066 commit 5ab63ad
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
"extends": "standard",
"env": {
"browser": true,
"es6": true
"es6": true,
"mocha": true,
"chai": true
}
}
7 changes: 4 additions & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module.exports = function (config) {
require('karma-mocha'),
require('karma-chai'),
require('karma-chrome-launcher'),
require('karma-rollup-preprocessor'),
require('karma-rollup-preprocessor')
// require('karma-coverage')
],
files: [
Expand All @@ -25,13 +25,14 @@ module.exports = function (config) {
// },
rollupPreprocessor: {
plugins: [
require('rollup-plugin-babel')(),
require('rollup-plugin-node-resolve')({
jsnext: true,
browser: true
}),
require('rollup-plugin-commonjs')(),
require('rollup-plugin-babel')(),
require('rollup-plugin-replace')({
'process.env.NODE_ENV': JSON.stringify( 'production' )
'process.env.NODE_ENV': JSON.stringify('production')
})
],
format: 'iife', // Helps prevent naming collisions.
Expand Down
22 changes: 11 additions & 11 deletions test/test-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@ describe('VueLazyload.js Test Suite', function () {
const LazyCore = genLazyCore(Vue)

const lazyload = new LazyCore({
error: 'error',
loading: 'loading',
error: 'error',
loading: 'loading'
})

expect(lazyload._valueFormatter('src').src).to.equal('src')
expect(lazyload._valueFormatter('src').error).to.equal('error')
expect(lazyload._valueFormatter('src').loading).to.equal('loading')

expect(lazyload._valueFormatter({
src: 'src',
error: 'error',
loading: 'loading',
src: 'src',
error: 'error',
loading: 'loading'
}).src).to.equal('src')

expect(lazyload._valueFormatter({
src: 'src',
error: 'error',
loading: 'loading',
src: 'src',
error: 'error',
loading: 'loading'
}).error).to.equal('error')

expect(lazyload._valueFormatter({
src: 'src',
error: 'error',
loading: 'loading',
src: 'src',
error: 'error',
loading: 'loading'
}).loading).to.equal('loading')
})
})

0 comments on commit 5ab63ad

Please sign in to comment.