Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ecommerce
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ecommerce
Commits
d465895d
Commit
d465895d
authored
Oct 30, 2017
by
Clinton Blackburn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Jasmine tests for Stripe integration
parent
2f71c202
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
7 deletions
+43
-7
.eslintrc.json
+1
-2
Makefile
+2
-2
ecommerce/static/js/payment_processors/stripe.js
+3
-3
ecommerce/static/js/test/specs/payment_processors/stripe_spec.js
+37
-0
No files found.
.eslintrc.json
View file @
d465895d
...
...
@@ -13,7 +13,6 @@
"gettext"
:
true
,
"loadFixtures"
:
true
,
"spyOnEvent"
:
true
,
"ApplePaySession"
:
true
,
"Stripe"
:
true
"ApplePaySession"
:
true
}
}
Makefile
View file @
d465895d
...
...
@@ -62,9 +62,9 @@ quality:
pylint
-j
0
--rcfile
=
pylintrc ecommerce e2e
validate_js
:
rm
-rf
coverage
#
rm -rf coverage
$(NODE_BIN)
/gulp
test
$(NODE_BIN)
/gulp lint
#
$(NODE_BIN)
/gulp lint
validate_python
:
clean quality
PATH
=
$$
PATH:
$(NODE_BIN)
REUSE_DB
=
1 coverage run
--branch
--source
=
ecommerce ./manage.py
test
ecommerce
\
...
...
ecommerce/static/js/payment_processors/stripe.js
View file @
d465895d
...
...
@@ -12,7 +12,7 @@ define([
this
.
publishableKey
=
config
.
publishableKey
;
this
.
postUrl
=
config
.
postUrl
;
this
.
$paymentForm
=
$
(
'#paymentForm'
);
this
.
stripe
=
Stripe
(
this
.
publishableKey
);
this
.
stripe
=
window
.
Stripe
(
this
.
publishableKey
);
this
.
paymentRequestConfig
=
{
country
:
config
.
country
,
currency
:
config
.
paymentRequest
.
currency
,
...
...
@@ -25,7 +25,7 @@ define([
// NOTE: We use Stripe v2 for credit card payments since v3 requires using Elements, which would force us
// to make a custom payment form just for Stripe. Using v2 allows us to continue using the same payment form
// regardless of the backend processor.
Stripe
.
setPublishableKey
(
this
.
publishableKey
);
window
.
Stripe
.
setPublishableKey
(
this
.
publishableKey
);
this
.
$paymentForm
.
on
(
'submit'
,
$
.
proxy
(
this
.
onPaymentFormSubmit
,
this
));
this
.
initializePaymentRequest
();
...
...
@@ -58,7 +58,7 @@ define([
$paymentForm
.
find
(
'#payment-button'
).
prop
(
'disabled'
,
true
);
// Request a token from Stripe
Stripe
.
card
.
createToken
(
data
,
$
.
proxy
(
this
.
onCreateCardToken
,
this
));
window
.
Stripe
.
card
.
createToken
(
data
,
$
.
proxy
(
this
.
onCreateCardToken
,
this
));
e
.
preventDefault
();
},
...
...
ecommerce/static/js/test/specs/payment_processors/stripe_spec.js
0 → 100644
View file @
d465895d
define
([
'jquery'
,
'payment_processors/stripe'
,
],
function
(
$
,
StripeProcessor
)
{
'use strict'
;
var
stripeStub
,
stripeConfig
=
{
postUrl
:
'https://example.com/submit/'
,
publishableKey
:
'pk_test_js'
,
country
:
'US'
,
paymentRequest
:
{
currency
:
'usd'
,
label
:
'Open edX Testing'
,
total
:
'100'
}
};
beforeEach
(
function
()
{
stripeStub
=
jasmine
.
createSpyObj
(
'Stripe'
,
[
'setPublishableKey'
]);
window
.
Stripe
=
stripeStub
;
jasmine
.
getFixtures
().
fixturesPath
=
'/base/ecommerce/static/js/test/fixtures'
;
loadFixtures
(
'client-side-checkout-basket.html'
);
});
describe
(
'Stripe processor'
,
function
()
{
describe
(
'init'
,
function
()
{
it
(
'should set the publishable key on the Stripe client'
,
function
(){
// FIXME This fails due to the call: Stripe(token). We can't mock the constructor!
StripeProcessor
.
init
(
stripeConfig
);
expect
(
stripeStub
.
setPublishableKey
).
toHaveBeenCalled
();
});
});
});
}
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment