Skip to content

Commit 486ada4

Browse files
committed
add test to verify refresh() is called after a change event has occurred
1 parent 75beb3a commit 486ada4

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test/mobile.spec.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,18 @@ describe('mobile', function() {
8787
});
8888
expect($('.selectric-wrapper').length).toBe(1);
8989
});
90+
91+
it('should refresh the select after change', function () {
92+
setUserAgent(window, 'Mozilla/5.0 (Linux; Android 4.1.1; Galaxy Nexus Build/JRO03C) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19');
93+
var spy = spyOn(select.data('selectric'), 'refresh');
94+
select.selectric({
95+
disableOnMobile: false,
96+
nativeOnMobile: true
97+
});
98+
select.trigger('change');
99+
expect(spy).toHaveBeenCalled();
100+
});
101+
90102
describe('nativeOnMobile', function () {
91103
beforeEach(function () {
92104
setUserAgent(window, 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3');
@@ -96,6 +108,10 @@ describe('mobile', function() {
96108
});
97109
});
98110

111+
afterEach(function() {
112+
setUserAgent(window, oldUserAgent);
113+
});
114+
99115
it('should add class `selectric-is-native`', function () {
100116
expect($('.selectric-wrapper').find('.selectric-is-native').length).toBe(1);
101117
});

0 commit comments

Comments
 (0)