1- var PAYPAL = require ( '../src/paypal-button.js' ) ;
2- require ( 'should' ) ;
1+ /*jshint node:true, evil:true */
2+ /*global describe:true, it:true, PAYPAL:true, document:true, window:true */
3+
4+ var fs = require ( 'fs' ) ,
5+ should = require ( 'should' ) ,
6+ jsdom = require ( 'jsdom' ) . jsdom ,
7+ document = jsdom ( fs . readFileSync ( './test/index.html' ) . toString ( ) ) ,
8+ window = document . createWindow ( ) ;
9+
10+ eval ( fs . readFileSync ( 'src/paypal-button.js' ) . toString ( ) ) ;
311
412// Test the object's integrity
513describe ( 'PAYPAL.apps.ButtonFactory' , function ( ) {
@@ -34,92 +42,82 @@ describe('PAYPAL.apps.ButtonFactory.create', function () {
3442
3543 result . should . equal ( false ) ;
3644 } ) ;
37-
38- it ( 'Should return an element' , function ( ) {
39- var result = PAYPAL . apps . ButtonFactory . create ( {
40- business : '6XF3MPZBZV6HU' ,
41- item : 'Buy now' ,
42- amount : '1.00'
43- } ) ;
44-
45- result . should . be . a ( 'object' ) ;
46- } ) ;
4745} ) ;
4846
4947// Test the buttons counter object
5048describe ( 'PAYPAL.apps.ButtonFactory.buttons' , function ( ) {
51-
49+
5250 'use strict' ;
53-
54- it ( 'Should have three buy now buttons' , function ( ) {
55- var result = PAYPAL . apps . ButtonFactory . buttons . buynow ;
56-
57- result . should . equal ( 4 ) ;
51+
52+ var buttons = PAYPAL . apps . ButtonFactory . buttons ;
53+
54+ it ( 'Should have four buy now buttons' , function ( ) {
55+ buttons . buynow . should . equal ( 4 ) ;
5856 } ) ;
59-
60- it ( 'Should have six cart buttons' , function ( ) {
61- var result = PAYPAL . apps . ButtonFactory . buttons . cart ;
62-
63- result . should . equal ( 6 ) ;
57+
58+ it ( 'Should have three cart buttons' , function ( ) {
59+ buttons . cart . should . equal ( 3 ) ;
6460 } ) ;
65-
61+
62+ it ( 'Should have three hosted buttons' , function ( ) {
63+ buttons . hosted . should . equal ( 3 ) ;
64+ } ) ;
65+
6666 it ( 'Should have one QR code' , function ( ) {
67- var result = PAYPAL . apps . ButtonFactory . buttons . qr ;
68-
69- result . should . equal ( 1 ) ;
67+ buttons . qr . should . equal ( 1 ) ;
7068 } ) ;
7169} ) ;
7270
7371// Test multi-language support
7472describe ( 'Multi-language button images' , function ( ) {
75-
73+
7674 'use strict' ;
77-
75+
7876 it ( 'Should have a spanish version of Buy Now button' , function ( ) {
7977 var spanishButton = document . getElementById ( 'buynowSpanish' ) ,
8078 spanishImage = spanishButton . getElementsByTagName ( 'input' ) [ 0 ] . src ;
81-
79+
8280 spanishImage . should . include ( 'es_ES' ) ;
8381 } ) ;
84-
82+
8583 it ( 'Should have a french version of Cart button' , function ( ) {
8684 var frenchButton = document . getElementById ( 'cartFrench' ) ,
8785 frenchImage = frenchButton . getElementsByTagName ( 'input' ) [ 0 ] . src ;
88-
86+
8987 frenchImage . should . include ( 'fr_FR' ) ;
9088 } ) ;
91-
89+
9290 it ( 'Should have a german version of Hosted button' , function ( ) {
9391 var germanButton = document . getElementById ( 'hostedGerman' ) ,
9492 germanImage = germanButton . getElementsByTagName ( 'input' ) [ 0 ] . src ;
95-
93+
9694 germanImage . should . include ( 'de_DE' ) ;
9795 } ) ;
9896} ) ;
9997
10098// Test multiple button image sizes
10199describe ( 'Multiple button image sizes' , function ( ) {
102-
100+
103101 'use strict' ;
104-
102+
105103 it ( 'Should have a small version of Buy Now button' , function ( ) {
106104 var buynowSmallButton = document . getElementById ( 'buynowSmall' ) ,
107105 buynowSmallImg = buynowSmallButton . getElementsByTagName ( 'input' ) [ 0 ] . src ;
108-
106+
109107 buynowSmallImg . should . include ( 'SM' ) ;
110108 } ) ;
111-
109+
112110 it ( 'Should have a small version of Cart button' , function ( ) {
113111 var cartSmallButton = document . getElementById ( 'cartSmall' ) ,
114112 cartSmallImg = cartSmallButton . getElementsByTagName ( 'input' ) [ 0 ] . src ;
115-
113+
116114 cartSmallImg . should . include ( 'SM' ) ;
117115 } ) ;
118-
116+
119117 it ( 'Should have a small version of Hosted button' , function ( ) {
120118 var hostedSmallButton = document . getElementById ( 'hostedSmall' ) ,
121119 hostedSmallImg = hostedSmallButton . getElementsByTagName ( 'input' ) [ 0 ] . src ;
122-
120+
123121 hostedSmallImg . should . include ( 'SM' ) ;
124122 } ) ;
125- } ) ;
123+ } ) ;
0 commit comments