Client - display only active sports in application in user preferences
+ fixes
This commit is contained in:
@ -16,7 +16,7 @@ export const sports: ISport[] = [
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
has_workouts: false,
|
||||
has_workouts: true,
|
||||
id: 2,
|
||||
img: '/img/sports/cycling-transport.png',
|
||||
is_active: false,
|
||||
|
@ -7,7 +7,7 @@ import { translateSports } from '@/utils/sports'
|
||||
|
||||
const { t, locale } = createI18n.global
|
||||
|
||||
describe('sortSports', () => {
|
||||
describe('translateSports', () => {
|
||||
const testsParams = [
|
||||
{
|
||||
description: "returns sorted all translated sports (with 'en' locale)",
|
||||
@ -15,6 +15,7 @@ describe('sortSports', () => {
|
||||
sports,
|
||||
locale: 'en',
|
||||
onlyActive: false,
|
||||
userSports: null,
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
@ -30,7 +31,7 @@ describe('sortSports', () => {
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
has_workouts: false,
|
||||
has_workouts: true,
|
||||
id: 2,
|
||||
img: '/img/sports/cycling-transport.png',
|
||||
is_active: false,
|
||||
@ -54,11 +55,12 @@ describe('sortSports', () => {
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns sorted only active translated sports (with 'en' locales)",
|
||||
"returns sorted only translated sports, active for user (with 'en' locales)",
|
||||
inputParams: {
|
||||
sports,
|
||||
locale: 'en',
|
||||
onlyActive: true,
|
||||
userSports: null,
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
@ -80,6 +82,7 @@ describe('sortSports', () => {
|
||||
sports: [],
|
||||
locale: 'en',
|
||||
onlyActive: false,
|
||||
userSports: null,
|
||||
},
|
||||
expected: [],
|
||||
},
|
||||
@ -89,6 +92,7 @@ describe('sortSports', () => {
|
||||
sports,
|
||||
locale: 'fr',
|
||||
onlyActive: false,
|
||||
userSports: [],
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
@ -115,7 +119,7 @@ describe('sortSports', () => {
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
has_workouts: false,
|
||||
has_workouts: true,
|
||||
id: 2,
|
||||
img: '/img/sports/cycling-transport.png',
|
||||
is_active: false,
|
||||
@ -128,11 +132,12 @@ describe('sortSports', () => {
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns sorted only active translated sports (with 'fr' locales)",
|
||||
"returns sorted only translated sports, active for user (with 'fr' locales)",
|
||||
inputParams: {
|
||||
sports,
|
||||
locale: 'fr',
|
||||
onlyActive: true,
|
||||
userSports: null,
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
@ -154,6 +159,209 @@ describe('sortSports', () => {
|
||||
sports: [],
|
||||
locale: 'fr',
|
||||
onlyActive: false,
|
||||
userSports: null,
|
||||
},
|
||||
expected: [],
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns sorted all translated sports, even with user sports list provided (with 'en' locale)",
|
||||
inputParams: {
|
||||
sports,
|
||||
locale: 'en',
|
||||
onlyActive: false,
|
||||
userSports: [2],
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
color: null,
|
||||
has_workouts: false,
|
||||
id: 1,
|
||||
img: '/img/sports/cycling-sport.png',
|
||||
is_active: true,
|
||||
is_active_for_user: true,
|
||||
label: 'Cycling (Sport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Cycling (Sport)',
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
has_workouts: true,
|
||||
id: 2,
|
||||
img: '/img/sports/cycling-transport.png',
|
||||
is_active: false,
|
||||
is_active_for_user: false,
|
||||
label: 'Cycling (Transport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Cycling (Transport)',
|
||||
},
|
||||
{
|
||||
color: null,
|
||||
has_workouts: true,
|
||||
id: 3,
|
||||
img: '/img/sports/hiking.png',
|
||||
is_active: true,
|
||||
is_active_for_user: false,
|
||||
label: 'Hiking',
|
||||
stopped_speed_threshold: 0.1,
|
||||
translatedLabel: 'Hiking',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns sorted only translated sports active on application and sports with user workouts (with 'en' locales)",
|
||||
inputParams: {
|
||||
sports,
|
||||
locale: 'en',
|
||||
onlyActive: true,
|
||||
userSports: [2],
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
color: null,
|
||||
has_workouts: false,
|
||||
id: 1,
|
||||
img: '/img/sports/cycling-sport.png',
|
||||
is_active: true,
|
||||
is_active_for_user: true,
|
||||
label: 'Cycling (Sport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Cycling (Sport)',
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
has_workouts: true,
|
||||
id: 2,
|
||||
img: '/img/sports/cycling-transport.png',
|
||||
is_active: false,
|
||||
is_active_for_user: false,
|
||||
label: 'Cycling (Transport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Cycling (Transport)',
|
||||
},
|
||||
{
|
||||
color: null,
|
||||
has_workouts: true,
|
||||
id: 3,
|
||||
img: '/img/sports/hiking.png',
|
||||
is_active: true,
|
||||
is_active_for_user: false,
|
||||
label: 'Hiking',
|
||||
stopped_speed_threshold: 0.1,
|
||||
translatedLabel: 'Hiking',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns empty array, with user sports list provided (with 'en' locale)",
|
||||
inputParams: {
|
||||
sports: [],
|
||||
locale: 'en',
|
||||
onlyActive: false,
|
||||
userSports: null,
|
||||
},
|
||||
expected: [],
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns sorted all translated sports, even with user sports list provided (with 'fr' locale)",
|
||||
inputParams: {
|
||||
sports,
|
||||
locale: 'fr',
|
||||
onlyActive: false,
|
||||
userSports: [2],
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
color: null,
|
||||
has_workouts: true,
|
||||
id: 3,
|
||||
img: '/img/sports/hiking.png',
|
||||
is_active: true,
|
||||
is_active_for_user: false,
|
||||
label: 'Hiking',
|
||||
stopped_speed_threshold: 0.1,
|
||||
translatedLabel: 'Randonnée',
|
||||
},
|
||||
{
|
||||
color: null,
|
||||
has_workouts: false,
|
||||
id: 1,
|
||||
img: '/img/sports/cycling-sport.png',
|
||||
is_active: true,
|
||||
is_active_for_user: true,
|
||||
label: 'Cycling (Sport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Vélo (Sport)',
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
has_workouts: true,
|
||||
id: 2,
|
||||
img: '/img/sports/cycling-transport.png',
|
||||
is_active: false,
|
||||
is_active_for_user: false,
|
||||
label: 'Cycling (Transport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Vélo (Transport)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns sorted only translated sports active on application and sports with user workouts (with 'fr' locales)",
|
||||
inputParams: {
|
||||
sports,
|
||||
locale: 'fr',
|
||||
onlyActive: true,
|
||||
userSports: [2],
|
||||
},
|
||||
expected: [
|
||||
{
|
||||
color: null,
|
||||
has_workouts: true,
|
||||
id: 3,
|
||||
img: '/img/sports/hiking.png',
|
||||
is_active: true,
|
||||
is_active_for_user: false,
|
||||
label: 'Hiking',
|
||||
stopped_speed_threshold: 0.1,
|
||||
translatedLabel: 'Randonnée',
|
||||
},
|
||||
{
|
||||
color: null,
|
||||
has_workouts: false,
|
||||
id: 1,
|
||||
img: '/img/sports/cycling-sport.png',
|
||||
is_active: true,
|
||||
is_active_for_user: true,
|
||||
label: 'Cycling (Sport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Vélo (Sport)',
|
||||
},
|
||||
{
|
||||
color: '#000000',
|
||||
has_workouts: true,
|
||||
id: 2,
|
||||
img: '/img/sports/cycling-transport.png',
|
||||
is_active: false,
|
||||
is_active_for_user: false,
|
||||
label: 'Cycling (Transport)',
|
||||
stopped_speed_threshold: 1,
|
||||
translatedLabel: 'Vélo (Transport)',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
description:
|
||||
"returns empty array, with user sports list provided (with 'fr' locale)",
|
||||
inputParams: {
|
||||
sports: [],
|
||||
locale: 'fr',
|
||||
onlyActive: false,
|
||||
userSports: [2],
|
||||
},
|
||||
expected: [],
|
||||
},
|
||||
@ -165,7 +373,8 @@ describe('sortSports', () => {
|
||||
translateSports(
|
||||
testParams.inputParams.sports,
|
||||
t,
|
||||
testParams.inputParams.onlyActive
|
||||
testParams.inputParams.onlyActive,
|
||||
testParams.inputParams.userSports
|
||||
),
|
||||
testParams.expected
|
||||
)
|
||||
|
Reference in New Issue
Block a user