Guest User

how_will_you_test_this_function

a guest
Dec 22nd, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.71 KB | Source Code | 0 0
  1. export function navigateToNewsDetail({
  2.   filter,
  3.   id,
  4.   index,
  5.   router,
  6.   search,
  7.   symbolName,
  8.   title,
  9. }) {
  10.   const params = {
  11.     id,
  12.     index,
  13.     title: toUrlFriendly(title),
  14.   }
  15.   const query = {
  16.     filter,
  17.     search,
  18.   }
  19.   const tag = toUrlFriendlyTag(symbolName)
  20.   if (tag !== 'all') {
  21.     params.tag = tag
  22.   }
  23.  
  24.   // https://stackoverflow.com/a/52640870/5371505
  25.   return new Promise((resolve, reject) => {
  26.     router
  27.       .push({ name: 'NewsDetail', params, query })
  28.       .then(resolve)
  29.       .catch((error) => {
  30.         if (isNavigationFailure(error, NavigationFailureType.duplicated)) {
  31.           resolve()
  32.         } else {
  33.           reject(error)
  34.         }
  35.       })
  36.   })
  37. }
Advertisement
Add Comment
Please, Sign In to add comment