11/*jshint node:true, evil:true */
22/*global describe:true, it:true, PAYPAL:true, document:true, window:true */
33
4-
54var fs = require ( 'fs' ) ,
65 should = require ( 'should' ) ,
76 jsdom = require ( 'jsdom' ) . jsdom ,
87 document = jsdom ( fs . readFileSync ( './test/index.html' ) . toString ( ) ) ,
98 window = document . createWindow ( ) ;
109
11-
1210eval ( fs . readFileSync ( 'src/paypal-button.js' ) . toString ( ) ) ;
1311
14-
15-
1612// Test the object's integrity
1713describe ( 'PAYPAL.apps.ButtonFactory' , function ( ) {
18- 'use strict' ;
1914
15+ 'use strict' ;
2016
2117 it ( 'Should have a PAYPAL object' , function ( ) {
2218 PAYPAL . should . be . a ( 'object' ) ;
@@ -30,14 +26,12 @@ describe('PAYPAL.apps.ButtonFactory', function () {
3026 PAYPAL . apps . ButtonFactory . should . be . a ( 'object' ) ;
3127 } ) ;
3228
33-
3429} ) ;
3530
36-
3731// Test the create method
3832describe ( 'PAYPAL.apps.ButtonFactory.create' , function ( ) {
39- 'use strict' ;
4033
34+ 'use strict' ;
4135
4236 it ( 'Should be a function' , function ( ) {
4337 PAYPAL . apps . ButtonFactory . create . should . be . a ( 'function' ) ;
@@ -49,7 +43,7 @@ describe('PAYPAL.apps.ButtonFactory.create', function () {
4943 result . should . equal ( false ) ;
5044 } ) ;
5145
52- it ( 'Should return an element if no parameters ' , function ( ) {
46+ it ( 'Should return an element' , function ( ) {
5347 var result = PAYPAL . apps . ButtonFactory . create ( {
5448 business : '6XF3MPZBZV6HU' ,
5549 item : 'Buy now' ,
@@ -58,5 +52,22 @@ describe('PAYPAL.apps.ButtonFactory.create', function () {
5852
5953 result . should . be . a ( 'object' ) ;
6054 } ) ;
55+ } ) ;
6156
57+ // Test the buttons counter object
58+ describe ( 'PAYPAL.apps.ButtonFactory.buttons' , function ( ) {
59+
60+ 'use strict' ;
61+
62+ it ( 'Should have two cart buttons' , function ( ) {
63+ var result = PAYPAL . apps . ButtonFactory . buttons . cart ;
64+
65+ result . should . equal ( 2 ) ;
66+ } ) ;
67+
68+ it ( 'Should have one QR code' , function ( ) {
69+ var result = PAYPAL . apps . ButtonFactory . buttons . qr ;
70+
71+ result . should . equal ( 1 ) ;
72+ } ) ;
6273} ) ;
0 commit comments