@@ -9,60 +9,63 @@ var fs = require('fs'),
99 document = jsdom ( testFile , null , jsdomOptions ) ,
1010 window = document . createWindow ( ) ;
1111
12+
1213eval ( fs . readFileSync ( 'src/paypal-button.js' ) . toString ( ) ) ;
1314
1415
1516// Test the object's integrity
16- describe ( 'PAYPAL.apps.ButtonFactory ' , function ( ) {
17+ describe ( 'JavaScript API ' , function ( ) {
1718 'use strict' ;
1819
19- it ( 'Should have a PAYPAL object ' , function ( ) {
20+ it ( 'Should have a PAYPAL namespace ' , function ( ) {
2021 PAYPAL . should . be . a ( 'object' ) ;
2122 } ) ;
2223
23- it ( 'Should have a PAYPAL.apps object ' , function ( ) {
24+ it ( 'Should have a PAYPAL.apps namespace ' , function ( ) {
2425 PAYPAL . apps . should . be . a ( 'object' ) ;
2526 } ) ;
2627
27- it ( 'Should have a PAYPAL.apps.ButtonFactory object ' , function ( ) {
28+ it ( 'Should have a PAYPAL.apps.ButtonFactory namespace ' , function ( ) {
2829 PAYPAL . apps . ButtonFactory . should . be . a ( 'object' ) ;
2930 } ) ;
3031
31- } ) ;
32-
33-
34- // Test the create method
35- describe ( 'PAYPAL.apps.ButtonFactory.create' , function ( ) {
36- 'use strict' ;
32+ it ( 'Should have a configuration object' , function ( ) {
33+ PAYPAL . apps . ButtonFactory . config . should . be . a ( 'object' ) ;
34+ } ) ;
3735
38- it ( 'Should be a function ' , function ( ) {
36+ it ( 'Should have a create method ' , function ( ) {
3937 PAYPAL . apps . ButtonFactory . create . should . be . a ( 'function' ) ;
4038 } ) ;
4139
42- it ( 'Should return false if no parameters' , function ( ) {
40+ it ( 'Create return false if no parameters' , function ( ) {
4341 var result = PAYPAL . apps . ButtonFactory . create ( ) ;
4442
4543 result . should . equal ( false ) ;
4644 } ) ;
45+
4746} ) ;
4847
4948
5049// Test the buttons counter object
51- describe ( 'PAYPAL.apps.ButtonFactory.buttons ' , function ( ) {
50+ describe ( 'Test page button counter ' , function ( ) {
5251
5352 'use strict' ;
5453
5554 var buttons = PAYPAL . apps . ButtonFactory . buttons ;
5655
57- it ( 'Should have four buy now buttons' , function ( ) {
56+ it ( 'Should have six buy now buttons' , function ( ) {
5857 buttons . buynow . should . equal ( 6 ) ;
5958 } ) ;
6059
61- it ( 'Should have three cart buttons' , function ( ) {
60+ it ( 'Should have two cart buttons' , function ( ) {
6261 buttons . cart . should . equal ( 2 ) ;
6362 } ) ;
6463
65- it ( 'Should have three hosted buttons' , function ( ) {
64+ it ( 'Should have two donation buttons' , function ( ) {
65+ buttons . donate . should . equal ( 2 ) ;
66+ } ) ;
67+
68+ it ( 'Should have two hosted buttons' , function ( ) {
6669 buttons . hosted . should . equal ( 2 ) ;
6770 } ) ;
6871
@@ -72,6 +75,30 @@ describe('PAYPAL.apps.ButtonFactory.buttons', function () {
7275} ) ;
7376
7477
78+ // Test editable fields
79+ describe ( 'Editable buttons' , function ( ) {
80+ 'use strict' ;
81+
82+ var inputs = document . querySelectorAll ( '#buynow-editable input[type="text"]' ) ;
83+
84+ it ( 'Should have two inputs' , function ( ) {
85+ inputs . length . should . equal ( 2 ) ;
86+ } ) ;
87+
88+ it ( 'Should have a CSS class on the input' , function ( ) {
89+ inputs [ 0 ] . className . should . include ( 'paypal-input' ) ;
90+ } ) ;
91+
92+ it ( 'Should have a CSS class on the label' , function ( ) {
93+ inputs [ 0 ] . parentNode . className . should . include ( 'paypal-label' ) ;
94+ } ) ;
95+
96+ it ( 'Should have a CSS class on the container' , function ( ) {
97+ inputs [ 0 ] . parentNode . parentNode . className . should . include ( 'paypal-group' ) ;
98+ } ) ;
99+
100+ } ) ;
101+
75102
76103// Test multi-language support
77104describe ( 'Multi-language button images' , function ( ) {
0 commit comments