Skip to content

Commit

Permalink
Merge pull request #9 from LancerComet/hotfix/umd
Browse files Browse the repository at this point in the history
+ Fix UMD export.
  • Loading branch information
LancerComet authored Apr 28, 2018
2 parents 0109045 + 11ce5ee commit 1828d14
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 6 deletions.
7 changes: 7 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.vscode/
src/
test/
.babelrc
.editorconfig
.travis.yml
gulpfile.js
2 changes: 1 addition & 1 deletion dist/vue-jsonp.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Index = factory();
root.vueJsonp = factory();
}
}(this, function() {
/**
Expand Down
9 changes: 7 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ gulp.task('js:build', () => {
gulp.task('js:umd', (file) => {
gulp.src(ENTRY)
.pipe(umd({
exports: function (file) { return 'vueJsonp' }
exports (file) {
return 'vueJsonp'
},
namespace (file) {
return 'vueJsonp'
}
}))
.pipe(rename('vue-jsonp.umd.js'))
.pipe(gulp.dest(`${ROOTPATH}/dist`))
})
})
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
"JSONP"
],
"scripts": {
"build": "gulp",
"predev": "gulp",
"pretest": "gulp",
"dev": "karma start ./test/karma.conf.js",
"build": "gulp",
"test": "karma start ./test/karma.conf.js --single-run"
},
"author": {
Expand Down
2 changes: 0 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Polyfill fn.bind() for PhantomJS
/* eslint-disable no-extend-native */
Function.prototype.bind = require('function-bind')

// require all test files (files that ends with .spec.js)
require('./specs/format-params.spec.js')
require('./specs/vue-jsonp.spec.js')
17 changes: 17 additions & 0 deletions test/specs/format-params.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ describe('Param format testing.', function () {

expect(decodeURIComponent(result)).equal(expected)
})

it('Should format params correctly - from issue.', function () {
var self = {
email: '[email protected]',
first_name: 'FirstName',
last_name: 'LastName'
}

var result = createQueryStr({
'EMAIL': self.email,
'FNAME': self.first_name,
'LNAME': self.last_name
})

var expected = 'EMAIL=' + self.email + '&FNAME=' + self.first_name + '&LNAME=' + self.last_name
expect(decodeURIComponent(result)).equal(expected)
})
})

function createQueryStr (param) {
Expand Down

0 comments on commit 1828d14

Please sign in to comment.