peteshow 0.7.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/tests/index.html ADDED
@@ -0,0 +1,58 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset='utf-8'>
5
+ <title>Peteshow.js Tests</title>
6
+ <link rel='stylesheet' href='../vendor/qunit/qunit.css'>
7
+ <link rel='stylesheet' href='../src/css/peteshow.css'>
8
+ </head>
9
+ <body>
10
+ <div id='qunit'></div>
11
+ <div id='qunit-fixture'>
12
+ <form class='registration'>
13
+ <input name='password' type='password' />
14
+ <input name='text' type='text' />
15
+ <input name='email' type='email' />
16
+ <input name='number' type='number' >
17
+ <input name='decimal' type='text' >
18
+ <input name='number' type='text' >
19
+ <input name='date' type='text' />
20
+ <input name='phone' type='text' />
21
+ <input name='tel' type='tel' >
22
+ <input name='first_name' type='text /'>
23
+ <input name='last_name' type='text /'>
24
+ <input name='company' type='text /'>
25
+ <input name='street' type='text /'>
26
+ <input name='line2' type='text /'>
27
+ <input name='city' type='text /'>
28
+ <input name='zip' type='text /'>
29
+ <input name='county' type='text /'>
30
+ <input name='postal' type='text /'>
31
+ <input name='state' type='text /'>
32
+ <input name='job_title' type='text /'>
33
+ <input name='intent' type='text /'>
34
+ <input name='income' type='text /'>
35
+ <input name='routing' type='text /'>
36
+ <input name='card_type_cd' type='text /'>
37
+ <input name='card_number' type='text /'>
38
+ <input name='cvv' type='text /'>
39
+ </form>
40
+ </div>
41
+ <div class='scripts'>
42
+ <script src='../vendor/qunit/qunit.js'></script>
43
+ <script src='../vendor/qunit/jquery.js'></script>
44
+
45
+ <script src='../vendor/faker.js'></script>
46
+ <script src='../vendor/jquery.formatdatetime.js'></script>
47
+
48
+ <script src='../src/peteshow.js'></script>
49
+ <script src='../src/peteshow-core.js'></script>
50
+ <script src='../src/peteshow-helpers.js'></script>
51
+ <script src='../vendor/peteshow.plugin.js'></script>
52
+
53
+ <script src='./suite/core.js'></script>
54
+ <script src='./suite/helpers.js'></script>
55
+ <script src='./suite/keybindings.js'></script>
56
+ </div>
57
+ </body>
58
+ </html>
@@ -0,0 +1,49 @@
1
+ QUnit.test('peteshow dom setup', function(assert) {
2
+ assert.equal(1, $('form').length, 'form exists')
3
+ assert.equal(1, $('#peteshow').length, 'peteshow exists')
4
+ });
5
+
6
+ QUnit.test('fill out form functionality', function(assert) {
7
+ Peteshow.fillOutForms();
8
+
9
+ NUMBER_REGEX = /^[0-9]*$/
10
+ TEXT_REGEX = /^[a-zA-Z0-9.,\/_ -]+$/
11
+ EMAIL_REGEX = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,6}$/i
12
+ DATE_REGEX = /^\d{2}([\//-])\d{2}\1\d{4}$/
13
+ PHONE_NUMBER_REGEX = /\(\d{3}\)\d{3}-\d{4}/
14
+
15
+ // from plugin
16
+ assert.equal('PL25 3JR', $('input[name*=zip]').val(), 'rule loaded from plugin, string');
17
+ assert.equal(true, TEXT_REGEX.test($('input[name*=county]').val()), 'rule loaded from plugin, function');
18
+
19
+ // from defaults
20
+ var fields = {
21
+ 'input[type=password]' : 'password',
22
+ 'input[type=text]' : TEXT_REGEX,
23
+ 'input[type=email], input[name*=email]' : EMAIL_REGEX,
24
+ 'input[name*=number], input[type=number]' : NUMBER_REGEX,
25
+ 'input[name*=date]' : DATE_REGEX,
26
+ 'input[name*=phone]' : PHONE_NUMBER_REGEX,
27
+ 'input[name*=first_name]' : TEXT_REGEX,
28
+ 'input[name*=last_name]' : TEXT_REGEX,
29
+ 'input[name*=company]' : TEXT_REGEX,
30
+ 'input[name*=street], input[name*=line1]' : TEXT_REGEX,
31
+ 'input[name*=line2], input[name*=suite]' : TEXT_REGEX,
32
+ 'input[name*=city]' : TEXT_REGEX,
33
+ 'input[name*=state]' : TEXT_REGEX,
34
+ 'input[name*=job_title]' : TEXT_REGEX,
35
+ 'input[name*=intent]' : TEXT_REGEX,
36
+ 'input[name*=income], input[name*=amount]' : NUMBER_REGEX,
37
+ 'input[name*=branch], input[name*=routing]' : '400001',
38
+ 'input[name*=card_type_cd]' : '001',
39
+ 'input[name*=card_number]' : '4111111111111111',
40
+ 'input[name*=cvv]' : '123',
41
+ }
42
+
43
+ $.each(fields, function(k,v) {
44
+ if(v.hasOwnProperty('source'))
45
+ assert.equal(true, v.test($(k).val()), 'testing ' + k + ' regex');
46
+ else
47
+ assert.equal(v, $(k).val(), 'testing ' + k + ' string');
48
+ });
49
+ });
@@ -0,0 +1,18 @@
1
+ QUnit.test('peteshow functions exist', function(assert) {
2
+ assert.equal(true, $.isPlainObject(Peteshow), 'window.Peteshow exists');
3
+
4
+ // helpers exist
5
+ assert.equal(true, $.isFunction(Peteshow.randomChars), 'randomChars helper is a function');
6
+ assert.equal(true, $.isFunction(Peteshow.randomLetters), 'randomLetershelper is a function');
7
+ assert.equal(true, $.isFunction(Peteshow.randomNumberRange), 'randomNumberRange helper is a function');
8
+ assert.equal(true, $.isFunction(Peteshow.randomNumber), 'randomNumber helper is a function');
9
+ assert.equal(true, $.isFunction(Peteshow.randomDate), 'randomDate helper is a function');
10
+ assert.equal(true, $.isFunction(Peteshow.randomEmail), 'randomEmail helper is a function');
11
+ assert.equal(true, $.isFunction(Peteshow.formatDate), 'formatDate helper is a function');
12
+
13
+ // core exists
14
+ assert.equal(true, $.isFunction(Peteshow.init), 'init helper is a function');
15
+ assert.equal(true, $.isFunction(Peteshow.fillOutForms), 'fillOutForms helper is a function');
16
+ assert.equal(true, $.isFunction(Peteshow.submitForm), 'submitForm helper is a function');
17
+ });
18
+
@@ -0,0 +1,13 @@
1
+ QUnit.test('keybindings work', function(assert) {
2
+ var event = $.Event('keydown');
3
+
4
+ event.keyCode = 192;
5
+ $(document).trigger(event);
6
+
7
+ assert.equal(true, $('#peteshow').hasClass('active'), 'div is shown when backtick is hit');
8
+
9
+ event.keyCode = 72;
10
+ $(document).trigger(event);
11
+
12
+ assert.equal(false, $('#peteshow').is(':visible'), 'div is hidden when H is hit for hide');
13
+ });