Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tipsi-shared
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Denis Sedura
tipsi-shared
Commits
9d3c6c2d
Commit
9d3c6c2d
authored
Dec 25, 2017
by
Dmytro Zavgorodniy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[RNA-761] Add latest utils
parent
e272b493
Changes
40
Hide whitespace changes
Inline
Side-by-side
Showing
40 changed files
with
1888 additions
and
145 deletions
+1888
-145
drinkInventoryFormatter.test.js
utils/__tests__/drinkInventoryFormatter.test.js
+198
-0
getDetailedOrderStatusData.test.js
utils/__tests__/getDetailedOrderStatusData.test.js
+11
-1
getOrderProductsCategories.test.js
utils/__tests__/getOrderProductsCategories.test.js
+40
-0
handleOrderStatus.test.js
utils/__tests__/handleOrderStatus.test.js
+211
-0
userFormatter.test.js
utils/__tests__/userFormatter.test.js
+148
-0
wineInventoryFormatter.test.js
utils/__tests__/wineInventoryFormatter.test.js
+290
-0
createRouteURL.js
utils/createRouteURL.js
+2
-2
deliveryTypes.bfw.js
utils/deliveryTypes/deliveryTypes.bfw.js
+10
-0
deliveryTypes.cw.js
utils/deliveryTypes/deliveryTypes.cw.js
+0
-9
deliveryTypes.js
utils/deliveryTypes/deliveryTypes.js
+2
-3
androidPayOrderFormatter.test.js
utils/formatters/__tests__/androidPayOrderFormatter.test.js
+103
-0
applePayOrderFormatter.test.js
utils/formatters/__tests__/applePayOrderFormatter.test.js
+61
-0
orderFormatter.test.js
utils/formatters/__tests__/orderFormatter.test.js
+75
-0
orderProductFormatter.test.js
utils/formatters/__tests__/orderProductFormatter.test.js
+102
-0
storeFormatter.test.js
utils/formatters/__tests__/storeFormatter.test.js
+44
-0
androidPayOrderFormatter.js
utils/formatters/androidPayOrderFormatter.js
+36
-12
applePayOrderFormatter.js
utils/formatters/applePayOrderFormatter.js
+22
-10
deliveryInfoFormatter.js
utils/formatters/deliveryInfoFormatter.js
+11
-0
drinkInventoryFormatter.js
utils/formatters/drinkInventoryFormatter.js
+12
-4
orderFormatter.js
utils/formatters/orderFormatter.js
+8
-5
orderProductFormatter.js
utils/formatters/orderProductFormatter.js
+10
-1
storeFormatter.js
utils/formatters/storeFormatter.js
+1
-1
userFormatter.js
utils/formatters/userFormatter.js
+6
-3
wineFormatter.js
utils/formatters/wineFormatter.js
+5
-5
wineInventoryFormatter.js
utils/formatters/wineInventoryFormatter.js
+13
-5
getDetailedOrderStatusData.js
utils/getDetailedOrderStatusData.js
+6
-1
getFBProfile.js
utils/getFBProfile.js
+6
-2
getOrderProductsCategories.js
utils/getOrderProductsCategories.js
+15
-0
handleErrorAlert.js
utils/handleErrorAlert.js
+1
-4
index.js
utils/handleOrderStatus/index.js
+18
-7
isDeliveryPossible.bfw.js
utils/isDeliveryPossible.bfw.js
+31
-0
isDeliveryPossible.js
utils/isDeliveryPossible.js
+3
-0
scheduleStatus.test.js
utils/scheduleStatus/__tests__/scheduleStatus.test.js
+266
-0
getStatus.bfw.js
utils/scheduleStatus/getStatus.bfw.js
+0
-3
getStatus.js
utils/scheduleStatus/getStatus.js
+4
-8
scheduleStatus.js
utils/scheduleStatus/scheduleStatus.js
+5
-5
sortStoresByDistance.js
utils/sortStoresByDistance.js
+2
-2
Theme.bd.js
utils/styles/Theme/Theme.bd.js
+44
-18
Theme.bfw.js
utils/styles/Theme/Theme.bfw.js
+29
-16
Theme.cw.js
utils/styles/Theme/Theme.cw.js
+37
-18
No files found.
utils/__tests__/drinkInventoryFormatter.test.js
0 → 100644
View file @
9d3c6c2d
import
{
drinkInventoryFormatter
}
from
'
../formatters
'
describe
(
'
drinkInventoryFormatter
'
,
()
=>
{
const
defaultInventory
=
{}
const
defaultExpectedResult
=
{
batchPrice
:
undefined
,
id
:
undefined
,
price
:
null
,
oldPrice
:
null
,
priceRaw
:
undefined
,
specialPrice
:
undefined
,
priceType
:
'
notAvailable
'
,
labels
:
[],
drink
:
undefined
,
note
:
undefined
,
unitSize
:
undefined
,
packageSize
:
undefined
,
externalId
:
undefined
,
}
it
(
'
undefined inventory should return undefined
'
,
()
=>
{
expect
(
drinkInventoryFormatter
(
undefined
)).
toEqual
(
undefined
)
})
it
(
'
null inventory should return null
'
,
()
=>
{
expect
(
drinkInventoryFormatter
(
null
)).
toEqual
(
null
)
})
it
(
'
emptry inventory should return default result
'
,
()
=>
{
expect
(
drinkInventoryFormatter
(
defaultInventory
)).
toEqual
(
defaultExpectedResult
)
})
it
(
'
inventory should return correct result
'
,
()
=>
{
const
inventory
=
{
special_price
:
'
44.99
'
,
batch_price
:
[{
price
:
24.99
,
count
:
4
,
}],
drink
:
{
id
:
10449
,
user_review
:
[{
id
:
2286
,
value
:
3
,
text
:
'
Nice
'
,
drink_id
:
10449
,
}],
description
:
'
Premium brand, bottom fermented Munchner Lager...
'
,
tag
:
{
name
:
'
German Lager
'
,
},
name
:
'
Spaten Premium Lager
'
,
label_url
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
user_favorite
:
[{
id
:
2349
,
drink_id
:
10449
,
}],
avg_review
:
{
value
:
3.54
,
count
:
493
,
},
country
:
{
name
:
'
Germany
'
,
description
:
''
,
image_url
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
},
producer
:
{
id
:
1559
,
description
:
''
,
name
:
'
Spaten-Franziskaner-Bräu
'
,
},
drink_type
:
'
beer
'
,
},
special_price_amount
:
24
,
value_pick
:
true
,
price
:
1.99
,
in_stock
:
73
,
special_price_on
:
true
,
unit_size
:
'
187ML
'
,
note
:
'
inventory_note
'
,
id
:
114929
,
pack_size
:
3
,
staff_pick
:
true
,
external_id
:
'
41520
'
,
on_sale
:
true
,
}
const
expectedResult
=
{
id
:
114929
,
price
:
'
$1.99
'
,
priceRaw
:
1.99
,
oldPrice
:
null
,
specialPrice
:
{
amount
:
24
,
price
:
'
$44.99
'
,
},
batchPrice
:
[{
price
:
24.99
,
count
:
4
,
}],
priceType
:
'
specialPrice
'
,
labels
:
[{
title
:
'
3 PACK
'
,
type
:
'
packSize
'
,
},
{
title
:
'
Value Pick
'
,
type
:
'
valuePick
'
,
},
{
title
:
'
Staff Pick
'
,
type
:
'
staffPick
'
,
},
{
title
:
'
Sale
'
,
type
:
'
onSale
'
,
}],
drink
:
{
id
:
10449
,
logo
:
{
uri
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
},
title
:
'
Spaten Premium Lager
'
,
subtitle
:
'
German Lager, Germany
'
,
description
:
'
Premium brand, bottom fermented Munchner Lager...
'
,
country
:
{
description
:
''
,
image_url
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
name
:
'
Germany
'
,
},
drinkType
:
'
beer
'
,
producer
:
{
id
:
1559
,
description
:
''
,
name
:
'
Spaten-Franziskaner-Bräu
'
,
},
reviewAvgValue
:
3.54
,
reviewTotalCount
:
493
,
userReview
:
{
id
:
2286
,
text
:
'
Nice
'
,
value
:
3
,
drink_id
:
10449
,
},
userFavorite
:
{
id
:
2349
,
drink_id
:
10449
,
},
},
note
:
'
inventory_note
'
,
unitSize
:
'
187ML
'
,
packageSize
:
3
,
externalId
:
'
41520
'
,
}
expect
(
drinkInventoryFormatter
(
inventory
)).
toEqual
(
expectedResult
)
})
it
(
'
should return priceType=outOfStock
'
,
()
=>
{
const
inventory
=
{
...
defaultInventory
,
in_stock
:
0
,
}
const
expectedResult
=
{
...
defaultExpectedResult
,
priceType
:
'
outOfStock
'
,
}
expect
(
drinkInventoryFormatter
(
inventory
)).
toEqual
(
expectedResult
)
})
it
(
'
should return priceType=onSale
'
,
()
=>
{
const
inventory
=
{
...
defaultInventory
,
on_sale
:
true
,
}
const
expectedResult
=
{
...
defaultExpectedResult
,
labels
:
[{
title
:
'
Sale
'
,
type
:
'
onSale
'
,
}],
}
expect
(
drinkInventoryFormatter
(
inventory
)).
toEqual
(
expectedResult
)
})
it
(
'
should return priceType=regularPrice
'
,
()
=>
{
const
inventory
=
{
...
defaultInventory
,
price
:
'
1.99
'
,
}
const
expectedResult
=
{
...
defaultExpectedResult
,
price
:
'
$1.99
'
,
priceRaw
:
'
1.99
'
,
priceType
:
'
regularPrice
'
,
}
expect
(
drinkInventoryFormatter
(
inventory
)).
toEqual
(
expectedResult
)
})
})
utils/__tests__/getDetailedOrderStatusData.test.js
View file @
9d3c6c2d
...
...
@@ -35,7 +35,7 @@ describe('getDetailedOrderStatusData', () => {
const
order
=
{
order_status
:
'
approved
'
}
const
expectedResult
=
{
output
:
'
approved
'
,
detailedOutputMessage
:
'
Your order is
available for pickup
'
,
detailedOutputMessage
:
'
Your order is
being proccessed
'
,
}
expect
(
getDetailedOrderStatusData
(
order
)).
toEqual
(
expectedResult
)
...
...
@@ -71,6 +71,16 @@ describe('getDetailedOrderStatusData', () => {
expect
(
getDetailedOrderStatusData
(
order
)).
toEqual
(
expectedResult
)
})
it
(
'
order_status is pickup_ready
'
,
()
=>
{
const
order
=
{
order_status
:
'
pickup_ready
'
}
const
expectedResult
=
{
output
:
'
pickupReady
'
,
detailedOutputMessage
:
'
Your order is available for pickup
'
,
}
expect
(
getDetailedOrderStatusData
(
order
)).
toEqual
(
expectedResult
)
})
it
(
'
order_status is canceled_by_user
'
,
()
=>
{
const
order
=
{
order_status
:
'
canceled_by_user
'
}
const
expectedResult
=
{
...
...
utils/__tests__/getOrderProductsCategories.test.js
0 → 100644
View file @
9d3c6c2d
import
getOrderProductsCategories
from
'
../getOrderProductsCategories
'
describe
(
'
getOrderProductsCategories
'
,
()
=>
{
it
(
'
undefined order products should return default result
'
,
()
=>
{
const
expectedResult
=
{
wineCount
:
0
,
beerCount
:
0
,
spiritsCount
:
0
,
otherCount
:
0
,
}
expect
(
getOrderProductsCategories
(
undefined
)).
toEqual
(
expectedResult
)
})
it
(
'
order products should return expected result
'
,
()
=>
{
const
orderProducts
=
[{
wine
:
{},
},
{
drink
:
{
drink_type
:
'
beer
'
,
},
},
{
drink
:
{
drink_type
:
'
beer
'
,
},
},
{
drink
:
{
drink_type
:
'
spirits
'
,
},
}]
const
expectedResult
=
{
wineCount
:
1
,
beerCount
:
2
,
spiritsCount
:
1
,
otherCount
:
0
,
}
expect
(
getOrderProductsCategories
(
orderProducts
)).
toEqual
(
expectedResult
)
})
})
utils/__tests__/handleOrderStatus.test.js
0 → 100644
View file @
9d3c6c2d
import
handleOrderStatus
,
{
process
,
readyToCollect
,
collected
,
inTransit
,
isActiveOrder
,
isNewOrder
,
}
from
'
../handleOrderStatus
'
describe
(
'
handleOrderStatus
'
,
()
=>
{
it
(
'
undefined order should return error status
'
,
()
=>
{
const
expectedResult
=
{
statusImg
:
{
testUri
:
'
../../../src/utils/handleOrderStatus/img/error.png
'
,
},
statusText
:
'
Error
'
,
}
expect
(
handleOrderStatus
(
undefined
)).
toEqual
(
expectedResult
)
})
it
(
"
order with order_status: 'new' should return process status
"
,
()
=>
{
const
order
=
{
order_status
:
'
new
'
}
const
expectedResult
=
{
statusImg
:
{
testUri
:
'
../../../src/utils/handleOrderStatus/img/process.png
'
,
},
statusText
:
'
Process
'
,
}
expect
(
handleOrderStatus
(
order
)).
toEqual
(
expectedResult
)
})
it
(
"
order with order_status: 'approved' should return approved status
"
,
()
=>
{
const
order
=
{
order_status
:
'
approved
'
}
const
expectedResult
=
{
statusImg
:
{
testUri
:
'
../../../src/utils/handleOrderStatus/img/ready_to_collect.png
'
,
},
statusText
:
'
Approved
'
,
}
expect
(
handleOrderStatus
(
order
)).
toEqual
(
expectedResult
)
})
it
(
"
order with order_status: 'delivered' should return collected status
"
,
()
=>
{
const
order
=
{
order_status
:
'
delivered
'
}
const
expectedResult
=
{
statusImg
:
{
testUri
:
'
../../../src/utils/handleOrderStatus/img/collected.png
'
,
},
statusText
:
'
Collected
'
,
}
expect
(
handleOrderStatus
(
order
)).
toEqual
(
expectedResult
)
})
it
(
"
order with order_status: 'in_transit' should return in transit status
"
,
()
=>
{
const
order
=
{
order_status
:
'
in_transit
'
}
const
expectedResult
=
{
statusImg
:
{
testUri
:
'
../../../src/utils/handleOrderStatus/img/in_transit.png
'
,
},
statusText
:
'
In Transit
'
,
}
expect
(
handleOrderStatus
(
order
)).
toEqual
(
expectedResult
)
})
})
describe
(
'
process
'
,
()
=>
{
it
(
'
undefined order should return false
'
,
()
=>
{
expect
(
process
(
undefined
)).
toBeFalsy
()
})
it
(
'
empty order should return false
'
,
()
=>
{
expect
(
process
({})).
toBeFalsy
()
})
it
(
"
order with order_status: 'unknown' should return false
"
,
()
=>
{
const
order
=
{
order_status
:
'
unknown
'
}
expect
(
process
(
order
)).
toBeFalsy
()
})
it
(
"
order with order_status: 'new' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
new
'
}
expect
(
process
(
order
)).
toBeTruthy
()
})
it
(
"
order with order_status: 'placed' should return false
"
,
()
=>
{
const
order
=
{
order_status
:
'
placed
'
}
expect
(
process
(
order
)).
toBeFalsy
()
})
it
(
"
order with order_status: 'placed' and payment_status: null should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
placed
'
,
payment_status
:
null
}
expect
(
process
(
order
)).
toBeTruthy
()
})
it
(
"
order with order_status: 'placed' and payment_status: 'new' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
placed
'
,
payment_status
:
'
new
'
}
expect
(
process
(
order
)).
toBeTruthy
()
})
it
(
"
order with order_status: 'placed' and payment_status: 'held' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
placed
'
,
payment_status
:
'
held
'
}
expect
(
process
(
order
)).
toBeTruthy
()
})
})
describe
(
'
ready to pickup
'
,
()
=>
{
it
(
'
undefined order should return false
'
,
()
=>
{
expect
(
readyToCollect
(
undefined
)).
toBeFalsy
()
})
it
(
'
empty order should return false
'
,
()
=>
{
expect
(
readyToCollect
({})).
toBeFalsy
()
})
it
(
"
order with order_status: 'unknown' should return false
"
,
()
=>
{
const
order
=
{
order_status
:
'
unknown
'
}
expect
(
readyToCollect
(
order
)).
toBeFalsy
()
})
it
(
"
order with order_status: 'pickup_ready' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
pickup_ready
'
}
expect
(
readyToCollect
(
order
)).
toBeTruthy
()
})
})
describe
(
'
collected
'
,
()
=>
{
it
(
'
undefined order should return false
'
,
()
=>
{
expect
(
collected
(
undefined
)).
toBeFalsy
()
})
it
(
'
empty order should return false
'
,
()
=>
{
expect
(
collected
({})).
toBeFalsy
()
})
it
(
"
order with order_status: 'unknown' should return false
"
,
()
=>
{
const
order
=
{
order_status
:
'
unknown
'
}
expect
(
collected
(
order
)).
toBeFalsy
()
})
it
(
"
order with order_status: 'delivered' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
delivered
'
}
expect
(
collected
(
order
)).
toBeTruthy
()
})
it
(
"
order with order_status: 'reconciled' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
reconciled
'
}
expect
(
collected
(
order
)).
toBeTruthy
()
})
})
describe
(
'
inTransit
'
,
()
=>
{
it
(
'
undefined order should return false
'
,
()
=>
{
expect
(
inTransit
(
undefined
)).
toBeFalsy
()
})
it
(
'
empty order should return false
'
,
()
=>
{
expect
(
inTransit
({})).
toBeFalsy
()
})
it
(
"
order with order_status: 'unknown' should return false
"
,
()
=>
{
const
order
=
{
order_status
:
'
unknown
'
}
expect
(
inTransit
(
order
)).
toBeFalsy
()
})
it
(
"
order with order_status: 'in_transit' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
in_transit
'
}
expect
(
inTransit
(
order
)).
toBeTruthy
()
})
})
describe
(
'
isActiveOrder
'
,
()
=>
{
it
(
"
order with order_status: 'new' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
new
'
}
expect
(
isActiveOrder
(
order
)).
toBeTruthy
()
})
it
(
"
order with order_status: 'approved' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
approved
'
}
expect
(
isActiveOrder
(
order
)).
toBeTruthy
()
})
it
(
"
order with order_status: 'pickup_ready' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
pickup_ready
'
}
expect
(
isActiveOrder
(
order
)).
toBeTruthy
()
})
it
(
"
order with order_status: 'in_transit' should return true
"
,
()
=>
{
const
order
=
{
order_status
:
'
in_transit
'
}
expect
(
isActiveOrder
(
order
)).
toBeTruthy
()
})
})
describe
(
'
isNewOrder
'
,
()
=>
{
it
(
'
undefined order should return false
'
,
()
=>
{
expect
(
isNewOrder
(
undefined
)).
toBeFalsy
()
})
it
(
'
empty order should return false
'
,
()
=>
{
expect
(
isNewOrder
({})).
toBeFalsy
()
})
it
(
"
order with order_status: 'unknown' should return false
"
,
()
=>
{
const
order
=
{
order_status
:
'
unknown
'
}
expect
(
isNewOrder
(
order
)).
toBeFalsy
()
})
it
(
"
order with order_status: 'new' should return false
"
,
()
=>
{
const
order
=
{
order_status
:
'
new
'
}
expect
(
isNewOrder
(
order
)).
toBeTruthy
()
})
})
utils/__tests__/userFormatter.test.js
0 → 100644
View file @
9d3c6c2d
import
{
userFormatter
}
from
'
../formatters
'
describe
(
'
userFormatter
'
,
()
=>
{
it
(
'
undefined user should return default result
'
,
()
=>
{
const
expectedResult
=
{
firstName
:
undefined
,
lastName
:
undefined
,
fullName
:
undefined
,
profilePicture
:
undefined
,
}
expect
(
userFormatter
(
undefined
)).
toEqual
(
expectedResult
)
})
it
(
'
empty user should return default result
'
,
()
=>
{
const
expectedResult
=
{
firstName
:
undefined
,
lastName
:
undefined
,
fullName
:
undefined
,
profilePicture
:
undefined
,
profileUsername
:
undefined
,
}
expect
(
userFormatter
({})).
toEqual
(
expectedResult
)
})
it
(
'
null user should return default result
'
,
()
=>
{
const
expectedResult
=
{
firstName
:
undefined
,
lastName
:
undefined
,
fullName
:
undefined
,
profilePicture
:
undefined
,
profileUsername
:
undefined
,
}
expect
(
userFormatter
({})).
toEqual
(
expectedResult
)
})
it
(
'
user should return expected result
'
,
()
=>
{
const
user
=
{
id
:
4567
,
first_name
:
'
Dmytro
'
,
last_name
:
'
Zavgorodniy
'
,
profile_picture
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
}
const
expectedResult
=
{
firstName
:
'
Dmytro
'
,
lastName
:
'
Zavgorodniy
'
,
fullName
:
'
Dmytro Zavgorodniy
'
,
profilePicture
:
{
uri
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
},
profileUsername
:
'
Dmytro Zavgorodniy
'
,
}
expect
(
userFormatter
(
user
)).
toEqual
(
expectedResult
)
})
it
(
'
user without profile_picture should return expected result
'
,
()
=>
{
const
user
=
{
id
:
4567
,
first_name
:
'
Dmytro
'
,
last_name
:
'
Zavgorodniy
'
,
profile_picture
:
undefined
,
}
const
expectedResult
=
{
firstName
:
'
Dmytro
'
,
lastName
:
'
Zavgorodniy
'
,
fullName
:
'
Dmytro Zavgorodniy
'
,
profilePicture
:
undefined
,
profileUsername
:
'
Dmytro Zavgorodniy
'
,
}
expect
(
userFormatter
(
user
)).
toEqual
(
expectedResult
)
})
it
(
'
user without first_name should return expected result
'
,
()
=>
{
const
user
=
{
id
:
4567
,
first_name
:
undefined
,
last_name
:
'
Zavgorodniy
'
,
profile_picture
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
}
const
expectedResult
=
{
firstName
:
undefined
,
lastName
:
'
Zavgorodniy
'
,
fullName
:
'
Zavgorodniy
'
,
profilePicture
:
{
uri
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
},
profileUsername
:
'
Zavgorodniy
'
,
}
expect
(
userFormatter
(
user
)).
toEqual
(
expectedResult
)
})
it
(
'
user without last_name should return expected result
'
,
()
=>
{
const
user
=
{
id
:
4567
,
first_name
:
'
Dmytro
'
,
last_name
:
undefined
,
profile_picture
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
}
const
expectedResult
=
{
firstName
:
'
Dmytro
'
,
lastName
:
undefined
,
fullName
:
'
Dmytro
'
,
profilePicture
:
{
uri
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
},
profileUsername
:
'
Dmytro
'
,
}
expect
(
userFormatter
(
user
)).
toEqual
(
expectedResult
)
})
it
(
'
user without first_name and last_name should return expected result
'
,
()
=>
{
const
user
=
{
id
:
4567
,
first_name
:
undefined
,
last_name
:
undefined
,
profile_picture
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
}
const
expectedResult
=
{
firstName
:
undefined
,
lastName
:
undefined
,
fullName
:
'
User #4567
'
,
profilePicture
:
{
uri
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
},
profileUsername
:
undefined
,
}
expect
(
userFormatter
(
user
)).
toEqual
(
expectedResult
)
})
it
(
'
user with email should return expected result
'
,
()
=>
{
const
user
=
{
id
:
4567
,
first_name
:
undefined
,
last_name
:
undefined
,
email
:
'
dmytro.zavgorodniy@gmail.com
'
,
profile_picture
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
}
const
expectedResult
=
{
firstName
:
undefined
,
lastName
:
undefined
,
fullName
:
'
User #4567
'
,
profilePicture
:
{
uri
:
'
https://tipsiphotos.s3.amazonaws.com:443/image_upload/image.png
'
,
},
profileUsername
:
'
dmytro.zavgorodniy@gmail.com
'
,
}
expect
(
userFormatter
(
user
)).
toEqual
(
expectedResult
)
})
})
utils/__tests__/wineInventoryFormatter.test.js
0 → 100644
View file @
9d3c6c2d
import
{
wineInventoryFormatter
}
from
'
../formatters
'
describe
(
'
wineInventoryFormatter
'
,
()
=>
{
const
defaultInventory
=
{}
const
defaultExpectedResult
=
{
id
:
undefined
,
price
:
null
,
oldPrice
:
null
,
priceRaw
:
undefined
,
batchPrice
:
undefined
,
specialPrice
:
undefined
,
priceType
:
'
notAvailable
'
,
labels
:
[],
wine
:
undefined
,
storeNote
:
undefined
,
unitSize
:
undefined
,
packageSize
:
undefined
,
externalId
:
undefined
,
}
it
(
'
undefined inventory should return undefined
'
,
()
=>
{
expect
(
wineInventoryFormatter
(
undefined
)).
toEqual
(
undefined
)
})
it
(
'
null inventory should return null
'
,
()
=>
{
expect
(
wineInventoryFormatter
(
null
)).
toEqual
(
null
)
})
it
(
'
emptry inventory should return default result
'
,
()
=>
{
expect
(
wineInventoryFormatter
(
defaultInventory
)).
toEqual
(
defaultExpectedResult
)
})
it
(
'
inventory should return correct result
'
,
()
=>
{
const
inventory
=
{
special_price
:
'
44.99
'
,
batch_price
:
[{
price
:
24.99
,
count
:
4
,
}],
wine
:
{
name
:
"
Cook's Brut Champagne Blend, Chardonnay
"
,
type
:
'
sparkling
'
,
batch_price
:
[{
price
:
24.99
,
count
:
4
,
}],
designation
:
{
name
:
'
Brut
'
,
description
:
''
,
},
avg_review
:
{
value
:
2.7948717948717947
,
count
:
39
,
},
varietals
:
[{
name
:
'
Champagne Blend
'
,
description
:
'
Champagne is used to...
'
,
},
{
name
:
'
Chardonnay
'
,
description
:
'
The flavor of Chardonnay...
'
,
}],
style_scoring
:
[{
id
:
1
,
name
:
'
style_scoring_1
'
,
score
:
90
,
},
{