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
a9367db8
Commit
a9367db8
authored
Oct 27, 2017
by
jaebradley
Committed by
Jae Bradley
Oct 27, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
trailing spaces in price regex
parent
c58582c1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
ecommerce/static/js/pages/basket_page.js
+4
-3
ecommerce/static/js/test/specs/pages/basket_page_spec.js
+8
-2
No files found.
ecommerce/static/js/pages/basket_page.js
View file @
a9367db8
...
...
@@ -269,9 +269,9 @@ define([
},
generateLocalPriceText
:
function
(
usdPriceText
)
{
// Assumes price value is prefixed by $ or USD with optional sign
// Assumes price value is prefixed by $ or USD with optional sign
followed by optional string
var
localPriceText
=
usdPriceText
,
prefixMatch
=
localPriceText
.
match
(
/
(\$
|USD
)
.*
/
),
prefixMatch
=
localPriceText
.
match
(
/
(\$
|USD
)
?(([
1-9
][
0-9
]{0,2}(
,
[
0-9
]{3})
*
)
|
[
0-9
]
+
)?\.[
0-9
]{1,2}
/
),
entireMatch
,
groupMatch
,
startIndex
,
...
...
@@ -281,7 +281,8 @@ define([
entireMatch
=
prefixMatch
[
0
];
groupMatch
=
prefixMatch
[
1
];
startIndex
=
prefixMatch
.
index
;
priceValue
=
localPriceText
.
substring
(
startIndex
+
groupMatch
.
length
);
priceValue
=
localPriceText
.
substring
(
startIndex
+
groupMatch
.
length
,
startIndex
+
entireMatch
.
length
);
localPriceText
=
localPriceText
.
replace
(
entireMatch
,
BasketPage
.
formatToLocalPrice
(
groupMatch
,
priceValue
));
...
...
ecommerce/static/js/test/specs/pages/basket_page_spec.js
View file @
a9367db8
...
...
@@ -636,8 +636,14 @@ define([
it
(
'should replace commaseparated values'
,
function
()
{
spyOn
(
BasketPage
,
'formatToLocalPrice'
).
and
.
returnValue
(
'foo'
);
expect
(
'-foo'
).
toEqual
(
BasketPage
.
generateLocalPriceText
(
'-$1,234'
));
expect
(
BasketPage
.
formatToLocalPrice
).
toHaveBeenCalledWith
(
'$'
,
'1,234'
);
expect
(
'-foo'
).
toEqual
(
BasketPage
.
generateLocalPriceText
(
'-$1,234.56'
));
expect
(
BasketPage
.
formatToLocalPrice
).
toHaveBeenCalledWith
(
'$'
,
'1,234.56'
);
});
it
(
'should only replace currency value'
,
function
()
{
spyOn
(
BasketPage
,
'formatToLocalPrice'
).
and
.
returnValue
(
'foo'
);
expect
(
'baz -foo bar'
).
toEqual
(
BasketPage
.
generateLocalPriceText
(
'baz -$1,234.56 bar'
));
expect
(
BasketPage
.
formatToLocalPrice
).
toHaveBeenCalledWith
(
'$'
,
'1,234.56'
);
});
it
(
'should not replace text without USD values'
,
function
()
{
...
...
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