2020-02-25 11:36:53 +00:00
/ * *
* Internal dependencies
* /
import {
getCartData ,
getCartTotals ,
getCartMeta ,
getCartErrors ,
isApplyingCoupon ,
getCouponBeingApplied ,
isRemovingCoupon ,
getCouponBeingRemoved ,
} from '../selectors' ;
const state = {
cartData : {
coupons : [
{
code : 'test' ,
totals : {
currency _code : 'GBP' ,
currency _symbol : '£' ,
currency _minor _unit : 2 ,
currency _decimal _separator : '.' ,
currency _thousand _separator : ',' ,
currency _prefix : '£' ,
currency _suffix : '' ,
total _discount : '583' ,
total _discount _tax : '117' ,
} ,
} ,
] ,
items : [
{
key : '1f0e3dad99908345f7439f8ffabdffc4' ,
id : 19 ,
quantity : 1 ,
name : 'Album' ,
short _description : '<p>This is a simple, virtual product.</p>' ,
description :
'<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sagittis orci ac odio dictum tincidunt. Donec ut metus leo. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Sed luctus, dui eu sagittis sodales, nulla nibh sagittis augue, vel porttitor diam enim non metus. Vestibulum aliquam augue neque. Phasellus tincidunt odio eget ullamcorper efficitur. Cras placerat ut turpis pellentesque vulputate. Nam sed consequat tortor. Curabitur finibus sapien dolor. Ut eleifend tellus nec erat pulvinar dignissim. Nam non arcu purus. Vivamus et massa massa.</p>' ,
sku : 'woo-album' ,
low _stock _remaining : null ,
permalink : 'http://local.wordpress.test/product/album/' ,
images : [
{
id : 48 ,
2022-06-15 09:56:52 +00:00
src : 'http://local.wordpress.test/wp-content/uploads/2019/12/album-1.jpg' ,
2020-02-25 11:36:53 +00:00
thumbnail :
'http://local.wordpress.test/wp-content/uploads/2019/12/album-1-324x324.jpg' ,
2022-06-15 09:56:52 +00:00
srcset : 'http://local.wordpress.test/wp-content/uploads/2019/12/album-1.jpg 800w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-324x324.jpg 324w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-100x100.jpg 100w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-416x416.jpg 416w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-300x300.jpg 300w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-150x150.jpg 150w, http://local.wordpress.test/wp-content/uploads/2019/12/album-1-768x768.jpg 768w' ,
2020-02-25 11:36:53 +00:00
sizes : '(max-width: 800px) 100vw, 800px' ,
name : 'album-1.jpg' ,
alt : '' ,
} ,
] ,
variation : [ ] ,
totals : {
currency _code : 'GBP' ,
currency _symbol : '£' ,
currency _minor _unit : 2 ,
currency _decimal _separator : '.' ,
currency _thousand _separator : ',' ,
currency _prefix : '£' ,
currency _suffix : '' ,
line _subtotal : '1250' ,
line _subtotal _tax : '250' ,
line _total : '1000' ,
line _total _tax : '200' ,
} ,
} ,
{
key : '6512bd43d9caa6e02c990b0a82652dca' ,
id : 11 ,
quantity : 1 ,
name : 'Beanie' ,
short _description : '<p>This is a simple product.</p>' ,
description :
'<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.</p>' ,
sku : 'woo-beanie' ,
low _stock _remaining : null ,
permalink : 'http://local.wordpress.test/product/beanie/' ,
images : [
{
id : 40 ,
2022-06-15 09:56:52 +00:00
src : 'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2.jpg' ,
2020-02-25 11:36:53 +00:00
thumbnail :
'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-324x324.jpg' ,
2022-06-15 09:56:52 +00:00
srcset : 'http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2.jpg 801w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-324x324.jpg 324w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-100x100.jpg 100w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-416x416.jpg 416w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-300x300.jpg 300w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-150x150.jpg 150w, http://local.wordpress.test/wp-content/uploads/2019/12/beanie-2-768x768.jpg 768w' ,
2020-02-25 11:36:53 +00:00
sizes : '(max-width: 801px) 100vw, 801px' ,
name : 'beanie-2.jpg' ,
alt : '' ,
} ,
] ,
variation : [ ] ,
totals : {
currency _code : 'GBP' ,
currency _symbol : '£' ,
currency _minor _unit : 2 ,
currency _decimal _separator : '.' ,
currency _thousand _separator : ',' ,
currency _prefix : '£' ,
currency _suffix : '' ,
line _subtotal : '1667' ,
line _subtotal _tax : '333' ,
line _total : '1333' ,
line _total _tax : '267' ,
} ,
} ,
] ,
items _count : 2 ,
items _weight : 0 ,
2020-04-09 14:01:11 +00:00
needs _payment : true ,
2020-02-25 11:36:53 +00:00
needs _shipping : true ,
totals : {
currency _code : 'GBP' ,
currency _symbol : '£' ,
currency _minor _unit : 2 ,
currency _decimal _separator : '.' ,
currency _thousand _separator : ',' ,
currency _prefix : '£' ,
currency _suffix : '' ,
total _items : '2917' ,
total _items _tax : '583' ,
total _fees : '0' ,
total _fees _tax : '0' ,
total _discount : '583' ,
total _discount _tax : '117' ,
total _shipping : '2000' ,
total _shipping _tax : '400' ,
total _price : '5200' ,
total _tax : '867' ,
tax _lines : [
{
name : 'Tax' ,
price : '867' ,
} ,
] ,
} ,
} ,
metaData : {
applyingCoupon : 'test-coupon' ,
removingCoupon : 'test-coupon2' ,
} ,
errors : [
{
code : '100' ,
message : 'Test Error' ,
data : { } ,
} ,
] ,
} ;
describe ( 'getCartData' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( getCartData ( state ) ) . toEqual ( state . cartData ) ;
} ) ;
} ) ;
describe ( 'getCartTotals' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( getCartTotals ( state ) ) . toEqual ( state . cartData . totals ) ;
} ) ;
} ) ;
describe ( 'getCartMeta' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( getCartMeta ( state ) ) . toEqual ( state . metaData ) ;
} ) ;
} ) ;
describe ( 'getCartErrors' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( getCartErrors ( state ) ) . toEqual ( state . errors ) ;
} ) ;
} ) ;
describe ( 'isApplyingCoupon' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( isApplyingCoupon ( state ) ) . toEqual ( true ) ;
} ) ;
} ) ;
describe ( 'getCouponBeingApplied' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( getCouponBeingApplied ( state ) ) . toEqual (
state . metaData . applyingCoupon
) ;
} ) ;
} ) ;
describe ( 'isRemovingCoupon' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( isRemovingCoupon ( state ) ) . toEqual ( true ) ;
} ) ;
} ) ;
describe ( 'getCouponBeingRemoved' , ( ) => {
it ( 'returns expected values for items existing in state' , ( ) => {
expect ( getCouponBeingRemoved ( state ) ) . toEqual (
state . metaData . removingCoupon
) ;
} ) ;
} ) ;