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+
47if ( 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
1720describe ( '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
4546describe ( '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
7473describe ( '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
9794describe ( '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
116112describe ( '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
154148describe ( '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
174166describe ( '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
206196describe ( '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