diff --git a/build/smart-number-inputs.min.js b/build/smart-number-inputs.min.js index 5937e2c..56e4c19 100644 --- a/build/smart-number-inputs.min.js +++ b/build/smart-number-inputs.min.js @@ -7,4 +7,4 @@ * License: MIT * URL: https://github.com/codeclown/smart-number-inputs */ -"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"object"===("undefined"==typeof module?"undefined":_typeof(module))?module.exports=e():"function"==typeof define&&define.amd?define(e):window.smartNumberInputs=e()}(function(){var e=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t=function(e,t,n){return e.addEventListener(t,n)},n=function(e,t){for(var n=0;n=t&&(null===u&&(u=c-i.length),f[a]=i.replace(/-?[0-9]+/,parseInt(i.replace(/^.*?(-?[0-9]+).*/,"$1"),10)+o)),c-=i.length-f[a].length,n-=i.length-f[a].length,c>=n)){l=c;break}return{value:f.join(""),start:u,end:l}};return{eventHandler:i,enable:f,modify:u}}); \ No newline at end of file +"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"object"===("undefined"==typeof module?"undefined":_typeof(module))?module.exports=e():"function"==typeof define&&define.amd?define(e):window.smartNumberInputs=e()}(function(){function n(e){if(38===e.which||40===e.which){e.preventDefault();var t=e.currentTarget,n=t.value,o=t.selectionStart,r=t.selectionEnd,i=38===e.which?1:-1;e.shiftKey&&(i*=10);var f=l(n,o,r,i);t.value=f.value,t.setSelectionRange(f.start,f.end),function(e,t){if("createEvent"in document){var n=document.createEvent("HTMLEvents");n.initEvent(t,!1,!0),e.dispatchEvent(n)}else e.fireEvent("on"+t)}(t,"change")}}var a=/([^\-\w0-9]+)/,l=function(e,t,n,o){for(var r,i=e.split(a),f=null,l=null,u=0,c=0;c { it('should work with jQuery', async () => { await browser.url('/html/jQuery.html'); + const input = await browser.$('#input'); - assert.equal(await browser.getValue('#input'), '10'); + assert.equal(await input.getValue(), '10'); - await browser.click('#input'); + await input.click(); await browser.keys(['Up arrow']); - assert.equal(await browser.getValue('#input'), '11'); + assert.equal(await input.getValue(), '11'); }); }); diff --git a/test/browser/specs/vanilla.spec.js b/test/browser/specs/vanilla.spec.js index 25f41ef..04795e3 100644 --- a/test/browser/specs/vanilla.spec.js +++ b/test/browser/specs/vanilla.spec.js @@ -3,72 +3,83 @@ const assert = require('assert'); describe('vanilla', () => { it('should work with a single element', async () => { await browser.url('/html/vanilla.html'); + const input = await browser.$('#input'); - assert.equal(await browser.getValue('#input'), '10'); + assert.equal(await input.getValue(), '10'); - await browser.click('#input'); + await input.click(); await browser.keys(['Up arrow']); - assert.equal(await browser.getValue('#input'), '11'); + assert.equal(await input.getValue(), '11'); }); it('should work with an array of elements', async () => { await browser.url('/html/vanilla-array.html'); + const input1 = await browser.$('#input1'); + const input2 = await browser.$('#input2'); - assert.equal(await browser.getValue('#input1'), '10'); - assert.equal(await browser.getValue('#input2'), '20'); + assert.equal(await input1.getValue(), '10'); + assert.equal(await input2.getValue(), '20'); - await browser.click('#input1'); + await input1.click(); await browser.keys(['Up arrow']); - await browser.click('#input2'); + await input2.click(); await browser.keys(['Up arrow']); - assert.equal(await browser.getValue('#input1'), '11'); - assert.equal(await browser.getValue('#input2'), '21'); + assert.equal(await input1.getValue(), '11'); + assert.equal(await input2.getValue(), '21'); }); it('should work with a NodeList', async () => { await browser.url('/html/vanilla-NodeList.html'); + const input1 = await browser.$('#input1'); + const input2 = await browser.$('#input2'); - assert.equal(await browser.getValue('#input1'), '10'); - assert.equal(await browser.getValue('#input2'), '20'); + assert.equal(await input1.getValue(), '10'); + assert.equal(await input2.getValue(), '20'); - await browser.click('#input1'); + await input1.click(); await browser.keys(['Up arrow']); - await browser.click('#input2'); + await input2.click(); await browser.keys(['Up arrow']); - assert.equal(await browser.getValue('#input1'), '11'); - assert.equal(await browser.getValue('#input2'), '21'); + assert.equal(await input1.getValue(), '11'); + assert.equal(await input2.getValue(), '21'); }); it('should work with a HTMLCollection', async () => { await browser.url('/html/vanilla-HTMLCollection.html'); + const input1 = await browser.$('#input1'); + const input2 = await browser.$('#input2'); - assert.equal(await browser.getValue('#input1'), '10'); - assert.equal(await browser.getValue('#input2'), '20'); + assert.equal(await input1.getValue(), '10'); + assert.equal(await input2.getValue(), '20'); - await browser.click('#input1'); + await input1.click(); await browser.keys(['Up arrow']); - await browser.click('#input2'); + await input2.click(); await browser.keys(['Up arrow']); - assert.equal(await browser.getValue('#input1'), '11'); - assert.equal(await browser.getValue('#input2'), '21'); + assert.equal(await input1.getValue(), '11'); + assert.equal(await input2.getValue(), '21'); }); it('should not block event listeners', async () => { await browser.url('/html/vanilla-events.html'); + const keydownBefore = await browser.$('div=keydown-before'); + const onkeydown = await browser.$('div=onkeydown'); + const keydownAfter = await browser.$('div=keydown-after'); + const input = await browser.$('#input'); - assert.equal(await browser.isVisible('div=keydown-before'), false); - assert.equal(await browser.isVisible('div=onkeydown'), false); - assert.equal(await browser.isVisible('div=keydown-after'), false); + assert.equal(await keydownBefore.isDisplayed(), false); + assert.equal(await onkeydown.isDisplayed(), false); + assert.equal(await keydownAfter.isDisplayed(), false); - await browser.click('#input'); + await input.click(); await browser.keys(['Up arrow']); - assert.equal(await browser.isVisible('div=keydown-before'), true); - assert.equal(await browser.isVisible('div=onkeydown'), true); - assert.equal(await browser.isVisible('div=keydown-after'), true); + assert.equal(await keydownBefore.isDisplayed(), true); + assert.equal(await onkeydown.isDisplayed(), true); + assert.equal(await keydownAfter.isDisplayed(), true); }); }); diff --git a/test/browser/wdio.config.js b/test/browser/wdio.config.js index 8f46bf9..3bc7233 100644 --- a/test/browser/wdio.config.js +++ b/test/browser/wdio.config.js @@ -42,30 +42,33 @@ if (process.env.TRAVIS) { exports.config.sauceConnect = true; const commonCapabilities = { - platform: 'Windows 10', - build: process.env.TRAVIS_BUILD_NUMBER + build: process.env.TRAVIS_BUILD_NUMBER, + public: true }; exports.config.capabilities = [ { browserName: 'chrome', - version: '64.0' + platform: 'Windows 7', + version: '61' }, { browserName: 'firefox', - version: '58.0' + version: '52' }, { browserName: 'internet explorer', - version: '11.103' + platform: 'Windows 7', + version: '10.0' }, { browserName: 'MicrosoftEdge', - version: '15.15063' + platform: 'Windows 10', + version: '16.16299' }, { browserName: 'safari', platform: 'macOS 10.13', - version: '11.0' + version: '11.1' } ].map(specs => Object.assign({}, commonCapabilities, specs)); }