Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6631415

Browse files
author
Jeff Harrell
committed
+ options test case
1 parent 704a3ec commit 6631415

File tree

2 files changed

+33
-21
lines changed

2 files changed

+33
-21
lines changed

test/functional/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ <h2>Options button</h2>
262262
data-name="Buy now!"
263263
data-amount="1.00"
264264
data-option0="Color=Blue:8.00,Green:12.00,Red:10.00"
265-
data-option1="Size=Small,Medium,Large"
265+
data-option1="Size=Tiny,Small,Medium,Large,X-Large"
266266
>
267267
</script>
268268
</div>

test/functional/spec/test.js

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
/*jshint node:true, evil:true */
22
/*global describe:true, it:true, paypal:true, document:true, window:true, before:true, beforeEach:true */
33

4+
'use strict';
5+
6+
47
if (typeof window === 'undefined') {
58
var fs = require('fs'),
69
should = require('should'),
@@ -16,8 +19,6 @@ if (typeof window === 'undefined') {
1619
// Test the object's integrity
1720
describe('JavaScript API', function () {
1821

19-
'use strict';
20-
2122
var namespace;
2223

2324
before(function () {
@@ -44,8 +45,6 @@ describe('JavaScript API', function () {
4445
// Test the buttons counter object
4546
describe('Test page button counter', function () {
4647

47-
'use strict';
48-
4948
var buttons;
5049

5150
before(function () {
@@ -73,8 +72,6 @@ describe('Test page button counter', function () {
7372
// Test environments
7473
describe('Environments', function () {
7574

76-
'use strict';
77-
7875
var sandbox, www;
7976

8077
before(function () {
@@ -95,7 +92,6 @@ describe('Environments', function () {
9592

9693
// Test different forms
9794
describe('Form factors', function () {
98-
'use strict';
9995

10096
it('Should produce a valid form', function () {
10197
document.querySelectorAll('#buynow-sm form').length.should.equal(1);
@@ -115,8 +111,6 @@ describe('Form factors', function () {
115111
// Test editable fields
116112
describe('Editable buttons', function () {
117113

118-
'use strict';
119-
120114
var inputs;
121115

122116
before(function () {
@@ -132,19 +126,19 @@ describe('Editable buttons', function () {
132126
});
133127

134128
it('Should have a CSS class on the label', function () {
135-
inputs[0].parentNode.children[0].className.should.include('paypal-label');
129+
inputs[0].parentNode.className.should.include('paypal-label');
136130
});
137131

138132
it('Should have proper labels', function () {
139133
var labels = document.querySelectorAll('#buynow-editable label');
140134

141-
labels[0].textContent.should.equal('Item');
142-
labels[1].textContent.should.equal('Amount');
143-
labels[2].textContent.should.equal('Quantity');
135+
labels[0].textContent.replace(/^\s+/, '').replace(/\s+$/, '').should.equal('Item');
136+
labels[1].textContent.replace(/^\s+/, '').replace(/\s+$/, '').should.equal('Amount');
137+
labels[2].textContent.replace(/^\s+/, '').replace(/\s+$/, '').should.equal('Quantity');
144138
});
145139

146140
it('Should have a CSS class on the container', function () {
147-
inputs[0].parentNode.className.should.include('paypal-group');
141+
inputs[0].parentNode.parentNode.className.should.include('paypal-group');
148142
});
149143

150144
});
@@ -153,8 +147,6 @@ describe('Editable buttons', function () {
153147
// Test multi-language support
154148
describe('Multi-language button images', function () {
155149

156-
'use strict';
157-
158150
function testLanguage(locale, type, expected) {
159151
it('Should have a ' + locale + ' version of the ' + type + ' button', function () {
160152
var button = document.querySelector('#' + type + '-' + locale + ' button[type=submit] .paypal-button-content'),
@@ -173,8 +165,6 @@ describe('Multi-language button images', function () {
173165
// Test multiple button image sizes
174166
describe('Multiple button image sizes', function () {
175167

176-
'use strict';
177-
178168
function testSize(size, type, expected) {
179169
it('Should have a ' + size + ' version of ' + type + ' button', function () {
180170
var button = document.querySelector('#' + type + '-' + size + ' button[type=submit]'),
@@ -205,8 +195,6 @@ describe('Multiple button image sizes', function () {
205195
// Test button styles
206196
describe('Styled buttons', function () {
207197

208-
'use strict';
209-
210198
var primary, secondary;
211199

212200
before(function () {
@@ -223,3 +211,27 @@ describe('Styled buttons', function () {
223211
});
224212

225213
});
214+
215+
216+
describe('Options buttons', function () {
217+
var form = document.getElementById('button-options');
218+
var selects = form.getElementsByTagName('select');
219+
220+
it('Should have two selects', function () {
221+
selects.length.should.equal(2);
222+
});
223+
224+
it('Should have the right number of options per select', function () {
225+
selects[0].options.length.should.equal(3);
226+
selects[1].options.length.should.equal(5);
227+
});
228+
229+
it('Should have the right values per options', function () {
230+
selects[0].options[0].textContent.should.equal('Blue 8.00');
231+
selects[0].options[0].value.should.equal('Blue');
232+
233+
selects[1].options[0].textContent.should.equal('Tiny');
234+
selects[1].options[0].value.should.equal('Tiny');
235+
});
236+
237+
});

0 commit comments

Comments
 (0)