Skip to content

Commit 49cd8b5

Browse files
committed
Fixed bug where buttons with other languages werent rendering correctly. Removed testling and added back the old mocha tests.
1 parent 935a554 commit 49cd8b5

9 files changed

Lines changed: 53 additions & 74 deletions

File tree

dist/paypal-button-minicart.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/paypal-button.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@
66
"name": "Jeff Harrell",
77
"url": "https://github.com/jeffharrell/"
88
},
9-
"testling": {
10-
"browsers": ["ie6", "ie7", "ie8", "ie9", "firefox/15", "chrome/22", "opera/12", "safari/5.1"],
11-
"harness" : "mocha",
12-
"files": "test/browser.js"
13-
},
149
"dependencies": {},
1510
"devDependencies": {
1611
"grunt": "*",
17-
"mocha": "*",
12+
"mocha": "~1.7.4",
1813
"should": "*",
1914
"jsdom": "*"
2015
},
2116
"scripts": {
22-
"test": "mocha test/server.js"
17+
"test": "mocha"
2318
}
2419
}

src/paypal-button.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ PAYPAL.apps = PAYPAL.apps || {};
125125
btn = document.createElement('input'),
126126
hidden = document.createElement('input'),
127127
items = data.items,
128-
item, child, label, input, key;
128+
item, child, label, input, key, size, locale;
129129

130130
btn.type = 'image';
131131
hidden.type = 'hidden';
@@ -160,9 +160,12 @@ PAYPAL.apps = PAYPAL.apps || {};
160160

161161
form.appendChild(child);
162162
}
163+
164+
size = items.size && items.size.value;
165+
locale = items.lc && items.lc.value;
163166

164167
form.appendChild(btn);
165-
btn.src = getButtonImg(type, data.size, data.lc);
168+
btn.src = getButtonImg(type, size, locale);
166169

167170
// If the Mini Cart is present then register the form
168171
if (PAYPAL.apps.MiniCart && data.cmd === '_cart') {

test/browser.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

test/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h2>Buy Now (Spanish)</h2>
3333
data-button="buynow"
3434
data-name="Buy now!"
3535
data-amount="1.00"
36-
data-lang="en_US"
36+
data-lang="es_ES"
3737
></script>
3838
</div>
3939

@@ -44,7 +44,7 @@ <h2>Buy Now (Editable)</h2>
4444
data-name-editable="Buy now!"
4545
data-amount="1.00"
4646
data-quantity-editable="1"
47-
data-lang="es_ES"
47+
data-lang="en_US"
4848
></script>
4949
</div>
5050

test/index.html.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

test/server.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

test/test.js

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
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
513
describe('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
5048
describe('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
7472
describe('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
10199
describe('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

Comments
 (0)