|
3 | 3 |
|
4 | 4 | var fs = require('fs'), |
5 | 5 | should = require('should'), |
6 | | - jsdom = require('jsdom').jsdom, |
7 | | - document = jsdom(fs.readFileSync(__dirname + '/index.html').toString()), |
8 | | - window = document.createWindow(); |
| 6 | + jsdom = require('jsdom').jsdom; |
9 | 7 |
|
10 | | -eval(fs.readFileSync(__dirname + '/../src/paypal-button.js').toString()); |
| 8 | +global.document = jsdom(fs.readFileSync(__dirname + '/index.html').toString()); |
| 9 | +global.window = document.createWindow(); |
11 | 10 |
|
12 | | -// Test the object's integrity |
13 | | -describe('PAYPAL.apps.ButtonFactory', function () { |
14 | | - |
15 | | - 'use strict'; |
16 | | - |
17 | | - it('Should have a PAYPAL object', function () { |
18 | | - PAYPAL.should.be.a('object'); |
19 | | - }); |
20 | | - |
21 | | - it('Should have a PAYPAL.apps object', function () { |
22 | | - PAYPAL.apps.should.be.a('object'); |
23 | | - }); |
24 | | - |
25 | | - it('Should have a PAYPAL.apps.ButtonFactory object', function () { |
26 | | - PAYPAL.apps.ButtonFactory.should.be.a('object'); |
27 | | - }); |
28 | | - |
29 | | -}); |
30 | | - |
31 | | -// Test the create method |
32 | | -describe('PAYPAL.apps.ButtonFactory.create', function () { |
33 | | - |
34 | | - 'use strict'; |
35 | | - |
36 | | - it('Should be a function', function () { |
37 | | - PAYPAL.apps.ButtonFactory.create.should.be.a('function'); |
38 | | - }); |
39 | | - |
40 | | - it('Should return false if no parameters', function () { |
41 | | - var result = PAYPAL.apps.ButtonFactory.create(); |
42 | | - |
43 | | - result.should.equal(false); |
44 | | - }); |
45 | | - |
46 | | - it('Should return an element', function () { |
47 | | - var result = PAYPAL.apps.ButtonFactory.create({ |
48 | | - business: '6XF3MPZBZV6HU', |
49 | | - item: 'Buy now', |
50 | | - amount: '1.00' |
51 | | - }); |
52 | | - |
53 | | - result.should.be.a('object'); |
54 | | - }); |
55 | | -}); |
56 | | - |
57 | | -// Test the buttons counter object |
58 | | -describe('PAYPAL.apps.ButtonFactory.buttons', function () { |
59 | | - |
60 | | - 'use strict'; |
61 | | - |
62 | | - it('Should have three buy now buttons', function () { |
63 | | - var result = PAYPAL.apps.ButtonFactory.buttons.buynow; |
64 | | - |
65 | | - result.should.equal(3); |
66 | | - }); |
67 | | - |
68 | | - it('Should have six cart buttons', function () { |
69 | | - var result = PAYPAL.apps.ButtonFactory.buttons.cart; |
70 | | - |
71 | | - result.should.equal(6); |
72 | | - }); |
73 | | - |
74 | | - it('Should have one QR code', function () { |
75 | | - var result = PAYPAL.apps.ButtonFactory.buttons.qr; |
76 | | - |
77 | | - result.should.equal(1); |
78 | | - }); |
79 | | -}); |
80 | | - |
81 | | -// Test multi-language support |
82 | | -describe('Multi-language button images', function () { |
83 | | - |
84 | | - 'use strict'; |
85 | | - |
86 | | - it('Should have a spanish version of Buy Now button', function () { |
87 | | - var spanishButton = document.getElementById('buynowSpanish'), |
88 | | - spanishImage = spanishButton.getElementsByTagName('input')[0].src; |
89 | | - |
90 | | - spanishImage.should.include('es_ES'); |
91 | | - }); |
92 | | - |
93 | | - it('Should have a french version of Cart button', function () { |
94 | | - var frenchButton = document.getElementById('cartFrench'), |
95 | | - frenchImage = frenchButton.getElementsByTagName('input')[0].src; |
96 | | - |
97 | | - frenchImage.should.include('fr_FR'); |
98 | | - }); |
99 | | - |
100 | | - it('Should have a german version of Hosted button', function () { |
101 | | - var germanButton = document.getElementById('hostedGerman'), |
102 | | - germanImage = germanButton.getElementsByTagName('input')[0].src; |
103 | | - |
104 | | - germanImage.should.include('de_DE'); |
105 | | - }); |
106 | | -}); |
107 | | - |
108 | | -// Test multiple button image sizes |
109 | | -describe('Multiple button image sizes', function () { |
110 | | - |
111 | | - 'use strict'; |
112 | | - |
113 | | - it('Should have a small version of Buy Now button', function () { |
114 | | - var buynowSmallButton = document.getElementById('buynowSmall'), |
115 | | - buynowSmallImg = buynowSmallButton.getElementsByTagName('input')[0].src; |
116 | | - |
117 | | - buynowSmallImg.should.include('SM'); |
118 | | - }); |
119 | | - |
120 | | - it('Should have a small version of Cart button', function () { |
121 | | - var cartSmallButton = document.getElementById('cartSmall'), |
122 | | - cartSmallImg = cartSmallButton.getElementsByTagName('input')[0].src; |
123 | | - |
124 | | - cartSmallImg.should.include('SM'); |
125 | | - }); |
126 | | - |
127 | | - it('Should have a small version of Hosted button', function () { |
128 | | - var hostedSmallButton = document.getElementById('hostedSmall'), |
129 | | - hostedSmallImg = hostedSmallButton.getElementsByTagName('input')[0].src; |
130 | | - |
131 | | - hostedSmallImg.should.include('SM'); |
132 | | - }); |
133 | | -}); |
| 11 | +require('./test.js'); |
0 commit comments