Modularise and test setting of jQuery Mobile config options.
This commit is contained in:
parent
e2920920ed
commit
1345357a5e
@ -1,8 +1,25 @@
|
|||||||
// jQuery Mobile configuration options
|
// jQuery Mobile configuration options
|
||||||
// see: http://api.jquerymobile.com/1.3/global-config/
|
// see: http://api.jquerymobile.com/1.3/global-config/
|
||||||
$(document).bind('mobileinit', function () {
|
(function (root, factory) {
|
||||||
$.extend($.mobile, {
|
if (typeof define === 'function' && define.amd) {
|
||||||
ajaxEnabled: false,
|
define([], factory)
|
||||||
hashListeningEnabled: false
|
} else if (typeof module === 'object' && module.exports) {
|
||||||
})
|
module.exports = factory()
|
||||||
})
|
} else {
|
||||||
|
root.configureJQueryMobile = factory()
|
||||||
|
}
|
||||||
|
}(this, function () {
|
||||||
|
'use strict'
|
||||||
|
|
||||||
|
function configureJQueryMobile () {
|
||||||
|
$.extend($.mobile, {
|
||||||
|
ajaxEnabled: false,
|
||||||
|
hashListeningEnabled: false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
$(document).bind('mobileinit', configureJQueryMobile)
|
||||||
|
|
||||||
|
return configureJQueryMobile
|
||||||
|
}))
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
CACHE MANIFEST
|
CACHE MANIFEST
|
||||||
|
|
||||||
# 2016-04-03:v1
|
# 2016-04-03:v2
|
||||||
|
|
||||||
NETWORK:
|
NETWORK:
|
||||||
*
|
*
|
||||||
|
|||||||
30
tests/js/test_custom_scripting.js
Normal file
30
tests/js/test_custom_scripting.js
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
var chai = require('chai')
|
||||||
|
var expect = chai.expect
|
||||||
|
var assert = chai.assert
|
||||||
|
chai.use(require('chai-string'))
|
||||||
|
chai.use(require('chai-jquery'))
|
||||||
|
|
||||||
|
var sinon = require('sinon')
|
||||||
|
|
||||||
|
var configureJQueryMobile = require('../../mopidy_musicbox_webclient/static/js/custom_scripting.js')
|
||||||
|
|
||||||
|
describe('jQuery Defaults', function () {
|
||||||
|
it('should disable ajax and hashListening', function () {
|
||||||
|
expect($.mobile.ajaxEnabled).to.be.true
|
||||||
|
expect($.mobile.hashListeningEnabled).to.be.true
|
||||||
|
|
||||||
|
configureJQueryMobile()
|
||||||
|
expect($.mobile.ajaxEnabled).to.be.false
|
||||||
|
expect($.mobile.hashListeningEnabled).to.be.false
|
||||||
|
})
|
||||||
|
|
||||||
|
it('should bind to "mobileinit"', function () {
|
||||||
|
var configSpy = sinon.spy(configureJQueryMobile)
|
||||||
|
|
||||||
|
$(document).bind('mobileinit', configSpy)
|
||||||
|
expect(configSpy.called).to.be.false
|
||||||
|
$(document).trigger('mobileinit')
|
||||||
|
expect(configSpy.called).to.be.true
|
||||||
|
configSpy.reset()
|
||||||
|
})
|
||||||
|
})
|
||||||
Loading…
Reference in New Issue
Block a user