From f59a040ca54e1e5842149bec97c295f9c37c4e78 Mon Sep 17 00:00:00 2001 From: Suyash Patil <127177049+suyashpatil78@users.noreply.github.com> Date: Sat, 4 May 2024 11:44:13 +0530 Subject: [PATCH] feat: added deepFreeze to not pollute global mock data - Part 8 (#2922) * feat: added deepFreeze to not pollute global mock data - Part 8 * feat: added deepFreeze to not pollute global mock data - Part 9 (#2924) * feat: added deepFreeze to not pollute global mock data - Part 9 * feat: added deepFreeze to not pollute global mock data - Part 10 (#2925) * feat: added deepFreeze to not pollute global mock data - Part 10 * feat: added deepFreeze to not pollute global mock data - Part 11 (#2927) * feat: added deepFreeze to not pollute global mock data - Part 11 * feat: added deepFreeze to not pollute global mock data - Part 12 (#2929) * feat: added deepFreeze to not pollute global mock data - Part 12 * feat: added deepFreeze to not pollute global mock data - Part 13 (#2930) * feat: added deepFreeze to not pollute global mock data - Part 13 * minor * feat: added deepFreeze to not pollute global mock data - Part 14 (#2933) * feat: added deepFreeze to not pollute global mock data - Part 14 * feat: added deepFreeze to not pollute global mock data - Part 15 (#2934) * feat: added deepFreeze to not pollute global mock data - Part 15 * test: fixing tests - part 1 (#2939) * test: fixing tests - part 1 * test: fixing tests - part 2 (#2940) * test: fixing tests - part 2 * test: fixing tests - part 3 (#2941) * test: fixing tests - part 3 * test: fixing tests - part 4 (#2943) * test: fixing tests - part 4 * test: fixing tests - part 5 (#2945) * minor --- src/app/core/mock-data/option.data.ts | 6 +- .../mock-data/org-category-list-item.data.ts | 14 +- src/app/core/mock-data/org-category.data.ts | 146 ++++----- .../org-payment-mode-settings.data.ts | 18 +- src/app/core/mock-data/org-settings.data.ts | 110 +++---- .../core/mock-data/org-user-settings.data.ts | 54 ++-- src/app/core/mock-data/org.data.ts | 10 +- src/app/core/mock-data/outbox-queue.data.ts | 6 +- src/app/core/mock-data/parsed-receipt.data.ts | 58 ++-- src/app/core/mock-data/pdf-export.data.ts | 10 +- .../mock-data/per-diem-custom-inputs.data.ts | 10 +- .../mock-data/per-diem-form-value.data.ts | 42 +-- src/app/core/mock-data/per-diem-rates.data.ts | 10 +- .../core/mock-data/personal-card-txns.data.ts | 10 +- src/app/core/mock-data/personal-cards.data.ts | 14 +- .../mock-data/platform-api-category.data.ts | 18 +- .../platform-corporate-card-detail.data.ts | 20 +- .../mock-data/platform-corporate-card.data.ts | 30 +- .../mock-data/platform-cost-centers.data.ts | 10 +- .../mock-data/platform-mileage-rate.data.ts | 14 +- .../mock-data/platform-policy-expense.data.ts | 38 +-- .../core/mock-data/platform-report.data.ts | 31 +- .../v1/advance-request-platform.data.ts | 15 +- .../v1/expense-duplicate-sets.data.ts | 18 +- .../mock-data/platform/v1/expense.data.ts | 132 ++++---- .../platform/v1/expenses-query-params.data.ts | 14 +- .../platform/v1/expenses-response.data.ts | 6 +- .../platform/v1/expenses-stats.data.ts | 18 +- .../core/mock-data/policy-violation.data.ts | 38 +-- .../policy-violcation-comment.data.ts | 22 +- src/app/core/mock-data/popover-params.data.ts | 10 +- src/app/core/mock-data/popup.data.ts | 14 +- .../project-dependent-fields-mapping.data.ts | 6 +- .../mock-data/public-policy-expense.data.ts | 54 ++-- .../recent-local-storage-items.data.ts | 18 +- src/app/core/mock-data/recently-used.data.ts | 139 +++++---- src/app/core/mock-data/report-actions.data.ts | 6 +- .../report-auto-submission-details.data.ts | 6 +- src/app/core/mock-data/report-options.data.ts | 19 +- .../core/mock-data/report-stats-data.data.ts | 10 +- src/app/core/mock-data/report-stats.data.ts | 10 +- .../core/mock-data/report-unflattened.data.ts | 58 ++-- src/app/core/mock-data/report-v1.data.ts | 18 +- src/app/core/mock-data/report.data.ts | 34 +- .../mock-data/router-state-snapshot.data.ts | 4 +- .../core/mock-data/selected-filters.data.ts | 50 +-- .../sidemenu-allowed-actions.data.ts | 6 +- src/app/core/mock-data/sidemenu-item.data.ts | 18 +- src/app/core/mock-data/sidemenu.data.ts | 30 +- .../mock-data/snackbar-properties.data.ts | 34 +- .../mock-data/split-expense-policy.data.ts | 6 +- ...-expense-data.ts => split-expense.data.ts} | 46 +-- src/app/core/mock-data/split-payload.data.ts | 14 +- src/app/core/mock-data/splits.data.ts | 10 +- .../mock-data/static-map-properties.data.ts | 6 +- .../stats-dimension-response.data.ts | 32 +- src/app/core/mock-data/stats-response.data.ts | 14 +- src/app/core/mock-data/stats.data.ts | 26 +- src/app/core/mock-data/task-cta.data.ts | 38 +-- src/app/core/mock-data/task-filters.data.ts | 38 +-- src/app/core/mock-data/task.data.ts | 50 +-- src/app/core/mock-data/tax-group.data.ts | 10 +- src/app/core/mock-data/tax-settings.data.ts | 6 +- .../mock-data/team-reports-filters.data.ts | 46 +-- .../track-expense-properties.data.ts | 30 +- .../core/mock-data/transaction-status.data.ts | 18 +- src/app/core/mock-data/transaction.data.ts | 238 +++++++------- .../mock-data/transformed-expense.data.ts | 50 +-- ...ormed-split-expense-missing-fields.data.ts | 10 +- src/app/core/mock-data/txn-account.data.ts | 6 +- .../mock-data/txn-custom-properties.data.ts | 38 +-- src/app/core/mock-data/undo-merge.data.ts | 10 +- .../unflattened-advance-request.data.ts | 6 +- .../mock-data/unflattened-expense.data.ts | 38 +-- .../core/mock-data/unflattened-txn.data.ts | 294 +++++++++--------- .../mock-data/unformatted-transaction.data.ts | 6 +- .../core/mock-data/unique-cards-stats.data.ts | 6 +- src/app/core/mock-data/unique-cards.data.ts | 6 +- .../mock-data/user-password-status.data.ts | 6 +- ...g-for-update-mobile-number-popover.data.ts | 6 +- .../virtual-card-combined-response.data.ts | 6 +- .../virtual-card-details-response.data.ts | 11 +- .../mock-data/virtual-card-response.data.ts | 10 +- .../virtual-cards-combined-request.data.ts | 6 +- .../mock-data/virtual-select-option.data.ts | 35 ++- src/app/core/mock-data/yoodle-token.data.ts | 6 +- .../card-details-combined-response.model.ts | 2 +- .../models/card-details-response.model.ts | 2 +- .../services/advance-request.service.spec.ts | 63 ++-- src/app/core/services/advance.service.spec.ts | 4 +- .../core/services/categories.service.spec.ts | 10 +- .../services/custom-fields.service.spec.ts | 15 +- src/app/core/services/date.service.spec.ts | 8 +- .../services/dependent-fields.service.spec.ts | 10 +- .../services/expense-fields.service.spec.ts | 4 +- src/app/core/services/file.service.spec.ts | 5 +- .../core/services/location.service.spec.ts | 5 +- .../services/merge-expenses.service.spec.ts | 74 +++-- .../services/org-settings.service.spec.ts | 12 +- src/app/core/services/org.service.spec.ts | 18 +- ...recent-local-storage-items.service.spec.ts | 23 +- src/app/core/services/report.service.spec.ts | 31 +- src/app/core/services/status.service.spec.ts | 12 +- .../core/services/transaction.service.spec.ts | 24 +- src/app/core/services/utility.service.spec.ts | 7 +- .../services/virtual-cards.service.spec.ts | 7 +- .../test-data/accounts.service.spec.data.ts | 142 ++++----- .../core/test-data/custom-inputs.spec.data.ts | 38 +-- .../test-data/deep-link.service.spec.data.ts | 6 +- .../dependent-fields.service.spec.data.ts | 77 ++--- .../org-settings.service.spec.data.ts | 66 ++-- .../test-data/org-user.service.spec.data.ts | 50 +-- .../test-data/per-diem.service.spec.data.ts | 42 +-- src/app/core/test-data/projects.spec.data.ts | 60 ++-- .../test-data/status.service.spec.data.ts | 62 ++-- .../core/test-data/tasks.service.spec.data.ts | 38 +-- .../add-edit-expense-2.spec.ts | 23 +- .../add-edit-expense-3.spec.ts | 102 +++--- .../add-edit-expense-4.spec.ts | 40 ++- .../add-edit-expense-5.spec.ts | 15 +- .../add-edit-expense-6.spec.ts | 28 +- .../add-edit-mileage-1.spec.ts | 2 +- .../add-edit-mileage-3.spec.ts | 5 +- .../add-edit-mileage-4.spec.ts | 9 +- .../add-edit-mileage-5.spec.ts | 6 +- .../merge-expense-3.page.spec.ts | 35 ++- .../my-create-report.page.spec.ts | 5 +- .../employee-details-card.component.spec.ts | 4 +- .../fyle/my-reports/my-reports.page.spec.ts | 28 +- .../my-view-report.page.spec.ts | 26 +- .../notifications/notifications.page.spec.ts | 17 +- .../split-expense/split-expense.page.spec.ts | 34 +- .../team-reports/team-reports-1.page.spec.ts | 3 +- .../view-team-report.page.spec.ts | 89 +++--- .../setup-account/setup-account.page.spec.ts | 51 +-- .../audit-history.component.spec.ts | 10 +- .../view-comment.component.spec.ts | 25 +- .../view-comment/view-comment.component.ts | 6 +- .../expenses-card.component.spec.ts | 29 +- .../expenses-card.component.spec.ts | 25 +- .../approver-dialog.component.spec.ts | 25 +- .../fy-userlist-modal.component.spec.ts | 27 +- .../route-selector.component.spec.ts | 9 +- .../sidemenu-content.component.spec.ts | 17 +- .../virtual-select-modal.component.spec.ts | 2 +- 145 files changed, 2315 insertions(+), 1969 deletions(-) rename src/app/core/mock-data/{split-expense-data.ts => split-expense.data.ts} (84%) diff --git a/src/app/core/mock-data/option.data.ts b/src/app/core/mock-data/option.data.ts index fc33e40597..dd17f97b43 100644 --- a/src/app/core/mock-data/option.data.ts +++ b/src/app/core/mock-data/option.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { Option } from '../models/option.model'; -export const optionData1: Option[] = [ +export const optionData1: Option[] = deepFreeze([ { label: 'report 1', value: { @@ -132,4 +134,4 @@ export const optionData1: Option[] = [ user_id: 'usvKA4X8Ugcr', }, }, -]; +]); diff --git a/src/app/core/mock-data/org-category-list-item.data.ts b/src/app/core/mock-data/org-category-list-item.data.ts index fa63efc841..c628c2e05f 100644 --- a/src/app/core/mock-data/org-category-list-item.data.ts +++ b/src/app/core/mock-data/org-category-list-item.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { OrgCategoryListItem } from '../models/v1/org-category.model'; import { expectedOrgCategoriesPaginated } from './org-category.data'; -export const categorieListRes: OrgCategoryListItem[] = [ +export const categorieListRes: OrgCategoryListItem[] = deepFreeze([ { label: 'Accounts Payable - Employees', value: expectedOrgCategoriesPaginated[0], @@ -18,9 +20,9 @@ export const categorieListRes: OrgCategoryListItem[] = [ label: 'samp category', value: expectedOrgCategoriesPaginated[3], }, -]; +]); -export const recentUsedCategoriesRes: OrgCategoryListItem[] = [ +export const recentUsedCategoriesRes: OrgCategoryListItem[] = deepFreeze([ { label: 'Office Supplies', value: { @@ -66,9 +68,9 @@ export const recentUsedCategoriesRes: OrgCategoryListItem[] = [ updated_at: new Date('2022-11-23T13:11:51.771676+00:00'), }, }, -]; +]); -export const orgCategoryListItemData1 = [ +export const orgCategoryListItemData1 = deepFreeze([ { label: 'Business', value: { @@ -129,4 +131,4 @@ export const orgCategoryListItemData1 = [ updated_at: new Date('2023-01-09T16:54:09.929Z'), }, }, -]; +]); diff --git a/src/app/core/mock-data/org-category.data.ts b/src/app/core/mock-data/org-category.data.ts index e2cfd0545d..b683f921ab 100644 --- a/src/app/core/mock-data/org-category.data.ts +++ b/src/app/core/mock-data/org-category.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PlatformCategory } from '../models/platform/platform-category.model'; import { OrgCategory } from '../models/v1/org-category.model'; -export const orgCategoryData: OrgCategory = { +export const orgCategoryData: OrgCategory = deepFreeze({ code: null, created_at: new Date('2018-01-31T23:50:27.235056+00:00'), displayName: 'Food', @@ -12,9 +14,9 @@ export const orgCategoryData: OrgCategory = { org_id: 'orNVthTo2Zyo', sub_category: 'Food', updated_at: new Date('2022-05-05T17:45:42.092507+00:00'), -}; +}); -export const mileagePerDiemPlatformCategoryData: PlatformCategory[] = [ +export const mileagePerDiemPlatformCategoryData: PlatformCategory[] = deepFreeze([ { code: null, created_at: new Date('2018-01-31T23:50:27.235056+00:00'), @@ -39,9 +41,9 @@ export const mileagePerDiemPlatformCategoryData: PlatformCategory[] = [ sub_category: 'Per Diem', updated_at: new Date('2022-05-05T17:45:42.092507+00:00'), }, -]; +]); -export const transformedOrgCategories: OrgCategory[] = [ +export const transformedOrgCategories: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -90,9 +92,9 @@ export const transformedOrgCategories: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const sortedCategory: OrgCategory[] = [ +export const sortedCategory: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -141,9 +143,9 @@ export const sortedCategory: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const sortedOrgCategories: OrgCategory[] = [ +export const sortedOrgCategories: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -192,9 +194,9 @@ export const sortedOrgCategories: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const filterOrgCategoryParam: OrgCategory[] = [ +export const filterOrgCategoryParam: OrgCategory[] = deepFreeze([ { code: '43', created_at: new Date('2023-01-09T16:54:09.929Z'), @@ -219,9 +221,9 @@ export const filterOrgCategoryParam: OrgCategory[] = [ sub_category: 'Marketing outreach', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const expectedFilterOrgCategory: OrgCategory[] = [ +export const expectedFilterOrgCategory: OrgCategory[] = deepFreeze([ { code: '42', created_at: new Date('2023-01-09T16:54:09.929Z'), @@ -234,9 +236,9 @@ export const expectedFilterOrgCategory: OrgCategory[] = [ sub_category: 'Marketing outreach', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const expectedAllOrgCategories: OrgCategory[] = [ +export const expectedAllOrgCategories: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -285,9 +287,9 @@ export const expectedAllOrgCategories: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const orgCategoryWoDisplayName: OrgCategory[] = [ +export const orgCategoryWoDisplayName: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -312,9 +314,9 @@ export const orgCategoryWoDisplayName: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const orgCategoryWithDisplayName: OrgCategory[] = [ +export const orgCategoryWithDisplayName: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -339,9 +341,9 @@ export const orgCategoryWithDisplayName: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const orgCategoryPaginated1: OrgCategory[] = [ +export const orgCategoryPaginated1: OrgCategory[] = deepFreeze([ { code: '20300', created_at: new Date('2021-03-14T06:07:39.652664+00:00'), @@ -366,9 +368,9 @@ export const orgCategoryPaginated1: OrgCategory[] = [ sub_category: 'Capitalized Software Costs', updated_at: new Date('2022-05-05T17:45:11.742874+00:00'), }, -]; +]); -export const orgCategoryPaginated2: OrgCategory[] = [ +export const orgCategoryPaginated2: OrgCategory[] = deepFreeze([ { code: '51708', created_at: new Date('2021-03-14T06:07:39.652664+00:00'), @@ -393,9 +395,9 @@ export const orgCategoryPaginated2: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const expectedOrgCategoriesPaginated: OrgCategory[] = [ +export const expectedOrgCategoriesPaginated: OrgCategory[] = deepFreeze([ { code: '20300', created_at: new Date('2021-03-14T06:07:39.652Z'), @@ -444,9 +446,9 @@ export const expectedOrgCategoriesPaginated: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const orgCategoryData1: OrgCategory[] = [ +export const orgCategoryData1: OrgCategory[] = deepFreeze([ { ...expectedOrgCategoriesPaginated[0] }, { ...expectedOrgCategoriesPaginated[1] }, { @@ -473,9 +475,9 @@ export const orgCategoryData1: OrgCategory[] = [ sub_category: 'Food', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const expectedTransformedCategories: OrgCategory[] = [ +export const expectedTransformedCategories: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -524,9 +526,9 @@ export const expectedTransformedCategories: OrgCategory[] = [ sub_category: 'Marketing outreach', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const unsortedCategories1: OrgCategory[] = [ +export const unsortedCategories1: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -647,9 +649,9 @@ export const unsortedCategories1: OrgCategory[] = [ sub_category: 'Induction', updated_at: new Date('2022-11-23T13:11:51.771676+00:00'), }, -]; +]); -export const sortedCategories1: OrgCategory[] = [ +export const sortedCategories1: OrgCategory[] = deepFreeze([ { code: null, created_at: new Date('2022-02-07T10:36:23.916Z'), @@ -770,9 +772,9 @@ export const sortedCategories1: OrgCategory[] = [ sub_category: 'Pager', updated_at: new Date('2022-05-05T17:47:06.951Z'), }, -]; +]); -export const transformedOrgCategoryById: OrgCategory[] = [ +export const transformedOrgCategoryById: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -809,9 +811,9 @@ export const transformedOrgCategoryById: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const displayOrgCategoryById: OrgCategory[] = [ +export const displayOrgCategoryById: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -848,9 +850,9 @@ export const displayOrgCategoryById: OrgCategory[] = [ sub_category: 'samp category', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const expectedOrgCategoryById: OrgCategory = { +export const expectedOrgCategoryById: OrgCategory = deepFreeze({ code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), displayName: 'Business', @@ -861,9 +863,9 @@ export const expectedOrgCategoryById: OrgCategory = { org_id: 'orrjqbDbeP9p', sub_category: 'Business', updated_at: new Date('2022-07-01T05:51:31.800Z'), -}; +}); -export const transformedOrgCategoriesByName: OrgCategory[] = [ +export const transformedOrgCategoriesByName: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -900,9 +902,9 @@ export const transformedOrgCategoriesByName: OrgCategory[] = [ sub_category: 'Marketing outreach', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const displayOrgCategoriesByName: OrgCategory[] = [ +export const displayOrgCategoriesByName: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -939,9 +941,9 @@ export const displayOrgCategoriesByName: OrgCategory[] = [ sub_category: 'Marketing outreach', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const expectedOrgCategoryByName: OrgCategory = { +export const expectedOrgCategoryByName: OrgCategory = deepFreeze({ code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), displayName: 'Business', @@ -952,18 +954,18 @@ export const expectedOrgCategoryByName: OrgCategory = { org_id: 'orrjqbDbeP9p', sub_category: 'Business', updated_at: new Date('2022-07-01T05:51:31.800Z'), -}; +}); -export const filteredCategoriesData = [ +export const filteredCategoriesData = deepFreeze([ { value: orgCategoryData, }, { value: transformedOrgCategories[0], }, -]; +]); -export const expectedAutoFillCategory: OrgCategory = { +export const expectedAutoFillCategory: OrgCategory = deepFreeze({ code: null, created_at: new Date('2018-01-31T23:50:27.235Z'), displayName: 'Food', @@ -974,9 +976,9 @@ export const expectedAutoFillCategory: OrgCategory = { org_id: 'orNVthTo2Zyo', sub_category: 'Food', updated_at: new Date('2022-05-05T17:45:42.092Z'), -}; +}); -export const expectedAutoFillCategory2: OrgCategory = { +export const expectedAutoFillCategory2: OrgCategory = deepFreeze({ code: null, created_at: new Date('2020-03-04T09:51:01.619Z'), displayName: 'Office supplies', @@ -987,9 +989,9 @@ export const expectedAutoFillCategory2: OrgCategory = { org_id: 'orNVthTo2Zyo', sub_category: 'Office supplies', updated_at: new Date('2022-11-23T13:11:51.771Z'), -}; +}); -export const TaxiCategory: OrgCategory = { +export const TaxiCategory: OrgCategory = deepFreeze({ code: null, created_at: new Date('2020-03-04T09:51:01.619Z'), displayName: 'Office supplies', @@ -1000,9 +1002,9 @@ export const TaxiCategory: OrgCategory = { org_id: 'orNVthTo2Zyo', sub_category: 'TRAVEL', updated_at: new Date('2022-11-23T13:11:51.771Z'), -}; +}); -export const expectedAutoFillCategory3: OrgCategory = { +export const expectedAutoFillCategory3: OrgCategory = deepFreeze({ code: null, created_at: new Date('2018-01-31T23:50:27.235Z'), displayName: 'Food', @@ -1013,9 +1015,9 @@ export const expectedAutoFillCategory3: OrgCategory = { org_id: 'orNVthTo2Zyo', sub_category: 'Food', updated_at: new Date('2022-05-05T17:45:42.092Z'), -}; +}); -export const perDiemCategory: OrgCategory = { +export const perDiemCategory: OrgCategory = deepFreeze({ code: null, created_at: new Date('2018-07-27T08:52:38.938006+00:00'), displayName: 'Per Diem', @@ -1026,9 +1028,9 @@ export const perDiemCategory: OrgCategory = { org_id: 'orrb8EW1zZsy', sub_category: 'Per Diem', updated_at: new Date('2022-09-13T17:16:56.232081+00:00'), -}; +}); -export const mileageCategories: OrgCategory[] = [ +export const mileageCategories: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -1065,9 +1067,9 @@ export const mileageCategories: OrgCategory[] = [ sub_category: 'Marketing outreach', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const mileageCategories2: OrgCategory[] = [ +export const mileageCategories2: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -1104,9 +1106,9 @@ export const mileageCategories2: OrgCategory[] = [ sub_category: 'Marketing outreach', updated_at: new Date('2023-01-09T16:54:09.929Z'), }, -]; +]); -export const mileageCategories3: OrgCategory[] = [ +export const mileageCategories3: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -1131,9 +1133,9 @@ export const mileageCategories3: OrgCategory[] = [ sub_category: null, updated_at: new Date('2022-05-05T17:47:06.951Z'), }, -]; +]); -export const expectedMileageCategoriesData: OrgCategory[] = [ +export const expectedMileageCategoriesData: OrgCategory[] = deepFreeze([ { code: '98', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -1146,9 +1148,9 @@ export const expectedMileageCategoriesData: OrgCategory[] = [ sub_category: null, updated_at: new Date('2022-05-05T17:47:06.951Z'), }, -]; +]); -export const expectedOrgCategoryByName2: OrgCategory = { +export const expectedOrgCategoryByName2: OrgCategory = deepFreeze({ code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), displayName: 'Business', @@ -1159,9 +1161,9 @@ export const expectedOrgCategoryByName2: OrgCategory = { org_id: 'orrjqbDbeP9p', sub_category: 'Business', updated_at: new Date('2022-07-01T05:51:31.800Z'), -}; +}); -export const unspecifiedCategory: OrgCategory = { +export const unspecifiedCategory: OrgCategory = deepFreeze({ code: null, created_at: new Date('2018-01-31T23:50:27.235056+00:00'), displayName: 'Unspecified', @@ -1172,9 +1174,9 @@ export const unspecifiedCategory: OrgCategory = { org_id: 'orNVthTo2Zyo', sub_category: 'Unspecified', updated_at: new Date('2022-05-05T17:45:42.092507+00:00'), -}; +}); -export const mileageCategoryWithoutId: OrgCategory[] = [ +export const mileageCategoryWithoutId: OrgCategory[] = deepFreeze([ { code: '93', created_at: new Date('2021-05-18T11:40:38.576Z'), @@ -1187,4 +1189,4 @@ export const mileageCategoryWithoutId: OrgCategory[] = [ sub_category: 'Business', updated_at: new Date('2022-07-01T05:51:31.800Z'), }, -]; +]); diff --git a/src/app/core/mock-data/org-payment-mode-settings.data.ts b/src/app/core/mock-data/org-payment-mode-settings.data.ts index 2aa6e61558..cb655233d5 100644 --- a/src/app/core/mock-data/org-payment-mode-settings.data.ts +++ b/src/app/core/mock-data/org-payment-mode-settings.data.ts @@ -1,32 +1,34 @@ +import deepFreeze from 'deep-freeze-strict'; + import { AllowedPaymentModes } from '../models/allowed-payment-modes.enum'; import { PaymentmodeSettings } from '../models/org-settings.model'; -export const cccOnlyPaymentModeSettingsParam: PaymentmodeSettings = { +export const cccOnlyPaymentModeSettingsParam: PaymentmodeSettings = deepFreeze({ allowed: true, enabled: true, payment_modes_order: [AllowedPaymentModes.PERSONAL_CORPORATE_CREDIT_CARD_ACCOUNT], -}; +}); -export const reimbursableOnlyPaymentModeSettingsParam: PaymentmodeSettings = { +export const reimbursableOnlyPaymentModeSettingsParam: PaymentmodeSettings = deepFreeze({ allowed: true, enabled: true, payment_modes_order: [AllowedPaymentModes.PERSONAL_ACCOUNT], -}; +}); -export const cccAndReimbursablePaymentModeSettingsParam: PaymentmodeSettings = { +export const cccAndReimbursablePaymentModeSettingsParam: PaymentmodeSettings = deepFreeze({ allowed: true, enabled: true, payment_modes_order: [ AllowedPaymentModes.PERSONAL_ACCOUNT, AllowedPaymentModes.PERSONAL_CORPORATE_CREDIT_CARD_ACCOUNT, ], -}; +}); -export const cccAndPaidByCompanyPaymentModeSettingsParam: PaymentmodeSettings = { +export const cccAndPaidByCompanyPaymentModeSettingsParam: PaymentmodeSettings = deepFreeze({ allowed: true, enabled: true, payment_modes_order: [ AllowedPaymentModes.PERSONAL_CORPORATE_CREDIT_CARD_ACCOUNT, AllowedPaymentModes.COMPANY_ACCOUNT, ], -}; +}); diff --git a/src/app/core/mock-data/org-settings.data.ts b/src/app/core/mock-data/org-settings.data.ts index d811139faa..e0aa03b761 100644 --- a/src/app/core/mock-data/org-settings.data.ts +++ b/src/app/core/mock-data/org-settings.data.ts @@ -1,8 +1,10 @@ +import deepFreeze from 'deep-freeze-strict'; + import { AllowedPaymentModes } from '../models/allowed-payment-modes.enum'; import { EmailEvents, OrgSettings, TaxSettings } from '../models/org-settings.model'; import { orgSettingsData } from '../test-data/accounts.service.spec.data'; -export const orgSettingsRes: OrgSettings = { +export const orgSettingsRes: OrgSettings = deepFreeze({ org_id: 'orrjqbDbeP9p', mileage: { allowed: true, @@ -407,9 +409,9 @@ export const orgSettingsRes: OrgSettings = { enabled: true, virtual_card_settings_enabled: true, }, -}; +}); -export const orgSettingsParams2: OrgSettings = { +export const orgSettingsParams2: OrgSettings = deepFreeze({ org_id: 'orrjqbDbeP9p', mileage: { allowed: true, @@ -814,9 +816,9 @@ export const orgSettingsParams2: OrgSettings = { enabled: true, virtual_card_settings_enabled: true, }, -}; +}); -export const orgSettingsParamWoCCC: OrgSettings = { +export const orgSettingsParamWoCCC: OrgSettings = deepFreeze({ org_id: 'orrjqbDbeP9p', mileage: { allowed: true, @@ -1199,35 +1201,35 @@ export const orgSettingsParamWoCCC: OrgSettings = { enabled: true, virtual_card_settings_enabled: true, }, -}; +}); -export const orgSettingsCCCDisabled: OrgSettings = { +export const orgSettingsCCCDisabled: OrgSettings = deepFreeze({ ...orgSettingsData, corporate_credit_card_settings: { ...orgSettingsData.corporate_credit_card_settings, allowed: false, enabled: false, }, -}; +}); -export const orgSettingsCCCEnabled: OrgSettings = { +export const orgSettingsCCCEnabled: OrgSettings = deepFreeze({ ...orgSettingsData, corporate_credit_card_settings: { ...orgSettingsData.corporate_credit_card_settings, allowed: true, enabled: true, }, -}; +}); -export const orgSettingsParamsWithSimplifiedReport: OrgSettings = { +export const orgSettingsParamsWithSimplifiedReport: OrgSettings = deepFreeze({ ...orgSettingsRes, simplified_report_closure_settings: { allowed: true, enabled: true, }, -}; +}); -export const taxSettingsData: TaxSettings = { +export const taxSettingsData: TaxSettings = deepFreeze({ allowed: true, enabled: true, name: null, @@ -1254,14 +1256,14 @@ export const taxSettingsData: TaxSettings = { }, }, ], -}; +}); -export const taxSettingsData2: TaxSettings = { +export const taxSettingsData2: TaxSettings = deepFreeze({ ...taxSettingsData, enabled: false, -}; +}); -export const orgSettingsWoTax: OrgSettings = { +export const orgSettingsWoTax: OrgSettings = deepFreeze({ ...orgSettingsData, tax_settings: { ...orgSettingsData.tax_settings, enabled: false }, advances: null, @@ -1275,9 +1277,9 @@ export const orgSettingsWoTax: OrgSettings = { advance_requests: { enabled: true, }, -}; +}); -export const orgSettingsWoTaxAndRtf: OrgSettings = { +export const orgSettingsWoTaxAndRtf: OrgSettings = deepFreeze({ ...orgSettingsWoTax, visa_enrollment_settings: { allowed: true, @@ -1287,22 +1289,22 @@ export const orgSettingsWoTaxAndRtf: OrgSettings = { allowed: true, enabled: false, }, -}; +}); -export const orgSettingsCCCDisabled2: OrgSettings = { +export const orgSettingsCCCDisabled2: OrgSettings = deepFreeze({ ...orgSettingsRes, corporate_credit_card_settings: null, -}; +}); -export const orgSettingsCCCDisabled3: OrgSettings = { +export const orgSettingsCCCDisabled3: OrgSettings = deepFreeze({ ...orgSettingsRes, corporate_credit_card_settings: { allowed: true, enabled: null, }, -}; +}); -export const orgSettingsRTFDisabled: OrgSettings = { +export const orgSettingsRTFDisabled: OrgSettings = deepFreeze({ ...orgSettingsRes, mastercard_enrollment_settings: { allowed: false, @@ -1312,45 +1314,45 @@ export const orgSettingsRTFDisabled: OrgSettings = { allowed: false, enabled: false, }, -}; +}); -export const orgSettingsWithProjectAndAutofill: OrgSettings = { +export const orgSettingsWithProjectAndAutofill: OrgSettings = deepFreeze({ ...orgSettingsRes, org_expense_form_autofills: { allowed: true, enabled: true, }, -}; +}); -export const orgSettingsWithExpenseFormAutofill: OrgSettings = { +export const orgSettingsWithExpenseFormAutofill: OrgSettings = deepFreeze({ ...orgSettingsParams2, org_expense_form_autofills: { allowed: true, enabled: true, }, -}; +}); -export const orgSettingsProjectDisabled: OrgSettings = { +export const orgSettingsProjectDisabled: OrgSettings = deepFreeze({ ...orgSettingsRes, projects: { allowed: false, enabled: false, }, -}; +}); -export const orgSettingsWoAdvance: OrgSettings = { +export const orgSettingsWoAdvance: OrgSettings = deepFreeze({ ...orgSettingsRes, advances: null, -}; +}); -export const orgSettingsCCDisabled: OrgSettings = { +export const orgSettingsCCDisabled: OrgSettings = deepFreeze({ ...orgSettingsRes, cost_centers: { enabled: false, }, -}; +}); -export const orgSettingsOrgAutofill: OrgSettings = { +export const orgSettingsOrgAutofill: OrgSettings = deepFreeze({ ...orgSettingsRes, org_expense_form_autofills: { enabled: true, @@ -1358,55 +1360,55 @@ export const orgSettingsOrgAutofill: OrgSettings = { }, advanced_projects: null, projects: null, -}; +}); -export const orgSettingsWoProjects: OrgSettings = { +export const orgSettingsWoProjects: OrgSettings = deepFreeze({ ...orgSettingsRes, advanced_projects: null, projects: null, -}; +}); -export const orgSettingsWoMileage: OrgSettings = { +export const orgSettingsWoMileage: OrgSettings = deepFreeze({ ...orgSettingsParams2, mileage: null, -}; +}); -export const orgSettingsWithUnsubscribeEvent: OrgSettings = { +export const orgSettingsWithUnsubscribeEvent: OrgSettings = deepFreeze({ ...orgSettingsRes, admin_email_settings: { ...orgSettingsRes.admin_email_settings, unsubscribed_events: [EmailEvents.DELEGATOR_SUBSCRIPTION, EmailEvents.EADVANCES_CREATED], }, -}; +}); -export const orgSettingsWithV2ExpensesPage: OrgSettings = { +export const orgSettingsWithV2ExpensesPage: OrgSettings = deepFreeze({ ...orgSettingsRes, mobile_app_my_expenses_beta_enabled: true, -}; +}); -export const orgSettingsWoV2ExpensesPage: OrgSettings = { +export const orgSettingsWoV2ExpensesPage: OrgSettings = deepFreeze({ ...orgSettingsRes, mobile_app_my_expenses_beta_enabled: false, -}; +}); -export const orgSettingsPendingRestrictions: OrgSettings = { +export const orgSettingsPendingRestrictions: OrgSettings = deepFreeze({ ...orgSettingsRes, corporate_credit_card_settings: { enabled: true }, pending_cct_expense_restriction: { enabled: true }, -}; +}); -export const orgSettingsWithCommuteDeductionsEnabled: OrgSettings = { +export const orgSettingsWithCommuteDeductionsEnabled: OrgSettings = deepFreeze({ ...orgSettingsRes, commute_deduction_settings: { enabled: true, allowed: true, }, -}; +}); -export const orgSettingsWithCommuteDeductionsDisabled: OrgSettings = { +export const orgSettingsWithCommuteDeductionsDisabled: OrgSettings = deepFreeze({ ...orgSettingsRes, commute_deduction_settings: { enabled: false, allowed: false, }, -}; +}); diff --git a/src/app/core/mock-data/org-user-settings.data.ts b/src/app/core/mock-data/org-user-settings.data.ts index 605d165484..8e9d4f3042 100644 --- a/src/app/core/mock-data/org-user-settings.data.ts +++ b/src/app/core/mock-data/org-user-settings.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { AccountType } from '../enums/account-type.enum'; import { OrgUserSettings } from '../models/org_user_settings.model'; -export const orgUserSettingsData: OrgUserSettings = { +export const orgUserSettingsData: OrgUserSettings = deepFreeze({ id: 'ousS9MgDNQ6NB', created_at: new Date('2018-02-01T02:32:25.275Z'), updated_at: new Date('2023-01-23T09:47:32.266Z'), @@ -158,27 +160,27 @@ export const orgUserSettingsData: OrgUserSettings = { enabled: true, allowed_payment_modes: [AccountType.PERSONAL, AccountType.CCC, AccountType.COMPANY], }, -}; +}); -export const orgUserSettingsWoPaymentModes: OrgUserSettings = { +export const orgUserSettingsWoPaymentModes: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, payment_mode_settings: { allowed: false, enabled: false, allowed_payment_modes: [AccountType.PERSONAL, AccountType.CCC, AccountType.COMPANY], }, -}; +}); -export const orgUserSettingsWoPayModesCompany: OrgUserSettings = { +export const orgUserSettingsWoPayModesCompany: OrgUserSettings = deepFreeze({ ...orgUserSettingsWoPaymentModes, preferences: { default_project_id: 3943, default_vehicle_type: 'four_wheeler', default_payment_mode: 'COMPANY_ACCOUNT', }, -}; +}); -export const orgUserSettingsData2: OrgUserSettings = { +export const orgUserSettingsData2: OrgUserSettings = deepFreeze({ id: 'ousS9MgDNQ6NB', created_at: new Date('2018-02-01T02:32:25.275Z'), updated_at: new Date('2023-02-03T14:01:22.940Z'), @@ -335,9 +337,9 @@ export const orgUserSettingsData2: OrgUserSettings = { enabled: true, allowed_payment_modes: [AccountType.PERSONAL, AccountType.CCC, AccountType.COMPANY], }, -}; +}); -export const orgUserSettingsData3: OrgUserSettings = { +export const orgUserSettingsData3: OrgUserSettings = deepFreeze({ id: 'ousS9MgDNQ6NB', created_at: new Date('2018-02-01T02:32:25.275Z'), updated_at: new Date('2023-02-08T10:04:47.852Z'), @@ -494,9 +496,9 @@ export const orgUserSettingsData3: OrgUserSettings = { enabled: true, allowed_payment_modes: [AccountType.PERSONAL, AccountType.CCC, AccountType.COMPANY], }, -}; +}); -export const orgUserSettingsDataWoCCIDs: OrgUserSettings = { +export const orgUserSettingsDataWoCCIDs: OrgUserSettings = deepFreeze({ id: 'ousS9MgDNQ6NB', created_at: new Date('2018-02-01T02:32:25.275Z'), updated_at: new Date('2023-01-23T09:47:32.266Z'), @@ -653,60 +655,60 @@ export const orgUserSettingsDataWoCCIDs: OrgUserSettings = { enabled: true, allowed_payment_modes: [AccountType.PERSONAL, AccountType.CCC, AccountType.COMPANY], }, -}; +}); -export const orgUserSettingsWithCurrency: OrgUserSettings = { +export const orgUserSettingsWithCurrency: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, currency_settings: { enabled: true, preferred_currency: 'USD', }, -}; +}); -export const orgUserSettingsWoDefaultProject: OrgUserSettings = { +export const orgUserSettingsWoDefaultProject: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, preferences: { ...orgUserSettingsData.preferences, default_project_id: null, }, -}; +}); -export const orgUserSettingsWoInstaFyle: OrgUserSettings = { +export const orgUserSettingsWoInstaFyle: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, insta_fyle_settings: { ...orgUserSettingsData.insta_fyle_settings, allowed: true, }, -}; +}); -export const orgUserSettingsWoProjects: OrgUserSettings = { +export const orgUserSettingsWoProjects: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, project_ids: null, -}; +}); -export const notificationDelegateeSettings1: OrgUserSettings = { +export const notificationDelegateeSettings1: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, notification_settings: { ...orgUserSettingsData.notification_settings, notify_delegatee: true, notify_user: false, }, -}; +}); -export const notificationDelegateeSettings2: OrgUserSettings = { +export const notificationDelegateeSettings2: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, notification_settings: { ...orgUserSettingsData.notification_settings, notify_delegatee: false, notify_user: true, }, -}; +}); -export const notificationDelegateeSettings3: OrgUserSettings = { +export const notificationDelegateeSettings3: OrgUserSettings = deepFreeze({ ...orgUserSettingsData, notification_settings: { ...orgUserSettingsData.notification_settings, notify_delegatee: true, notify_user: true, }, -}; +}); diff --git a/src/app/core/mock-data/org.data.ts b/src/app/core/mock-data/org.data.ts index 04778403d1..6ab8790159 100644 --- a/src/app/core/mock-data/org.data.ts +++ b/src/app/core/mock-data/org.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { Org } from '../models/org.model'; -export const orgData1: Org[] = [ +export const orgData1: Org[] = deepFreeze([ { id: 'orNVthTo2Zyo', created_at: new Date('2018-01-31T23:50:27.216Z'), @@ -21,9 +23,9 @@ export const orgData1: Org[] = [ lite: false, dwolla_customers_metadata_id: 'dcmbDcwO330Wn', }, -]; +]); -export const orgData2 = [ +export const orgData2 = deepFreeze([ { id: 'orNVthTo2Zyo', created_at: new Date('2018-01-31T23:50:27.216Z'), @@ -64,4 +66,4 @@ export const orgData2 = [ lite: false, dwolla_customers_metadata_id: 'dcmbDcwO440Xn', }, -]; +]); diff --git a/src/app/core/mock-data/outbox-queue.data.ts b/src/app/core/mock-data/outbox-queue.data.ts index ea30392884..bd1747ea17 100644 --- a/src/app/core/mock-data/outbox-queue.data.ts +++ b/src/app/core/mock-data/outbox-queue.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { OutboxQueue } from '../models/outbox-queue.model'; import { expectedUnflattendedTxnData3 } from './unflattened-txn.data'; -export const outboxQueueData1: OutboxQueue[] = [ +export const outboxQueueData1: OutboxQueue[] = deepFreeze([ { transaction: expectedUnflattendedTxnData3.tx, dataUrls: [ @@ -17,4 +19,4 @@ export const outboxQueueData1: OutboxQueue[] = [ applyMagic: true, fileUploadCompleted: true, }, -]; +]); diff --git a/src/app/core/mock-data/parsed-receipt.data.ts b/src/app/core/mock-data/parsed-receipt.data.ts index f8b11164a6..fda8fc4af1 100644 --- a/src/app/core/mock-data/parsed-receipt.data.ts +++ b/src/app/core/mock-data/parsed-receipt.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { InstaFyleResponse } from '../models/insta-fyle-data.model'; import { ParsedReceipt } from '../models/parsed_receipt.model'; -export const parsedReceiptData1: ParsedReceipt = { +export const parsedReceiptData1: ParsedReceipt = deepFreeze({ data: { category: 'SYSTEM', currency: 'USD', @@ -10,9 +12,9 @@ export const parsedReceiptData1: ParsedReceipt = { invoice_dt: new Date('2023-02-24T12:03:57.680Z'), vendor_name: 'vendor', }, -}; +}); -export const parsedReceiptData: ParsedReceipt = { +export const parsedReceiptData: ParsedReceipt = deepFreeze({ data: { category: 'SYSTEM', currency: 'USD', @@ -21,9 +23,9 @@ export const parsedReceiptData: ParsedReceipt = { invoice_dt: new Date('2023-02-24T12:03:57.680Z'), vendor_name: 'vendor', }, -}; +}); -export const parsedReceiptData2: ParsedReceipt = { +export const parsedReceiptData2: ParsedReceipt = deepFreeze({ data: { category: 'SYSTEM', currency: 'USD', @@ -32,9 +34,9 @@ export const parsedReceiptData2: ParsedReceipt = { invoice_dt: new Date('2023-02-24T12:03:57.680Z'), vendor_name: 'vendor', }, -}; +}); -export const expectedInstaFyleData1: InstaFyleResponse = { +export const expectedInstaFyleData1: InstaFyleResponse = deepFreeze({ thumbnail: 'data-url', type: 'image', url: 'data-url', @@ -47,9 +49,9 @@ export const expectedInstaFyleData1: InstaFyleResponse = { vendor_name: 'vendor', }, exchangeRate: 82, -}; +}); -export const instaFyleData1: InstaFyleResponse = { +export const instaFyleData1: InstaFyleResponse = deepFreeze({ thumbnail: 'data-url', type: 'image', url: 'data-url', @@ -62,9 +64,9 @@ export const instaFyleData1: InstaFyleResponse = { vendor_name: 'vendor', }, exchangeRate: 82, -}; +}); -export const extractedData: ParsedReceipt = { +export const extractedData: ParsedReceipt = deepFreeze({ data: { category: 'SYSTEM', currency: 'USD', @@ -74,9 +76,9 @@ export const extractedData: ParsedReceipt = { vendor_name: 'vendor', }, exchangeRate: 82, -}; +}); -export const expectedInstaFyleData2: InstaFyleResponse = { +export const expectedInstaFyleData2: InstaFyleResponse = deepFreeze({ thumbnail: 'data-url', type: 'image', url: 'data-url', @@ -88,9 +90,9 @@ export const expectedInstaFyleData2: InstaFyleResponse = { invoice_dt: new Date('2023-02-24T12:03:57.680Z'), vendor_name: 'vendor', }, -}; +}); -export const instaFyleData2: InstaFyleResponse = { +export const instaFyleData2: InstaFyleResponse = deepFreeze({ thumbnail: 'data-url', type: 'image', url: 'data-url', @@ -103,9 +105,9 @@ export const instaFyleData2: InstaFyleResponse = { vendor_name: 'vendor', }, exchangeRate: 82, -}; +}); -export const parsedInfo1: ParsedReceipt = { +export const parsedInfo1: ParsedReceipt = deepFreeze({ data: { category: 'SYSTEM', currency: 'USD', @@ -115,9 +117,9 @@ export const parsedInfo1: ParsedReceipt = { vendor_name: 'vendor', }, exchangeRate: 82, -}; +}); -export const parsedInfo2: ParsedReceipt = { +export const parsedInfo2: ParsedReceipt = deepFreeze({ data: { category: 'SYSTEM', currency: 'USD', @@ -127,9 +129,9 @@ export const parsedInfo2: ParsedReceipt = { vendor_name: 'vendor', }, exchangeRate: 82, -}; +}); -export const parsedReceiptDataWoDate: ParsedReceipt = { +export const parsedReceiptDataWoDate: ParsedReceipt = deepFreeze({ data: { category: 'SYSTEM', currency: 'USD', @@ -138,9 +140,9 @@ export const parsedReceiptDataWoDate: ParsedReceipt = { invoice_dt: new Date('2023-02-24T12:03:57.680Z'), vendor_name: 'vendor', }, -}; +}); -export const instaFyleData3 = { +export const instaFyleData3 = deepFreeze({ thumbnail: 'data-url', type: 'image', url: 'data-url', @@ -153,16 +155,16 @@ export const instaFyleData3 = { vendor_name: 'vendor', }, exchangeRate: null, -}; +}); -export const instaFyleData4 = { +export const instaFyleData4 = deepFreeze({ thumbnail: 'data-url', type: 'image', url: 'data-url', parsedResponse: null, -}; +}); -export const instaFyleData5 = { +export const instaFyleData5 = deepFreeze({ thumbnail: 'data-url', type: 'image', url: 'data-url', @@ -175,4 +177,4 @@ export const instaFyleData5 = { vendor_name: 'vendor', }, exchangeRate: null, -}; +}); diff --git a/src/app/core/mock-data/pdf-export.data.ts b/src/app/core/mock-data/pdf-export.data.ts index e0dbb66fb2..7aa2665fb5 100644 --- a/src/app/core/mock-data/pdf-export.data.ts +++ b/src/app/core/mock-data/pdf-export.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PdfExport } from '../models/pdf-exports.model'; -export const pdfExportData1: PdfExport[] = [ +export const pdfExportData1: PdfExport[] = deepFreeze([ { id: 'ldz3kKCK1ehw', sent_by: 'arjun.m@fyle.in', @@ -53,9 +55,9 @@ export const pdfExportData1: PdfExport[] = [ column_mappings: null, batch_size: null, }, -]; +]); -export const pdfExportData2: PdfExport[] = [ +export const pdfExportData2: PdfExport[] = deepFreeze([ { id: 'ldz3kKCK1ehw', sent_by: 'arjun.m@fyle.in', @@ -134,4 +136,4 @@ export const pdfExportData2: PdfExport[] = [ column_mappings: null, batch_size: null, }, -]; +]); diff --git a/src/app/core/mock-data/per-diem-custom-inputs.data.ts b/src/app/core/mock-data/per-diem-custom-inputs.data.ts index 990e6f17e9..66e32d8144 100644 --- a/src/app/core/mock-data/per-diem-custom-inputs.data.ts +++ b/src/app/core/mock-data/per-diem-custom-inputs.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { FormBuilder } from '@angular/forms'; import { TxnCustomProperties } from '../models/txn-custom-properties.model'; import { PerDiemCustomInputs } from '../models/per-diem-custom-inputs.model'; const formBuilder = new FormBuilder(); -export const perDiemCustomInputsData1 = [ +export const perDiemCustomInputsData1 = deepFreeze([ { id: 200227, mandatory: false, @@ -92,7 +94,7 @@ export const perDiemCustomInputsData1 = [ value: '2023-02-13', }), }, -]; +]); // eslint-disable-next-line @typescript-eslint/no-unused-vars export const expectedExpenseFieldWithoutControl = perDiemCustomInputsData1.map(({ control, ...otherProps }) => ({ @@ -103,7 +105,7 @@ export const expectedControlValues = perDiemCustomInputsData1.map( ({ control }: { control: { value: string | string[] } }) => control.value ); -export const perDiemCustomInputsData2: PerDiemCustomInputs[] = [ +export const perDiemCustomInputsData2: PerDiemCustomInputs[] = deepFreeze([ { id: 318297, mandatory: true, @@ -132,4 +134,4 @@ export const perDiemCustomInputsData2: PerDiemCustomInputs[] = [ value: '', }), }, -]; +]); diff --git a/src/app/core/mock-data/per-diem-form-value.data.ts b/src/app/core/mock-data/per-diem-form-value.data.ts index 667163af65..1b2cf86f74 100644 --- a/src/app/core/mock-data/per-diem-form-value.data.ts +++ b/src/app/core/mock-data/per-diem-form-value.data.ts @@ -1,3 +1,5 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PerDiemFormValue } from '../models/per-diem-form-value.model'; import { multiplePaymentModesData } from '../test-data/accounts.service.spec.data'; import { costCentersData2, expectedCCdata3 } from './cost-centers.data'; @@ -7,7 +9,7 @@ import { orgCategoryData1 } from './org-category.data'; import { perDiemRatesData1 } from './per-diem-rates.data'; import { expectedReportsPaginated } from './platform-report.data'; -export const perDiemFormValuesData1: Partial = { +export const perDiemFormValuesData1: Partial = deepFreeze({ paymentMode: multiplePaymentModesData[0], sub_category: undefined, per_diem_rate: null, @@ -22,14 +24,14 @@ export const perDiemFormValuesData1: Partial = { custom_inputs: [], project_dependent_fields: [], cost_center_dependent_fields: [], -}; +}); -export const perDiemFormValuesData2: Partial = { +export const perDiemFormValuesData2: Partial = deepFreeze({ ...perDiemFormValuesData1, project: null, -}; +}); -export const perDiemFormValuesData3: Partial = { +export const perDiemFormValuesData3: Partial = deepFreeze({ ...perDiemFormValuesData1, per_diem_rate: { active: true, @@ -43,31 +45,31 @@ export const perDiemFormValuesData3: Partial = { full_name: 'BulkTest2 (50 USD per day)', readableRate: '$50.00 per day', }, -}; +}); -export const perDiemFormValuesData4: Partial = { +export const perDiemFormValuesData4: Partial = deepFreeze({ ...perDiemFormValuesData1, report: expectedReportsPaginated[0], -}; +}); -export const perDiemFormValuesData5: Partial = { +export const perDiemFormValuesData5: Partial = deepFreeze({ ...perDiemFormValuesData1, report: expectedReportsPaginated[0], -}; +}); -export const perDiemFormValuesData6: Partial = { +export const perDiemFormValuesData6: Partial = deepFreeze({ ...perDiemFormValuesData1, costCenter: expectedCCdata3[0].value, -}; +}); -export const perDiemFormValuesData7: Partial = { +export const perDiemFormValuesData7: Partial = deepFreeze({ ...perDiemFormValuesData1, to_dt: '2023-08-03', from_dt: '2023-08-01', num_days: 3, -}; +}); -export const perDiemFormValuesData8: PerDiemFormValue = { +export const perDiemFormValuesData8: PerDiemFormValue = deepFreeze({ currencyObj: currencyObjData6, paymentMode: multiplePaymentModesData[0], sub_category: orgCategoryData1[0], @@ -95,9 +97,9 @@ export const perDiemFormValuesData8: PerDiemFormValue = { }, ], cost_center_dependent_fields: [], -}; +}); -export const perDiemFormValuesData9: PerDiemFormValue = { +export const perDiemFormValuesData9: PerDiemFormValue = deepFreeze({ currencyObj: currencyObjData6, paymentMode: multiplePaymentModesData[0], sub_category: undefined, @@ -113,9 +115,9 @@ export const perDiemFormValuesData9: PerDiemFormValue = { custom_inputs: [], project_dependent_fields: [], cost_center_dependent_fields: [], -}; +}); -export const perDiemFormValuesData10: PerDiemFormValue = { +export const perDiemFormValuesData10: PerDiemFormValue = deepFreeze({ ...perDiemFormValuesData8, custom_inputs: [ { @@ -143,4 +145,4 @@ export const perDiemFormValuesData10: PerDiemFormValue = { displayValue: null, }, ], -}; +}); diff --git a/src/app/core/mock-data/per-diem-rates.data.ts b/src/app/core/mock-data/per-diem-rates.data.ts index 2f704a7433..ed6b63fb08 100644 --- a/src/app/core/mock-data/per-diem-rates.data.ts +++ b/src/app/core/mock-data/per-diem-rates.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PerDiemRates } from '../models/v1/per-diem-rates.model'; -export const perDiemRatesData1: PerDiemRates = { +export const perDiemRatesData1: PerDiemRates = deepFreeze({ active: true, created_at: new Date('2023-08-21'), currency: 'USD', @@ -11,12 +13,12 @@ export const perDiemRatesData1: PerDiemRates = { rate: 30, readableRate: '$30.00 per day', updated_at: new Date('2023-08-21'), -}; +}); -export const perDiemRatesData2: PerDiemRates = { +export const perDiemRatesData2: PerDiemRates = deepFreeze({ ...perDiemRatesData1, currency: 'INR', full_name: 'Rate 1 (300 INR per day)', rate: 300, readableRate: '₹300.00 per day', -}; +}); diff --git a/src/app/core/mock-data/personal-card-txns.data.ts b/src/app/core/mock-data/personal-card-txns.data.ts index 95ccebf049..63caa7936d 100644 --- a/src/app/core/mock-data/personal-card-txns.data.ts +++ b/src/app/core/mock-data/personal-card-txns.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PersonalCardTxn } from '../models/personal_card_txn.model'; import { ApiV2Response } from '../models/v2/api-v2-response.model'; -export const apiPersonalCardTxnsRes: ApiV2Response = { +export const apiPersonalCardTxnsRes: ApiV2Response = deepFreeze({ count: 1, data: [ { @@ -33,9 +35,9 @@ export const apiPersonalCardTxnsRes: ApiV2Response = { limit: 1, offset: 0, url: '/v2/personal_bank_transactions', -}; +}); -export const matchedPersonalCardTxn: PersonalCardTxn = { +export const matchedPersonalCardTxn: PersonalCardTxn = deepFreeze({ _search_document: "'200':1 '200.00':2 'card':5 'debit':4,18 'huskyteambkstore':11 'purchase':6 'usd':3 'wa':16 'xx':8 'xx/xx':7 'xxp':9 'xxx':13,14 'xxx-xxx-xxxx':12 'xxxx':15 'xxxxuw':10 'xxxxx':17", ba_account_number: 'xxxx2345', @@ -76,4 +78,4 @@ export const matchedPersonalCardTxn: PersonalCardTxn = { vendor_name: 'Office & Shipping', }, ], -}; +}); diff --git a/src/app/core/mock-data/personal-cards.data.ts b/src/app/core/mock-data/personal-cards.data.ts index 30fc6a9823..197d84c54d 100644 --- a/src/app/core/mock-data/personal-cards.data.ts +++ b/src/app/core/mock-data/personal-cards.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ApiV2Response } from '../models/api-v2.model'; import { PersonalCard } from '../models/personal_card.model'; -export const apiLinkedAccRes: ApiV2Response = { +export const apiLinkedAccRes: ApiV2Response = deepFreeze({ count: 11, data: [ { @@ -46,9 +48,9 @@ export const apiLinkedAccRes: ApiV2Response = { limit: 11, offset: 0, url: '/v2/personal_bank_accounts', -}; +}); -export const deletePersonalCardRes: PersonalCard = { +export const deletePersonalCardRes: PersonalCard = deepFreeze({ account_number: 'xxxx9806', account_type: 'CREDIT', bank_name: 'Dag Site yodlee', @@ -66,9 +68,9 @@ export const deletePersonalCardRes: PersonalCard = { unclassified_count: 0, update_credentials: false, updated_at: new Date('2022-05-31T07:40:58.190907'), -}; +}); -export const linkedAccountsRes: PersonalCard[] = [ +export const linkedAccountsRes: PersonalCard[] = deepFreeze([ { account_number: 'xxxx4227', account_type: 'CHECKING', @@ -107,4 +109,4 @@ export const linkedAccountsRes: PersonalCard[] = [ update_credentials: false, updated_at: new Date('2023-01-12T15:57:47.178727'), }, -]; +]); diff --git a/src/app/core/mock-data/platform-api-category.data.ts b/src/app/core/mock-data/platform-api-category.data.ts index 0ebbfb1110..4695428d5f 100644 --- a/src/app/core/mock-data/platform-api-category.data.ts +++ b/src/app/core/mock-data/platform-api-category.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ApiV2Response } from '../models/api-v2.model'; import { PlatformCategory } from '../models/platform/platform-category.model'; -export const platformApiCategoryRes: ApiV2Response = { +export const platformApiCategoryRes: ApiV2Response = deepFreeze({ count: 318, data: [ { @@ -19,9 +21,9 @@ export const platformApiCategoryRes: ApiV2Response = { }, ], offset: 0, -}; +}); -export const platformApiAllCategories: ApiV2Response = { +export const platformApiAllCategories: ApiV2Response = deepFreeze({ count: 4, data: [ { @@ -78,9 +80,9 @@ export const platformApiAllCategories: ApiV2Response = { }, ], offset: 0, -}; +}); -export const platformApiCategoryById: ApiV2Response = { +export const platformApiCategoryById: ApiV2Response = deepFreeze({ count: 3, data: [ { @@ -124,9 +126,9 @@ export const platformApiCategoryById: ApiV2Response = { }, ], offset: 0, -}; +}); -export const platformApiCategoriesByName: ApiV2Response = { +export const platformApiCategoriesByName: ApiV2Response = deepFreeze({ count: 3, data: [ { @@ -170,4 +172,4 @@ export const platformApiCategoriesByName: ApiV2Response = { }, ], offset: 0, -}; +}); diff --git a/src/app/core/mock-data/platform-corporate-card-detail.data.ts b/src/app/core/mock-data/platform-corporate-card-detail.data.ts index 178e606498..b62377a1c3 100644 --- a/src/app/core/mock-data/platform-corporate-card-detail.data.ts +++ b/src/app/core/mock-data/platform-corporate-card-detail.data.ts @@ -1,8 +1,10 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PlatformCorporateCardDetail } from '../models/platform-corporate-card-detail.model'; import { mastercardRTFCard, statementUploadedCard, virtualCard, visaRTFCard } from './platform-corporate-card.data'; import { virtualCardCombinedResponse } from './virtual-card-combined-response.data'; -export const virtualCardDetails: PlatformCorporateCardDetail[] = [ +export const virtualCardDetails: PlatformCorporateCardDetail[] = deepFreeze([ { card: virtualCard, stats: { @@ -14,9 +16,9 @@ export const virtualCardDetails: PlatformCorporateCardDetail[] = [ totalAmountValue: 0, }, }, -]; +]); -export const cardDetailsRes: PlatformCorporateCardDetail[] = [ +export const cardDetailsRes: PlatformCorporateCardDetail[] = deepFreeze([ { card: visaRTFCard, stats: { @@ -51,9 +53,9 @@ export const cardDetailsRes: PlatformCorporateCardDetail[] = [ }, }, virtualCardDetails[0], -]; +]); -export const statementUploadedCardDetail: PlatformCorporateCardDetail[] = [ +export const statementUploadedCardDetail: PlatformCorporateCardDetail[] = deepFreeze([ { card: statementUploadedCard, stats: { @@ -65,11 +67,11 @@ export const statementUploadedCardDetail: PlatformCorporateCardDetail[] = [ totalAmountValue: 1874.4, }, }, -]; +]); -export const virtualCardDetailsCombined: PlatformCorporateCardDetail[] = [ +export const virtualCardDetailsCombined: PlatformCorporateCardDetail[] = deepFreeze([ { ...virtualCardDetails[0], - virtualCardDetail: virtualCardCombinedResponse['vc1234'], + virtualCardDetail: virtualCardCombinedResponse.vc1234, }, -]; +]); diff --git a/src/app/core/mock-data/platform-corporate-card.data.ts b/src/app/core/mock-data/platform-corporate-card.data.ts index 399a85d87c..e34e8a02df 100644 --- a/src/app/core/mock-data/platform-corporate-card.data.ts +++ b/src/app/core/mock-data/platform-corporate-card.data.ts @@ -1,8 +1,10 @@ +import deepFreeze from 'deep-freeze-strict'; + import { CardStatus } from '../enums/card-status.enum'; import { DataFeedSource } from '../enums/data-feed-source.enum'; import { PlatformCorporateCard } from '../models/platform/platform-corporate-card.model'; -export const mastercardRTFCard: PlatformCorporateCard = { +export const mastercardRTFCard: PlatformCorporateCard = deepFreeze({ assignor_user_id: 'usvKA4X8Ugcr', bank_name: 'MASTERCARD_BANK', card_number: '555555******5555', @@ -23,9 +25,9 @@ export const mastercardRTFCard: PlatformCorporateCard = { updated_at: '2023-03-03T07:16:46.376082+00:00', user_id: 'usvKA4X8Ugcr', verification_status: 'NOT_VERIFIED', -}; +}); -export const visaRTFCard: PlatformCorporateCard = { +export const visaRTFCard: PlatformCorporateCard = deepFreeze({ assignor_user_id: 'usvKA4X8Ugcr', bank_name: 'VISA_BANK', card_number: '455555******5555', @@ -46,9 +48,9 @@ export const visaRTFCard: PlatformCorporateCard = { updated_at: '2023-03-03T07:16:46.376082+00:00', user_id: 'usvKA4X8Ugcr', verification_status: 'NOT_VERIFIED', -}; +}); -export const statementUploadedCard: PlatformCorporateCard = { +export const statementUploadedCard: PlatformCorporateCard = deepFreeze({ assignor_user_id: 'usvKA4X8Ugcr', bank_name: 'MASTERCARD_BANK', card_number: '5555', @@ -69,9 +71,9 @@ export const statementUploadedCard: PlatformCorporateCard = { updated_at: '2023-03-03T07:16:46.376082+00:00', user_id: 'usvKA4X8Ugcr', verification_status: 'NOT_VERIFIED', -}; +}); -export const virtualCard: PlatformCorporateCard = { +export const virtualCard: PlatformCorporateCard = deepFreeze({ assignor_user_id: 'usvKA4X8Ugcr', bank_name: 'American Express', card_number: '5555', @@ -94,9 +96,9 @@ export const virtualCard: PlatformCorporateCard = { verification_status: 'NOT_VERIFIED', virtual_card_id: 'vc1234', virtual_card_state: CardStatus.PREACTIVE, -}; +}); -export const bankFeedCard: PlatformCorporateCard = { +export const bankFeedCard: PlatformCorporateCard = deepFreeze({ assignor_user_id: 'usvKA4X8Ugcr', bank_name: 'MASTERCARD_BANK', card_number: '555555******5555', @@ -117,9 +119,9 @@ export const bankFeedCard: PlatformCorporateCard = { updated_at: '2023-03-03T07:16:46.376082+00:00', user_id: 'usvKA4X8Ugcr', verification_status: 'NOT_VERIFIED', -}; +}); -export const yodleeCard: PlatformCorporateCard = { +export const yodleeCard: PlatformCorporateCard = deepFreeze({ assignor_user_id: 'usvKA4X8Ugcr', bank_name: 'MASTERCARD_BANK', card_number: '555555******5555', @@ -140,9 +142,9 @@ export const yodleeCard: PlatformCorporateCard = { updated_at: '2023-03-03T07:16:46.376082+00:00', user_id: 'usvKA4X8Ugcr', verification_status: 'NOT_VERIFIED', -}; +}); -export const amexFeedCard: PlatformCorporateCard = { +export const amexFeedCard: PlatformCorporateCard = deepFreeze({ assignor_user_id: 'usvKA4X8Ugcr', bank_name: 'AMEX_BANK', card_number: '**********81000', @@ -163,4 +165,4 @@ export const amexFeedCard: PlatformCorporateCard = { updated_at: '2023-03-03T07:16:46.376082+00:00', user_id: 'usvKA4X8Ugcr', verification_status: 'NOT_VERIFIED', -}; +}); diff --git a/src/app/core/mock-data/platform-cost-centers.data.ts b/src/app/core/mock-data/platform-cost-centers.data.ts index 11d6828cd8..0697d744de 100644 --- a/src/app/core/mock-data/platform-cost-centers.data.ts +++ b/src/app/core/mock-data/platform-cost-centers.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PlatformCostCenter } from '../models/platform/platform-cost-center.model'; import { PlatformApiResponse } from '../models/platform/platform-api-response.model'; -export const platformCostCenterSingleRes: PlatformApiResponse = { +export const platformCostCenterSingleRes: PlatformApiResponse = deepFreeze({ count: 1, data: [ { @@ -16,9 +18,9 @@ export const platformCostCenterSingleRes: PlatformApiResponse = { +export const platformCostCenterMultipleRes: PlatformApiResponse = deepFreeze({ count: 4, data: [ { @@ -63,4 +65,4 @@ export const platformCostCenterMultipleRes: PlatformApiResponse = { +export const platformMileageRates: PlatformApiResponse = deepFreeze({ count: 4, data: [ { @@ -73,9 +75,9 @@ export const platformMileageRates: PlatformApiResponse = { }, ], offset: 0, -}; +}); -export const platformMileageRatesSingleData: PlatformApiResponse = { +export const platformMileageRatesSingleData: PlatformApiResponse = deepFreeze({ count: 1, data: [ { @@ -92,9 +94,9 @@ export const platformMileageRatesSingleData: PlatformApiResponse = { +export const expensePolicyStatesData: PlatformApiResponse = deepFreeze({ count: 1, data: [ { @@ -263,15 +265,15 @@ export const expensePolicyStatesData: PlatformApiResponse = }, ], offset: 0, -}; +}); -export const emptyApiResponse: PlatformApiResponse = { +export const emptyApiResponse: PlatformApiResponse = deepFreeze({ count: 0, data: [], offset: 0, -}; +}); -export const ApproverExpensePolicyStatesData: PlatformApiResponse = { +export const ApproverExpensePolicyStatesData: PlatformApiResponse = deepFreeze({ count: 1, data: [ { @@ -290,9 +292,9 @@ export const ApproverExpensePolicyStatesData: PlatformApiResponse = { +export const platformReportCountData: PlatformApiResponse = deepFreeze({ count: 4, data: [platformReportData], offset: 0, -}; +}); -export const allReportsPaginated1: PlatformApiResponse = { +export const allReportsPaginated1: PlatformApiResponse = deepFreeze({ count: 4, data: [ { @@ -204,9 +206,9 @@ export const allReportsPaginated1: PlatformApiResponse = { }, ], offset: 0, -}; +}); -export const allReportsPaginated2: PlatformApiResponse = { +export const allReportsPaginated2: PlatformApiResponse = deepFreeze({ count: 4, data: [ { @@ -335,10 +337,13 @@ export const allReportsPaginated2: PlatformApiResponse = { }, ], offset: 2, -}; +}); -export const expectedSingleReport: Report[] = [allReportsPaginated1.data[0]]; +export const expectedSingleReport: Report[] = deepFreeze([allReportsPaginated1.data[0]]); -export const expectedReportsSinglePage: Report[] = [...allReportsPaginated1.data]; +export const expectedReportsSinglePage: Report[] = deepFreeze([...allReportsPaginated1.data]); -export const expectedReportsPaginated: Report[] = [...allReportsPaginated1.data, ...allReportsPaginated2.data]; +export const expectedReportsPaginated: Report[] = deepFreeze([ + ...allReportsPaginated1.data, + ...allReportsPaginated2.data, +]); diff --git a/src/app/core/mock-data/platform/v1/advance-request-platform.data.ts b/src/app/core/mock-data/platform/v1/advance-request-platform.data.ts index 2d8a713e27..d7629a5d0c 100644 --- a/src/app/core/mock-data/platform/v1/advance-request-platform.data.ts +++ b/src/app/core/mock-data/platform/v1/advance-request-platform.data.ts @@ -1,10 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { cloneDeep } from 'lodash'; import { CustomFieldTypes } from 'src/app/core/enums/platform/v1/custom-fields-type.enum'; -import { AdvanceRequestState } from 'src/app/core/models/advance-request-state.model'; import { AdvanceRequestPlatform } from 'src/app/core/models/platform/advance-request-platform.model'; import { PlatformApiResponse } from 'src/app/core/models/platform/platform-api-response.model'; -export const advanceRequestPlatform: PlatformApiResponse = { +export const advanceRequestPlatform: PlatformApiResponse = deepFreeze({ count: 1, offset: 0, data: [ @@ -87,9 +88,9 @@ export const advanceRequestPlatform: PlatformApiResponse ], }, ], -}; +}); -export const advanceRequestPlatformPulledBack: PlatformApiResponse = { +export const advanceRequestPlatformPulledBack: PlatformApiResponse = deepFreeze({ count: 1, offset: 0, data: [ @@ -99,9 +100,9 @@ export const advanceRequestPlatformPulledBack: PlatformApiResponse = { +export const advanceRequestPlatformSentBack: PlatformApiResponse = deepFreeze({ count: 1, offset: 0, data: [ @@ -111,4 +112,4 @@ export const advanceRequestPlatformSentBack: PlatformApiResponse; -const mileageCategory: Category = { +const mileageCategory: Category = deepFreeze({ code: null, display_name: 'mileage display', id: 267841, name: 'Mileage', sub_category: 'Others', system_category: 'Mileage', -}; +}); -const perDiemCategory = { +const perDiemCategory = deepFreeze({ code: null, display_name: 'Per Diem display', id: 267841, name: 'Per Diem', sub_category: 'Others', system_category: 'Per Diem', -}; +}); -export const mileageExpenseWithDistance: Expense = { +export const mileageExpenseWithDistance: Expense = deepFreeze({ ...expenseData, distance: 25, distance_unit: MileageUnitEnum.KM, category: mileageCategory, -}; +}); -export const mileageExpenseWithoutDistance: Expense = { +export const mileageExpenseWithoutDistance: Expense = deepFreeze({ ...expenseData, distance: 0, distance_unit: MileageUnitEnum.KM, category: mileageCategory, -}; +}); -export const perDiemExpenseWithSingleNumDays: Expense = { +export const perDiemExpenseWithSingleNumDays: Expense = deepFreeze({ ...expenseData, category: perDiemCategory, per_diem_num_days: 1, -}; +}); -export const perDiemExpenseWithMultipleNumDays: Expense = { +export const perDiemExpenseWithMultipleNumDays: Expense = deepFreeze({ ...expenseData, category: perDiemCategory, per_diem_num_days: 3, -}; +}); -export const apiExpenses1: Expense[] = [ +export const apiExpenses1: Expense[] = deepFreeze([ { accounting_export_summary: {}, @@ -1715,25 +1717,25 @@ export const apiExpenses1: Expense[] = [ user_id: 'usuQPzaT0w9C', verifier_comments: [], }, -]; +]); -export const perDiemExpenseWithSingleNumDays2: Expense = { +export const perDiemExpenseWithSingleNumDays2: Expense = deepFreeze({ ...perDiemExpenseWithSingleNumDays, category: { ...perDiemExpenseWithSingleNumDays.category, name: 'Per Diem', }, -}; +}); -export const mileageExpenseWithDistance2: Expense = { +export const mileageExpenseWithDistance2: Expense = deepFreeze({ ...mileageExpenseWithDistance, category: { ...mileageExpenseWithDistance.category, name: 'Mileage', }, -}; +}); -export const readyToReportExpensesData: Expense[] = [ +export const readyToReportExpensesData: Expense[] = deepFreeze([ { ...expenseData, amount: 50, @@ -1744,9 +1746,9 @@ export const readyToReportExpensesData: Expense[] = [ amount: 100, id: 'txWjW9qT2Vf1', }, -]; +]); -export const readyToReportExpensesData2: Expense[] = [ +export const readyToReportExpensesData2: Expense[] = deepFreeze([ { ...expenseData, amount: 100, @@ -1759,19 +1761,19 @@ export const readyToReportExpensesData2: Expense[] = [ is_reimbursable: true, id: 'txWjW9qT2Vf1', }, -]; +]); -export const nonReimbursableExpense: Expense = { +export const nonReimbursableExpense: Expense = deepFreeze({ ...expenseData, is_reimbursable: false, -}; +}); -export const draftExpense: Expense = { +export const draftExpense: Expense = deepFreeze({ ...expenseData, state: ExpenseState.DRAFT, -}; +}); -export const splitExpensesData: Expense[] = [ +export const splitExpensesData: Expense[] = deepFreeze([ { accounting_export_summary: {}, added_to_report_at: null, @@ -2068,11 +2070,11 @@ export const splitExpensesData: Expense[] = [ verifications: [], verifier_comments: [], }, -]; +]); -export const apiExpenses2: Expense[] = [splitExpensesData[0]]; +export const apiExpenses2: Expense[] = deepFreeze([splitExpensesData[0]]); -export const apiExpenses3: Expense[] = [ +export const apiExpenses3: Expense[] = deepFreeze([ { accounting_export_summary: {}, added_to_report_at: null, @@ -2369,9 +2371,9 @@ export const apiExpenses3: Expense[] = [ verifications: [], verifier_comments: [], }, -]; +]); -export const platformExpenseData: Expense = { +export const platformExpenseData: Expense = deepFreeze({ accounting_export_summary: {}, added_to_report_at: null, admin_amount: null, @@ -2535,9 +2537,9 @@ export const platformExpenseData: Expense = { }, user_id: 'usvMoPfCC9Xw', verifier_comments: ['Amount changed due to following reason(s) : No policy violation explanation provided'], -}; +}); -export const platformExpenseDataWithSubCategory: Expense = { +export const platformExpenseDataWithSubCategory: Expense = deepFreeze({ accounting_export_summary: {}, added_to_report_at: null, id: 'txD5hIQgLuR5', @@ -2755,19 +2757,19 @@ export const platformExpenseDataWithSubCategory: Expense = { user_id: 'usvMoPfCC9Xw', verifications: [], verifier_comments: [], -}; +}); -export const platformExpenseDataWithReportId: Expense = { +export const platformExpenseDataWithReportId: Expense = deepFreeze({ ...platformExpenseDataWithSubCategory, report_id: 'rpbNc3kn5baq', -}; +}); -export const platformExpenseDataWithReportId2: Expense = { +export const platformExpenseDataWithReportId2: Expense = deepFreeze({ ...platformExpenseDataWithSubCategory, report_id: 'rplD17WeBlha', -}; +}); -export const platformExpenseWithExtractedData: Expense = { +export const platformExpenseWithExtractedData: Expense = deepFreeze({ accounting_export_summary: {}, added_to_report_at: null, admin_amount: null, @@ -2959,9 +2961,9 @@ export const platformExpenseWithExtractedData: Expense = { user_id: 'usvMoPfCC9Xw', verifications: [], verifier_comments: [], -}; +}); -export const platformExpenseWithExtractedData2: Expense = { +export const platformExpenseWithExtractedData2: Expense = deepFreeze({ ...platformExpenseWithExtractedData, category: { code: null, @@ -2979,9 +2981,9 @@ export const platformExpenseWithExtractedData2: Expense = { invoice_dt: null, vendor_name: 'SWIGGY', }, -}; +}); -export const platformExpenseWithMatchCCC: Expense = { +export const platformExpenseWithMatchCCC: Expense = deepFreeze({ accounting_export_summary: {}, added_to_report_at: null, admin_amount: null, @@ -3139,26 +3141,26 @@ export const platformExpenseWithMatchCCC: Expense = { user_id: 'usvMoPfCC9Xw', verifications: [], verifier_comments: [], -}; +}); -export const platformExpenseWithMatchCCC2: Expense = { +export const platformExpenseWithMatchCCC2: Expense = deepFreeze({ ...platformExpenseWithMatchCCC, matched_corporate_card_transaction_ids: [], matched_corporate_card_transactions: [], -}; +}); -export const mileageCategoryPlatformExpenseData: Expense = { +export const mileageCategoryPlatformExpenseData: Expense = deepFreeze({ ...platformExpenseData, category: { ...platformExpenseData.category, name: 'MILEAGE' }, -}; +}); -export const perDiemCategoryPlatformExpenseData: Expense = { +export const perDiemCategoryPlatformExpenseData: Expense = deepFreeze({ ...platformExpenseData, category: { ...platformExpenseData.category, name: 'PER DIEM' }, -}; +}); -export const expensesList: Expense[] = [ +export const expensesList: Expense[] = deepFreeze([ { ...platformExpenseData, }, -]; +]); diff --git a/src/app/core/mock-data/platform/v1/expenses-query-params.data.ts b/src/app/core/mock-data/platform/v1/expenses-query-params.data.ts index 40e0d70692..02ad78504b 100644 --- a/src/app/core/mock-data/platform/v1/expenses-query-params.data.ts +++ b/src/app/core/mock-data/platform/v1/expenses-query-params.data.ts @@ -1,23 +1,25 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ExpensesQueryParams } from 'src/app/core/models/platform/v1/expenses-query-params.model'; -export const getExpensesQueryParams: ExpensesQueryParams = { +export const getExpensesQueryParams: ExpensesQueryParams = deepFreeze({ report_id: 'eq.txOJVaaPxo9O', -}; +}); -export const allExpensesQueryParams: ExpensesQueryParams = { +export const allExpensesQueryParams: ExpensesQueryParams = deepFreeze({ queryParams: { employee_id: 'eq.out3t2X258rd', state: ['in.(COMPLETE)'], or: ['(policy_amount.is.null,policy_amount.gt.0.0001)'], report_id: ['is.null'], }, -}; +}); -export const unreportedExpensesQueryParams: ExpensesQueryParams = { +export const unreportedExpensesQueryParams: ExpensesQueryParams = deepFreeze({ queryParams: { state: 'in.(COMPLETE)', or: '(policy_amount.is.null,policy_amount.gt.0.0001)', report_id: 'is.null', and: '(or(matched_corporate_card_transactions.eq.[],matched_corporate_card_transactions->0->status.neq.PENDING))', }, -}; +}); diff --git a/src/app/core/mock-data/platform/v1/expenses-response.data.ts b/src/app/core/mock-data/platform/v1/expenses-response.data.ts index 1910619b58..4efbbcf16b 100644 --- a/src/app/core/mock-data/platform/v1/expenses-response.data.ts +++ b/src/app/core/mock-data/platform/v1/expenses-response.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PlatformApiResponse } from 'src/app/core/models/platform/platform-api-response.model'; import { expenseData } from './expense.data'; import { Expense } from 'src/app/core/models/platform/v1/expense.model'; -export const expensesResponse: PlatformApiResponse = { +export const expensesResponse: PlatformApiResponse = deepFreeze({ count: 1, data: [expenseData], offset: 0, -}; +}); diff --git a/src/app/core/mock-data/platform/v1/expenses-stats.data.ts b/src/app/core/mock-data/platform/v1/expenses-stats.data.ts index ee6a3c4010..94153ebc25 100644 --- a/src/app/core/mock-data/platform/v1/expenses-stats.data.ts +++ b/src/app/core/mock-data/platform/v1/expenses-stats.data.ts @@ -1,27 +1,29 @@ -export const completeStats = { +import deepFreeze from 'deep-freeze-strict'; + +export const completeStats = deepFreeze({ data: { count: 3, total_amount: 30, }, -}; +}); -export const emptyStats = { +export const emptyStats = deepFreeze({ data: { count: 0, total_amount: 0, }, -}; +}); -export const incompleteStats = { +export const incompleteStats = deepFreeze({ data: { count: 339, total_amount: 76234.4729069240282984, }, -}; +}); -export const completeStats1 = { +export const completeStats1 = deepFreeze({ data: { count: 4, total_amount: 3494, }, -}; +}); diff --git a/src/app/core/mock-data/policy-violation.data.ts b/src/app/core/mock-data/policy-violation.data.ts index 115af74d77..a17d78e82d 100644 --- a/src/app/core/mock-data/policy-violation.data.ts +++ b/src/app/core/mock-data/policy-violation.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PolicyViolation } from '../models/policy-violation.model'; import { PolicyViolationTxn } from '../models/policy-violation-txn.model'; -export const policyViolation1: PolicyViolation = { +export const policyViolation1: PolicyViolation = deepFreeze({ data: { final_desired_state: { add_approver_user_ids: [], @@ -13,9 +15,9 @@ export const policyViolation1: PolicyViolation = { }, individual_desired_states: [], }, -}; +}); -export const splitPolicyExp2: PolicyViolation = { +export const splitPolicyExp2: PolicyViolation = deepFreeze({ data: { final_desired_state: { add_approver_user_ids: [], @@ -32,9 +34,9 @@ export const splitPolicyExp2: PolicyViolation = { currency: 'USD', name: 'Food', type: 'category', -}; +}); -export const splitPolicyExp3: PolicyViolation = { +export const splitPolicyExp3: PolicyViolation = deepFreeze({ data: { final_desired_state: { add_approver_user_ids: [], @@ -51,14 +53,14 @@ export const splitPolicyExp3: PolicyViolation = { currency: 'USD', name: 'Food / Travelling - Inland', type: 'category', -}; +}); -export const policyVoilationData2: PolicyViolationTxn = { +export const policyVoilationData2: PolicyViolationTxn = deepFreeze({ txVHydZVrGYC: splitPolicyExp2, tx4QhcvNHpuh: splitPolicyExp3, -}; +}); -export const splitPolicyExp4: PolicyViolation = { +export const splitPolicyExp4: PolicyViolation = deepFreeze({ data: { final_desired_state: { add_approver_user_ids: [], @@ -95,9 +97,9 @@ export const splitPolicyExp4: PolicyViolation = { currency: 'INR', name: '1 / chumma returns', type: 'category', -}; +}); -export const splitPolicyExp5: PolicyViolation = { +export const splitPolicyExp5: PolicyViolation = deepFreeze({ data: { final_desired_state: { add_approver_user_ids: [], @@ -146,19 +148,19 @@ export const splitPolicyExp5: PolicyViolation = { currency: 'INR', name: '1 / sd', type: 'category', -}; +}); -export const policyViolationData3: PolicyViolationTxn = { +export const policyViolationData3: PolicyViolationTxn = deepFreeze({ txc2KIogxUAy: splitPolicyExp4, txgfkvuYteta: splitPolicyExp5, -}; +}); -export const policyViolationData4: PolicyViolationTxn = { +export const policyViolationData4: PolicyViolationTxn = deepFreeze({ txSEM4DtjyKR: splitPolicyExp4, txNyI8ot5CuJ: splitPolicyExp5, -}; +}); -export const policyViolationData5: PolicyViolation = { +export const policyViolationData5: PolicyViolation = deepFreeze({ amount: 122, currency: 'INR', name: 'Food', @@ -175,4 +177,4 @@ export const policyViolationData5: PolicyViolation = { run_summary: [], }, }, -}; +}); diff --git a/src/app/core/mock-data/policy-violcation-comment.data.ts b/src/app/core/mock-data/policy-violcation-comment.data.ts index e72023bd00..571c9d9d72 100644 --- a/src/app/core/mock-data/policy-violcation-comment.data.ts +++ b/src/app/core/mock-data/policy-violcation-comment.data.ts @@ -1,46 +1,48 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PolicyViolationComment } from '../models/policy-violation-comment.model'; -export const violationComment1: PolicyViolationComment = { +export const violationComment1: PolicyViolationComment = deepFreeze({ objectType: 'reports', txnId: 'rpkpSa8guCuR', comment: { comment: 'a comment', }, notify: false, -}; +}); -export const violationComment2: PolicyViolationComment = { +export const violationComment2: PolicyViolationComment = deepFreeze({ objectType: 'transactions', txnId: 'txxkBruL0EO9', comment: { comment: 'Policy violation explanation: another comment', }, notify: true, -}; +}); -export const violationComment3: PolicyViolationComment = { +export const violationComment3: PolicyViolationComment = deepFreeze({ objectType: 'transactions', txnId: 'txNVtsqF8Siq', comment: { comment: 'No policy violation explanation provided', }, notify: true, -}; +}); -export const violationComment4: PolicyViolationComment = { +export const violationComment4: PolicyViolationComment = deepFreeze({ objectType: 'transactions', txnId: 'txeqxj49dgh', comment: { comment: 'Policy violation explanation: test comment 1', }, notify: true, -}; +}); -export const violationComment5: PolicyViolationComment = { +export const violationComment5: PolicyViolationComment = deepFreeze({ objectType: 'transactions', txnId: 'txeqxj89ddf', comment: { comment: 'No policy violation explanation provided', }, notify: true, -}; +}); diff --git a/src/app/core/mock-data/popover-params.data.ts b/src/app/core/mock-data/popover-params.data.ts index 40a7190042..9a6b6f8075 100644 --- a/src/app/core/mock-data/popover-params.data.ts +++ b/src/app/core/mock-data/popover-params.data.ts @@ -1,13 +1,15 @@ -export const getMarkDismissModalParamsData1 = { +import deepFreeze from 'deep-freeze-strict'; + +export const getMarkDismissModalParamsData1 = deepFreeze({ header: 'Dismiss this expense?', body: "This corporate card expense will be dismissed and you won't be able to edit it.\nDo you wish to proceed?", ctaText: 'Yes', ctaLoadingText: 'Dismissing', -}; +}); -export const getMarkDismissModalParamsData2 = { +export const getMarkDismissModalParamsData2 = deepFreeze({ header: 'Mark Expense as Personal', body: "This corporate card expense will be marked as personal and you won't be able to edit it.\nDo you wish to proceed?", ctaText: 'Yes', ctaLoadingText: 'Marking', -}; +}); diff --git a/src/app/core/mock-data/popup.data.ts b/src/app/core/mock-data/popup.data.ts index d7ed61d21e..9af71dd11a 100644 --- a/src/app/core/mock-data/popup.data.ts +++ b/src/app/core/mock-data/popup.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { PopupConfig } from 'src/app/shared/components/fy-popup/popup.model'; -export const popupConfigData: PopupConfig = { +export const popupConfigData: PopupConfig = deepFreeze({ header: 'Delete Report?', message: `

@@ -13,20 +15,20 @@ export const popupConfigData: PopupConfig = { primaryCta: { text: 'Delete', }, -}; +}); -export const popupConfigData2: PopupConfig = { +export const popupConfigData2: PopupConfig = deepFreeze({ header: 'Cannot Delete Report', message: 'Report cannot be deleted', primaryCta: { text: 'Close', }, -}; +}); -export const popupConfigData3: PopupConfig = { +export const popupConfigData3: PopupConfig = deepFreeze({ header: 'Confirm', message: 'Are you sure you want to delete this Advance Request', primaryCta: { text: 'Delete Advance Request', }, -}; +}); diff --git a/src/app/core/mock-data/project-dependent-fields-mapping.data.ts b/src/app/core/mock-data/project-dependent-fields-mapping.data.ts index c1d347e901..f11592cfd4 100644 --- a/src/app/core/mock-data/project-dependent-fields-mapping.data.ts +++ b/src/app/core/mock-data/project-dependent-fields-mapping.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ProjectDependentFieldsMapping } from '../models/project-dependent-fields-mapping.model'; import { dependentCustomProperties } from './custom-property.data'; -export const projectDependentFieldsMappingData1: ProjectDependentFieldsMapping = { +export const projectDependentFieldsMappingData1: ProjectDependentFieldsMapping = deepFreeze({ 3943: dependentCustomProperties, 3944: dependentCustomProperties, -}; +}); diff --git a/src/app/core/mock-data/public-policy-expense.data.ts b/src/app/core/mock-data/public-policy-expense.data.ts index 964a3dbb1d..395622aee8 100644 --- a/src/app/core/mock-data/public-policy-expense.data.ts +++ b/src/app/core/mock-data/public-policy-expense.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ExpensePolicy } from '../models/platform/platform-expense-policy.model'; import { PolicyViolation } from '../models/policy-violation.model'; import { PublicPolicyExpense } from '../models/public-policy-expense.model'; import { optionsData15 } from './merge-expenses-options-data.data'; -export const publicPolicyExpenseData1: PublicPolicyExpense = { +export const publicPolicyExpenseData1: PublicPolicyExpense = deepFreeze({ skip_reimbursement: false, source: 'MOBILE', state: 'COMPLETE', @@ -121,39 +123,39 @@ export const publicPolicyExpenseData1: PublicPolicyExpense = { user_reason_for_duplicate_expenses: '', vendor: 'Uber', vendor_id: 0, -}; +}); -export const publicPolicyExpenseData2: PublicPolicyExpense = { +export const publicPolicyExpenseData2: PublicPolicyExpense = deepFreeze({ ...publicPolicyExpenseData1, fyle_category: 'airlines', -}; +}); -export const publicPolicyExpenseData3: PublicPolicyExpense = { +export const publicPolicyExpenseData3: PublicPolicyExpense = deepFreeze({ ...publicPolicyExpenseData1, fyle_category: 'bus', -}; +}); -export const publicPolicyExpenseData4: PublicPolicyExpense = { +export const publicPolicyExpenseData4: PublicPolicyExpense = deepFreeze({ ...publicPolicyExpenseData1, fyle_category: 'train', -}; +}); -export const publicPolicyExpenseData5: PublicPolicyExpense = { +export const publicPolicyExpenseData5: PublicPolicyExpense = deepFreeze({ ...publicPolicyExpenseData1, skip_reimbursement: null, -}; +}); -export const publicPolicyExpenseData6: PublicPolicyExpense = { +export const publicPolicyExpenseData6: PublicPolicyExpense = deepFreeze({ ...publicPolicyExpenseData1, locations: null, -}; +}); -export const publicPolicyExpenseData7: PublicPolicyExpense = { +export const publicPolicyExpenseData7: PublicPolicyExpense = deepFreeze({ ...publicPolicyExpenseData1, fyle_category: null, -}; +}); -export const expensePolicyData: ExpensePolicy = { +export const expensePolicyData: ExpensePolicy = deepFreeze({ data: { final_desired_state: { add_approver_user_ids: [], @@ -192,9 +194,9 @@ export const expensePolicyData: ExpensePolicy = { }, ], }, -}; +}); -export const policyViolationData: PolicyViolation = { +export const policyViolationData: PolicyViolation = deepFreeze({ data: { individual_desired_states: [ { @@ -238,13 +240,13 @@ export const policyViolationData: PolicyViolation = { currency: 'INR', name: 'Policy Violation 1', type: 'Expense Policy', -}; +}); -export const violations: { [id: string]: PolicyViolation } = { +export const violations: { [id: string]: PolicyViolation } = deepFreeze({ txVTmNOp5JEa: policyViolationData, -}; +}); -export const splitPolicyExp: PublicPolicyExpense = { +export const splitPolicyExp: PublicPolicyExpense = deepFreeze({ ...publicPolicyExpenseData1, id: 'txqhb1IwrujH', org_user_id: 'ouX8dwsbLCLv', @@ -252,9 +254,9 @@ export const splitPolicyExp: PublicPolicyExpense = { txn_dt: new Date('2023-02-15T06:30:00.000Z'), amount: 20.4, user_amount: 20.4, -}; +}); -export const splitTransactionData1: PublicPolicyExpense = { +export const splitTransactionData1: PublicPolicyExpense = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -356,9 +358,9 @@ export const splitTransactionData1: PublicPolicyExpense = { proposed_exchange_rate: 0, status_id: '', updated_at: undefined, -}; +}); -export const publicPolicyExpenseDataFromTxn: PublicPolicyExpense = { +export const publicPolicyExpenseDataFromTxn: PublicPolicyExpense = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -486,4 +488,4 @@ export const publicPolicyExpenseDataFromTxn: PublicPolicyExpense = { proposed_exchange_rate: 0, status_id: '', updated_at: undefined, -}; +}); diff --git a/src/app/core/mock-data/recent-local-storage-items.data.ts b/src/app/core/mock-data/recent-local-storage-items.data.ts index 6ec24628e7..77672f6d8b 100644 --- a/src/app/core/mock-data/recent-local-storage-items.data.ts +++ b/src/app/core/mock-data/recent-local-storage-items.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { RecentLocalStorageItems } from '../models/recent-local-storage-items.model'; -export const recentLocalStorageItemsRes: RecentLocalStorageItems[] = [ +export const recentLocalStorageItemsRes: RecentLocalStorageItems[] = deepFreeze([ { label: '12232', value: { @@ -18,9 +20,9 @@ export const recentLocalStorageItemsRes: RecentLocalStorageItems[] = [ selected: false, custom: false, }, -]; +]); -export const recentItemsRes: RecentLocalStorageItems[] = [ +export const recentItemsRes: RecentLocalStorageItems[] = deepFreeze([ { label: 'New New Mileage', value: { @@ -55,9 +57,9 @@ export const recentItemsRes: RecentLocalStorageItems[] = [ selected: false, custom: false, }, -]; +]); -export const itemsRes: RecentLocalStorageItems = { +export const itemsRes: RecentLocalStorageItems = deepFreeze({ label: 'New New Mileage', value: { code: null, @@ -73,11 +75,11 @@ export const itemsRes: RecentLocalStorageItems = { }, selected: false, custom: false, -}; +}); export const propertyRes = 'label'; -export const postRecentItemsRes: RecentLocalStorageItems[] = [ +export const postRecentItemsRes: RecentLocalStorageItems[] = deepFreeze([ { label: 'New New Mileage', value: { @@ -129,4 +131,4 @@ export const postRecentItemsRes: RecentLocalStorageItems[] = [ selected: false, custom: false, }, -]; +]); diff --git a/src/app/core/mock-data/recently-used.data.ts b/src/app/core/mock-data/recently-used.data.ts index 680adf7925..80cbb21cf7 100644 --- a/src/app/core/mock-data/recently-used.data.ts +++ b/src/app/core/mock-data/recently-used.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { RecentlyUsed } from '../models/v1/recently_used.model'; import { ExtendedProject } from '../models/v2/extended-project.model'; import { Currency, CurrencyName } from '../models/currency.model'; import { CostCenter } from '../models/v1/cost-center.model'; -export const recentlyUsedRes: RecentlyUsed = { +export const recentlyUsedRes: RecentlyUsed = deepFreeze({ recent_project_ids: [168826, 247943, 247946], recent_org_category_ids: [89469, 129111, 16576], recent_cost_center_ids: [6671, 6725, 89, 2406], @@ -24,9 +26,9 @@ export const recentlyUsedRes: RecentlyUsed = { '16/10, 16/10, Mariyamman Kovil St, Vagai Nagar, Ramanathapuram, Tamil Nadu 623504, India', 'mg road race', ], -}; +}); -export const recentlyUsedProjectRes: ExtendedProject[] = [ +export const recentlyUsedProjectRes: ExtendedProject[] = deepFreeze([ { ap1_email: 'john.d@fyle.in', ap1_full_name: 'John Doe', @@ -85,9 +87,9 @@ export const recentlyUsedProjectRes: ExtendedProject[] = [ projectv2_name: 'AcuVision Eye Centre', sub_project_name: null, }, -]; +]); -export const recentCurrencyRes: Currency[] = [ +export const recentCurrencyRes: Currency[] = deepFreeze([ { shortCode: 'ARS', longName: 'Argentine Peso', @@ -104,94 +106,95 @@ export const recentCurrencyRes: Currency[] = [ shortCode: 'CLP', longName: 'Chilean Peso', }, -]; +]); -export const currencies: CurrencyName = { +export const currencies: CurrencyName = deepFreeze({ ARS: 'Argentine Peso', INR: 'Indian Rupee', EUR: 'Euro', CLP: 'Chilean Peso', -}; +}); -export const recentlyUsedResWithoutCurr = { +export const recentlyUsedResWithoutCurr = deepFreeze({ ...recentlyUsedRes, recent_currencies: [], -}; +}); -export const recentlyUsedResWithoutCostCenterId = { +export const recentlyUsedResWithoutCostCenterId = deepFreeze({ ...recentlyUsedRes, recent_cost_center_ids: [], -}; +}); -export const recentlyUsedCategoryWithoutId = { +export const recentlyUsedCategoryWithoutId = deepFreeze({ ...recentlyUsedRes, recent_org_category_ids: [], -}; +}); -export const costCentersResWithNonMatchingIds = { +export const costCentersResWithNonMatchingIds = deepFreeze({ ...recentlyUsedRes, recent_cost_center_ids: [2456, 2457, 3457, 3458], -}; +}); -export const recentlyUsedCostCentersRes: Partial<{ label: string; value: CostCenter; selected?: boolean }[]> = [ - { - label: 'Cost center 1', - value: { - active: true, - code: '92344', - created_at: new Date('2020-10-27T17:07:55.516633+00:00'), - description: 'This is the description for cost center 1', - id: 6671, - name: 'Cost center 1', - org_id: 'orNVthTo2Zyo', - updated_at: new Date('2020-10-27T17:08:13.441319+00:00'), +export const recentlyUsedCostCentersRes: Partial<{ label: string; value: CostCenter; selected?: boolean }[]> = + deepFreeze([ + { + label: 'Cost center 1', + value: { + active: true, + code: '92344', + created_at: new Date('2020-10-27T17:07:55.516633+00:00'), + description: 'This is the description for cost center 1', + id: 6671, + name: 'Cost center 1', + org_id: 'orNVthTo2Zyo', + updated_at: new Date('2020-10-27T17:08:13.441319+00:00'), + }, }, - }, - { - label: 'Cost center 2', - value: { - active: true, - code: 'A very long cost center code', - created_at: new Date('2020-12-08T03:11:07.653324+00:00'), - description: 'This is the description for cost center 2', - id: 6725, - name: 'Cost center 2', - org_id: 'orNVthTo2Zyo', - updated_at: new Date('2022-07-14T13:13:56.757449+00:00'), + { + label: 'Cost center 2', + value: { + active: true, + code: 'A very long cost center code', + created_at: new Date('2020-12-08T03:11:07.653324+00:00'), + description: 'This is the description for cost center 2', + id: 6725, + name: 'Cost center 2', + org_id: 'orNVthTo2Zyo', + updated_at: new Date('2022-07-14T13:13:56.757449+00:00'), + }, }, - }, - { - label: 'Cost center 3', - value: { - active: true, - code: 'Administrion', - created_at: new Date('2019-02-01T06:59:07.889634+00:00'), - description: 'This is the description for cost center 3', - id: 89, - name: 'Cost center 3', - org_id: 'orNVthTo2Zyo', - updated_at: new Date('2019-08-28T10:11:41.004307+00:00'), + { + label: 'Cost center 3', + value: { + active: true, + code: 'Administrion', + created_at: new Date('2019-02-01T06:59:07.889634+00:00'), + description: 'This is the description for cost center 3', + id: 89, + name: 'Cost center 3', + org_id: 'orNVthTo2Zyo', + updated_at: new Date('2019-08-28T10:11:41.004307+00:00'), + }, }, - }, - { - label: 'Cost center 4', - value: { - active: true, - code: 'code1', - created_at: new Date('2019-06-24T08:25:08.307285+00:00'), - description: 'This is the description for cost center 4', - id: 2406, - name: 'Cost center 4', - org_id: 'orNVthTo2Zyo', - updated_at: new Date('2022-09-08T19:17:19.671789+00:00'), + { + label: 'Cost center 4', + value: { + active: true, + code: 'code1', + created_at: new Date('2019-06-24T08:25:08.307285+00:00'), + description: 'This is the description for cost center 4', + id: 2406, + name: 'Cost center 4', + org_id: 'orNVthTo2Zyo', + updated_at: new Date('2022-09-08T19:17:19.671789+00:00'), + }, }, - }, -]; + ]); export const recentlyUsedMileages: Pick< RecentlyUsed, 'recent_start_locations' | 'recent_end_locations' | 'recent_locations' -> = { +> = deepFreeze({ recent_start_locations: [ 'MG Road, Halasuru, Yellappa Chetty Layout, Sivanchetti Gardens, Bengaluru, Karnataka, India', 'MG Road, Yellappa Chetty Layout, Sivanchetti Gardens, Halasuru, Karnataka, India', @@ -207,4 +210,4 @@ export const recentlyUsedMileages: Pick< '16/10, 16/10, Mariyamman Kovil St, Vagai Nagar, Ramanathapuram, Tamil Nadu 623504, India', 'mg road race', ], -}; +}); diff --git a/src/app/core/mock-data/report-actions.data.ts b/src/app/core/mock-data/report-actions.data.ts index f57c7f2aab..6f265172db 100644 --- a/src/app/core/mock-data/report-actions.data.ts +++ b/src/app/core/mock-data/report-actions.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ReportActions } from '../models/report-actions.model'; -export const apiReportActions: ReportActions = { +export const apiReportActions: ReportActions = deepFreeze({ id: 'rpxtbiLXQZUm', can_resubmit: false, can_approve: false, @@ -13,4 +15,4 @@ export const apiReportActions: ReportActions = { can_payment_pending: false, can_undo_payment_pending: false, can_inquire: true, -}; +}); diff --git a/src/app/core/mock-data/report-auto-submission-details.data.ts b/src/app/core/mock-data/report-auto-submission-details.data.ts index 246a2ad574..c30eddc032 100644 --- a/src/app/core/mock-data/report-auto-submission-details.data.ts +++ b/src/app/core/mock-data/report-auto-submission-details.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ReportAutoSubmissionDetails } from '../models/report-auto-submission-details.model'; -export const apiReportAutoSubmissionDetails: ReportAutoSubmissionDetails = { +export const apiReportAutoSubmissionDetails: ReportAutoSubmissionDetails = deepFreeze({ data: { next_at: new Date('2023-02-01T00:00:00.000000'), }, -}; +}); diff --git a/src/app/core/mock-data/report-options.data.ts b/src/app/core/mock-data/report-options.data.ts index 7ab871b442..86e3045be4 100644 --- a/src/app/core/mock-data/report-options.data.ts +++ b/src/app/core/mock-data/report-options.data.ts @@ -1,8 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ReportOptions } from '../models/report-options.model'; -import { expectedErpt, expectedUnflattenedReports } from './report-unflattened.data'; import { expectedReportsPaginated } from './platform-report.data'; // TODO: update the spec file for fy-add-to-report component to use these mock data in next pr -hp -export const reportOptionsData: ReportOptions[] = [ +export const reportOptionsData: ReportOptions[] = deepFreeze([ { label: 'report1', value: expectedReportsPaginated[0], @@ -11,16 +12,16 @@ export const reportOptionsData: ReportOptions[] = [ label: 'report2', value: expectedReportsPaginated[1], }, -]; +]); -export const reportOptionsData2: ReportOptions[] = [ +export const reportOptionsData2: ReportOptions[] = deepFreeze([ { label: 'report1', value: expectedReportsPaginated[0], }, -]; +]); -export const reportOptionsData3: ReportOptions[] = [ +export const reportOptionsData3: ReportOptions[] = deepFreeze([ { label: '#8: Jan 2023', value: expectedReportsPaginated[0], @@ -37,9 +38,9 @@ export const reportOptionsData3: ReportOptions[] = [ label: '#4: Jan 2023', value: expectedReportsPaginated[3], }, -]; +]); -export const reportOptionsData4 = [ +export const reportOptionsData4 = deepFreeze([ { label: '#8: Jan 2023', value: { @@ -284,4 +285,4 @@ export const reportOptionsData4 = [ }, }, }, -]; +]); diff --git a/src/app/core/mock-data/report-stats-data.data.ts b/src/app/core/mock-data/report-stats-data.data.ts index 18f49e6ed9..5c82bf5e1c 100644 --- a/src/app/core/mock-data/report-stats-data.data.ts +++ b/src/app/core/mock-data/report-stats-data.data.ts @@ -1,15 +1,17 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ReportStatsData } from '../models/report-stats-data.model'; import { expectedReportStats } from './report-stats.data'; -export const reportStatsData1: ReportStatsData = { +export const reportStatsData1: ReportStatsData = deepFreeze({ reportStats: expectedReportStats, simplifyReportsSettings: { enabled: true }, homeCurrency: 'INR', currencySymbol: '₹', isNonReimbursableOrg: false, -}; +}); -export const reportStatsData2: ReportStatsData = { +export const reportStatsData2: ReportStatsData = deepFreeze({ ...reportStatsData1, simplifyReportsSettings: { enabled: undefined }, -}; +}); diff --git a/src/app/core/mock-data/report-stats.data.ts b/src/app/core/mock-data/report-stats.data.ts index fccb6d9720..a0654d6f89 100644 --- a/src/app/core/mock-data/report-stats.data.ts +++ b/src/app/core/mock-data/report-stats.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ReportStats } from '../models/report-stats.model'; -export const expectedReportStats: ReportStats = { +export const expectedReportStats: ReportStats = deepFreeze({ draft: { count: 6, sum: 93165.91, @@ -21,9 +23,9 @@ export const expectedReportStats: ReportStats = { count: 7, sum: 5012.12, }, -}; +}); -export const expectedEmptyReportStats: ReportStats = { +export const expectedEmptyReportStats: ReportStats = deepFreeze({ draft: { sum: 0, count: 0, @@ -44,4 +46,4 @@ export const expectedEmptyReportStats: ReportStats = { sum: 0, count: 0, }, -}; +}); diff --git a/src/app/core/mock-data/report-unflattened.data.ts b/src/app/core/mock-data/report-unflattened.data.ts index 782e2b1c2d..48d7826eb1 100644 --- a/src/app/core/mock-data/report-unflattened.data.ts +++ b/src/app/core/mock-data/report-unflattened.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { UnflattenedReport } from '../models/report-unflattened.model'; -export const expectedErpt: UnflattenedReport[] = [ +export const expectedErpt: UnflattenedReport[] = deepFreeze([ { rp: { id: 'rprAfNrce73O', @@ -233,9 +235,9 @@ export const expectedErpt: UnflattenedReport[] = [ email: 'ajain@fyle.in', }, }, -]; +]); -export const expectedErptPlatform: UnflattenedReport[] = [ +export const expectedErptPlatform: UnflattenedReport[] = deepFreeze([ { rp: { id: 'rpIfg2VWQKGJ', @@ -326,9 +328,9 @@ export const expectedErptPlatform: UnflattenedReport[] = [ email: 'devendra.r@fyle.in', }, }, -]; +]); -export const expectedSingleErpt: UnflattenedReport = { +export const expectedSingleErpt: UnflattenedReport = deepFreeze({ rp: { id: 'rprAfNrce73O', org_user_id: 'ouX8dwsbLCLv', @@ -385,9 +387,9 @@ export const expectedSingleErpt: UnflattenedReport = { full_name: 'Abhishek Jain', email: 'ajain@fyle.in', }, -}; +}); -export const extendedReportParam: UnflattenedReport[] = [ +export const extendedReportParam: UnflattenedReport[] = deepFreeze([ { rp: { id: 'rp5eUkeNm9wB', @@ -612,9 +614,9 @@ export const extendedReportParam: UnflattenedReport[] = [ email: 'ajain@fyle.in', }, }, -]; +]); -export const expectedUnflattenedReports: UnflattenedReport[] = [ +export const expectedUnflattenedReports: UnflattenedReport[] = deepFreeze([ { rp: { id: 'rp5eUkeNm9wB', @@ -839,9 +841,9 @@ export const expectedUnflattenedReports: UnflattenedReport[] = [ email: 'ajain@fyle.in', }, }, -]; +]); -export const unflattenedErptc: UnflattenedReport = { +export const unflattenedErptc: UnflattenedReport = deepFreeze({ rp: { id: 'rprAfNrce73O', org_user_id: 'ouX8dwsbLCLv', @@ -898,9 +900,9 @@ export const unflattenedErptc: UnflattenedReport = { full_name: 'Abhishek Jain', email: 'ajain@fyle.in', }, -}; +}); -export const unflattenedErptcArrayItem1: UnflattenedReport = { +export const unflattenedErptcArrayItem1: UnflattenedReport = deepFreeze({ rp: { id: 'rprAfNrce73O', org_user_id: 'ouX8dwsbLCLv', @@ -957,9 +959,9 @@ export const unflattenedErptcArrayItem1: UnflattenedReport = { full_name: 'Abhishek Jain', email: 'ajain@fyle.in', }, -}; +}); -export const unflattenedErptcArrayItem2: UnflattenedReport = { +export const unflattenedErptcArrayItem2: UnflattenedReport = deepFreeze({ rp: { id: 'rpLMyvYSXgJy', org_user_id: 'ouX8dwsbLCLv', @@ -1016,9 +1018,9 @@ export const unflattenedErptcArrayItem2: UnflattenedReport = { full_name: 'Abhishek Jain', email: 'ajain@fyle.in', }, -}; +}); -export const unflattenedErptcArrayItem3: UnflattenedReport = { +export const unflattenedErptcArrayItem3: UnflattenedReport = deepFreeze({ rp: { id: 'rpxtbiLXQZUm', org_user_id: 'ouX8dwsbLCLv', @@ -1075,9 +1077,9 @@ export const unflattenedErptcArrayItem3: UnflattenedReport = { full_name: 'Abhishek Jain', email: 'ajain@fyle.in', }, -}; +}); -export const unflattenedErptcArrayItem4: UnflattenedReport = { +export const unflattenedErptcArrayItem4: UnflattenedReport = deepFreeze({ rp: { id: 'rpSGcIEwzxDd', org_user_id: 'ouX8dwsbLCLv', @@ -1134,9 +1136,9 @@ export const unflattenedErptcArrayItem4: UnflattenedReport = { full_name: 'Abhishek Jain', email: 'ajain@fyle.in', }, -}; +}); -export const singleERptcFixDatesMock: UnflattenedReport = { +export const singleERptcFixDatesMock: UnflattenedReport = deepFreeze({ rp: { id: 'rprAfNrce73O', org_user_id: 'ouX8dwsbLCLv', @@ -1193,9 +1195,9 @@ export const singleERptcFixDatesMock: UnflattenedReport = { full_name: 'Abhishek Jain', email: 'ajain@fyle.in', }, -}; +}); -export const addApproverERpts: UnflattenedReport[] = [ +export const addApproverERpts: UnflattenedReport[] = deepFreeze([ { rp: { id: 'rp35DK02IvMP', @@ -1456,9 +1458,9 @@ export const addApproverERpts: UnflattenedReport[] = [ email: 'ajain@fyle.in', }, }, -]; +]); -export const expectedAddedApproverERpts: UnflattenedReport[] = [ +export const expectedAddedApproverERpts: UnflattenedReport[] = deepFreeze([ { rp: { id: 'rp35DK02IvMP', @@ -1623,9 +1625,9 @@ export const expectedAddedApproverERpts: UnflattenedReport[] = [ email: 'ajain@fyle.in', }, }, -]; +]); -export const draftReportPerDiemData: UnflattenedReport[] = [ +export const draftReportPerDiemData: UnflattenedReport[] = deepFreeze([ { rp: { id: 'rp35DK02IvMP', @@ -1700,4 +1702,4 @@ export const draftReportPerDiemData: UnflattenedReport[] = [ email: 'ajain@fyle.in', }, }, -]; +]); diff --git a/src/app/core/mock-data/report-v1.data.ts b/src/app/core/mock-data/report-v1.data.ts index 40d9cfb82c..b5e1772e27 100644 --- a/src/app/core/mock-data/report-v1.data.ts +++ b/src/app/core/mock-data/report-v1.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ReportV1 } from '../models/report-v1.model'; -export const reportUnflattenedData: ReportV1 = { +export const reportUnflattenedData: ReportV1 = deepFreeze({ created_at: new Date('2023-01-19T16:25:46.804Z'), updated_at: new Date('2023-01-19T16:25:46.804Z'), last_updated_by: { @@ -49,9 +51,9 @@ export const reportUnflattenedData: ReportV1 = { location4: null, location5: null, type: 'EXPENSE', -}; +}); -export const reportUnflattenedData2: ReportV1 = { +export const reportUnflattenedData2: ReportV1 = deepFreeze({ created_at: new Date('2023-01-21T07:45:18.869Z'), updated_at: new Date('2023-01-21T07:45:18.869Z'), last_updated_by: { @@ -100,9 +102,9 @@ export const reportUnflattenedData2: ReportV1 = { location4: null, location5: null, type: 'EXPENSE', -}; +}); -export const apiEmptyReportRes: ReportV1 = { +export const apiEmptyReportRes: ReportV1 = deepFreeze({ created_at: null, updated_at: null, last_updated_by: null, @@ -139,9 +141,9 @@ export const apiEmptyReportRes: ReportV1 = { location4: null, location5: null, type: null, -}; +}); -export const apiReportUpdatedDetails: ReportV1 = { +export const apiReportUpdatedDetails: ReportV1 = deepFreeze({ created_at: new Date('2022-10-31T13:54:46.317Z'), updated_at: new Date('2023-01-23T10:53:52.220Z'), last_updated_by: { @@ -190,4 +192,4 @@ export const apiReportUpdatedDetails: ReportV1 = { location4: null, location5: null, type: 'EXPENSE', -}; +}); diff --git a/src/app/core/mock-data/report.data.ts b/src/app/core/mock-data/report.data.ts index 4a5e0b2401..03b15643ae 100644 --- a/src/app/core/mock-data/report.data.ts +++ b/src/app/core/mock-data/report.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ExtendedReport } from '../models/report.model'; -export const apiExtendedReportRes: ExtendedReport[] = [ +export const apiExtendedReportRes: ExtendedReport[] = deepFreeze([ { rp_id: 'rprAfNrce73O', rp_org_user_id: 'ouX8dwsbLCLv', @@ -209,9 +211,9 @@ export const apiExtendedReportRes: ExtendedReport[] = [ rp_risk_state_expense_count: null, rp_risk_state: null, }, -]; +]); -export const expectedAllReports: ExtendedReport[] = [ +export const expectedAllReports: ExtendedReport[] = deepFreeze([ { _search_document: "'0':5 '2023':3 '4':1 'a':8 'abhishek':10 'ajain@fyle.in':12 'bangalore':9 'c/2023/02/r/5':6 'feb':2 'inr':4 'jain':11 'lion':7", @@ -318,9 +320,9 @@ export const expectedAllReports: ExtendedReport[] = [ us_email: 'ajain@fyle.in', us_full_name: 'Abhishek Jain', }, -]; +]); -export const expectedPaginatedReports: ExtendedReport[] = [ +export const expectedPaginatedReports: ExtendedReport[] = deepFreeze([ { _search_document: "'0':5 '2023':3 '4':1 'a':8 'abhishek':10 'ajain@fyle.in':12 'bangalore':9 'c/2023/02/r/5':6 'feb':2 'inr':4 'jain':11 'lion':7", @@ -481,9 +483,9 @@ export const expectedPaginatedReports: ExtendedReport[] = [ us_email: 'ajain@fyle.in', us_full_name: 'Abhishek Jain', }, -]; +]); -export const reportParam: ExtendedReport = { +export const reportParam: ExtendedReport = deepFreeze({ _search_document: "'46040':4 'a':8,14,20,26 'abhishek':32 'ajain@fyle.in':34 'business':11,17,23,29 'c/2022/10/r/37':5 'director':6 'indeed':13,19,25,31 'inr':3 'jain':33 'long':10,16,22,28 'mumbai':7 'report':2 'testing':1 'unit':12,18,24,30 'very':9,15,21,27", approved_by: null, @@ -533,9 +535,9 @@ export const reportParam: ExtendedReport = { sequential_approval_turn: false, us_email: 'ajain@fyle.in', us_full_name: 'Abhishek Jain', -}; +}); -export const expectedReportSingleResponse: ExtendedReport = { +export const expectedReportSingleResponse: ExtendedReport = deepFreeze({ _search_document: "'145':5 'a':8 'abhishek':10 'ajain@fyle.in':12 'bangalore':9 'c/2023/01/r/31':6 'columns':3 'inr':4 'jain':11 'lion':7 'manage':2 'test':1", approved_by: ['out3t2X258rd'], @@ -592,9 +594,9 @@ export const expectedReportSingleResponse: ExtendedReport = { sequential_approval_turn: false, us_email: 'ajain@fyle.in', us_full_name: 'Abhishek Jain', -}; +}); -export const apiErptcReportsRes: ExtendedReport[] = [ +export const apiErptcReportsRes: ExtendedReport[] = deepFreeze([ { rp_id: 'rpfClhA1lglE', rp_org_user_id: 'ouCI4UQ2G0K1', @@ -799,9 +801,9 @@ export const apiErptcReportsRes: ExtendedReport[] = [ rp_risk_state_expense_count: null, rp_risk_state: null, }, -]; +]); -export const newReportParam = { +export const newReportParam = deepFreeze({ _search_document: "'46040':4 'a':8,14,20,26 'abhishek':32 'ajain@fyle.in':34 'business':11,17,23,29 'c/2022/10/r/37':5 'director':6 'indeed':13,19,25,31 'inr':3 'jain':33 'long':10,16,22,28 'mumbai':7 'report':2 'testing':1 'unit':12,18,24,30 'very':9,15,21,27", approved_by: null, @@ -851,9 +853,9 @@ export const newReportParam = { sequential_approval_turn: false, us_email: 'ajain@fyle.in', us_full_name: 'Abhishek Jain', -}; +}); -export const reportData1: ExtendedReport = { +export const reportData1: ExtendedReport = deepFreeze({ _search_document: "'0':7 '2023':3 '3':1 'a':11,17,23,29 'abhishek':35 'ajain@fyle.in':37 'business':14,20,26,32 'c/2023/07/r/17':8 'director':9 'expense':5 'indeed':16,22,28,34 'inr':6 'jain':36 'jul':2 'long':13,19,25,31 'mumbai':10 'office':4 'unit':15,21,27,33 'very':12,18,24,30", approved_by: null, @@ -906,4 +908,4 @@ export const reportData1: ExtendedReport = { sequential_approval_turn: false, us_email: 'ajain@fyle.in', us_full_name: 'Abhishek Jain', -}; +}); diff --git a/src/app/core/mock-data/router-state-snapshot.data.ts b/src/app/core/mock-data/router-state-snapshot.data.ts index ec90f79b8e..de07d66d87 100644 --- a/src/app/core/mock-data/router-state-snapshot.data.ts +++ b/src/app/core/mock-data/router-state-snapshot.data.ts @@ -1 +1,3 @@ -export const routerStateSnapshotData = { url: '/test', root: null }; +import deepFreeze from 'deep-freeze-strict'; + +export const routerStateSnapshotData = deepFreeze({ url: '/test', root: null }); diff --git a/src/app/core/mock-data/selected-filters.data.ts b/src/app/core/mock-data/selected-filters.data.ts index 26f5531513..74102f3fcb 100644 --- a/src/app/core/mock-data/selected-filters.data.ts +++ b/src/app/core/mock-data/selected-filters.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { SelectedFilters } from 'src/app/shared/components/fy-filters/selected-filters.interface'; -export const selectedFilters1: SelectedFilters[] = [ +export const selectedFilters1: SelectedFilters[] = deepFreeze([ { name: 'Created On', value: 'custom', @@ -29,9 +31,9 @@ export const selectedFilters1: SelectedFilters[] = [ name: 'Receipts Attached', value: 'custom', }, -]; +]); -export const selectedFilters2: SelectedFilters[] = [ +export const selectedFilters2: SelectedFilters[] = deepFreeze([ { name: 'Updated On', value: 'custom', @@ -52,9 +54,9 @@ export const selectedFilters2: SelectedFilters[] = [ name: 'Transactions Type', value: 'Debit', }, -]; +]); -export const selectedFilters3 = [ +export const selectedFilters3 = deepFreeze([ { name: 'State', value: 'Approved' }, { name: 'Date', @@ -62,23 +64,23 @@ export const selectedFilters3 = [ associatedData: { startDate: new Date('2023-04-01'), endDate: new Date('2023-04-04') }, }, { name: 'Sort By', value: 'dateNewToOld' }, -]; +]); -export const selectedFilters4 = [ +export const selectedFilters4 = deepFreeze([ { name: 'State', value: 'Approved' }, { name: 'Date', value: 'Last 7 Days', associatedData: undefined }, { name: 'Sort By', value: 'dateNewToOld' }, -]; +]); -export const selectedFilters5 = [ +export const selectedFilters5 = deepFreeze([ { name: 'Date', value: 'Last Month', associatedData: { startDate: new Date('2023-01-04'), endDate: new Date('2023-01-10') }, }, -]; +]); -export const taskSelectedFiltersData: SelectedFilters[] = [ +export const taskSelectedFiltersData: SelectedFilters[] = deepFreeze([ { name: 'Expenses', value: ['DRAFT'], @@ -91,9 +93,9 @@ export const taskSelectedFiltersData: SelectedFilters[] = [ name: 'Advances', value: ['SENT_BACK'], }, -]; +]); -export const selectedFilters6: SelectedFilters[] = [ +export const selectedFilters6: SelectedFilters[] = deepFreeze([ { name: 'State', value: 'DRAFT', @@ -106,14 +108,14 @@ export const selectedFilters6: SelectedFilters[] = [ endDate: new Date('2023-02-02'), }, }, -]; +]); -export const selectedFiltersParams: SelectedFilters = { +export const selectedFiltersParams: SelectedFilters = deepFreeze({ name: 'Sort By', value: 'dateNewToOld', -}; +}); -export const selectedFiltersParams2: SelectedFilters[] = [ +export const selectedFiltersParams2: SelectedFilters[] = deepFreeze([ { name: 'State', value: 'DRAFT', @@ -131,9 +133,9 @@ export const selectedFiltersParams2: SelectedFilters[] = [ endDate: new Date('2023-02-02'), }, }, -]; +]); -export const selectedFilters7: SelectedFilters[] = [ +export const selectedFilters7: SelectedFilters[] = deepFreeze([ ...selectedFilters5, { name: 'Type', @@ -156,9 +158,9 @@ export const selectedFilters7: SelectedFilters[] = [ name: 'Split Expense', value: 'Yes', }, -]; +]); -export const selectedFilters8: SelectedFilters[] = [ +export const selectedFilters8: SelectedFilters[] = deepFreeze([ { name: 'Date', value: 'Last Month', @@ -184,9 +186,9 @@ export const selectedFilters8: SelectedFilters[] = [ name: 'Split Expense', value: 'Yes', }, -]; +]); -export const selectedFilters9: SelectedFilters[] = [ +export const selectedFilters9: SelectedFilters[] = deepFreeze([ { name: 'Type', value: ['DRAFT', 'READY_TO_REPORT'], @@ -215,4 +217,4 @@ export const selectedFilters9: SelectedFilters[] = [ name: 'Split Expense', value: 'YES', }, -]; +]); diff --git a/src/app/core/mock-data/sidemenu-allowed-actions.data.ts b/src/app/core/mock-data/sidemenu-allowed-actions.data.ts index 5d4778bf33..ac7ac269d1 100644 --- a/src/app/core/mock-data/sidemenu-allowed-actions.data.ts +++ b/src/app/core/mock-data/sidemenu-allowed-actions.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { SidemenuAllowedActions } from '../models/sidemenu-allowed-actions.model'; -export const sidemenuAllowedActions: SidemenuAllowedActions = { +export const sidemenuAllowedActions: SidemenuAllowedActions = deepFreeze({ allowedReportsActions: { allowedRouteAccess: true, approve: true, @@ -12,4 +14,4 @@ export const sidemenuAllowedActions: SidemenuAllowedActions = { approve: true, delete: true, }, -}; +}); diff --git a/src/app/core/mock-data/sidemenu-item.data.ts b/src/app/core/mock-data/sidemenu-item.data.ts index 1b2e0383f2..ba10186cdf 100644 --- a/src/app/core/mock-data/sidemenu-item.data.ts +++ b/src/app/core/mock-data/sidemenu-item.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { SidemenuItem } from '../models/sidemenu-item.model'; -export const sidemenuItemData1: SidemenuItem = { +export const sidemenuItemData1: SidemenuItem = deepFreeze({ title: 'Dashboard', isVisible: true, icon: 'dashboard', @@ -9,9 +11,9 @@ export const sidemenuItemData1: SidemenuItem = { isDropdownOpen: false, dropdownOptions: [], openLiveChat: false, -}; +}); -export const sidemenuItemData2: SidemenuItem = { +export const sidemenuItemData2: SidemenuItem = deepFreeze({ title: 'Team', isVisible: true, icon: 'user-three', @@ -31,17 +33,17 @@ export const sidemenuItemData2: SidemenuItem = { ], route: [], openLiveChat: false, -}; +}); -export const sidemenuItemData3: Partial = { +export const sidemenuItemData3: Partial = deepFreeze({ title: 'Live Chat', isVisible: true, icon: 'chat', openLiveChat: true, disabled: false, -}; +}); -export const sidemenuItemData4: Partial = { +export const sidemenuItemData4: Partial = deepFreeze({ title: 'Switch Organization', isVisible: true, icon: 'swap', @@ -55,4 +57,4 @@ export const sidemenuItemData4: Partial = { }, ], disabled: false, -}; +}); diff --git a/src/app/core/mock-data/sidemenu.data.ts b/src/app/core/mock-data/sidemenu.data.ts index 49f39cfa36..ba038cc626 100644 --- a/src/app/core/mock-data/sidemenu.data.ts +++ b/src/app/core/mock-data/sidemenu.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { SidemenuItem } from '../models/sidemenu-item.model'; -export const sidemenuData1 = [ +export const sidemenuData1 = deepFreeze([ { title: 'Dashboard', isVisible: true, @@ -19,9 +21,9 @@ export const sidemenuData1 = [ icon: 'gear', route: ['/', 'enterprise', 'my_profile'], }, -]; +]); -export const PrimaryOptionsRes1: Partial[] = [ +export const PrimaryOptionsRes1: Partial[] = deepFreeze([ { title: 'Dashboard', isVisible: true, @@ -55,17 +57,17 @@ export const PrimaryOptionsRes1: Partial[] = [ route: ['/', 'enterprise', 'my_advances'], disabled: false, }, -]; +]); -export const UpdatedOptionsRes: Partial = { +export const UpdatedOptionsRes: Partial = deepFreeze({ title: 'Personal Cards', isVisible: true, route: ['/', 'enterprise', 'personal_cards'], icon: 'card', disabled: false, -}; +}); -export const PrimaryOptionsRes2: Partial[] = [ +export const PrimaryOptionsRes2: Partial[] = deepFreeze([ { title: 'Team', isVisible: true, @@ -85,9 +87,9 @@ export const PrimaryOptionsRes2: Partial[] = [ }, ], }, -]; +]); -export const getPrimarySidemenuOptionsRes1 = [ +export const getPrimarySidemenuOptionsRes1 = deepFreeze([ { title: 'Dashboard', isVisible: true, @@ -122,9 +124,9 @@ export const getPrimarySidemenuOptionsRes1 = [ icon: 'user-three', disabled: false, }, -]; +]); -export const getSecondarySidemenuOptionsRes1 = [ +export const getSecondarySidemenuOptionsRes1 = deepFreeze([ { title: 'Delegated Accounts', isVisible: true, @@ -152,9 +154,9 @@ export const getSecondarySidemenuOptionsRes1 = [ route: ['/', 'enterprise', 'help'], disabled: false, }, -]; +]); -export const setSideMenuRes: Partial[] = [ +export const setSideMenuRes: Partial[] = deepFreeze([ { title: 'Dashboard', isVisible: true, @@ -215,4 +217,4 @@ export const setSideMenuRes: Partial[] = [ route: ['/', 'enterprise', 'help'], disabled: false, }, -]; +]); diff --git a/src/app/core/mock-data/snackbar-properties.data.ts b/src/app/core/mock-data/snackbar-properties.data.ts index b37453a4a9..6f2aa3c0e4 100644 --- a/src/app/core/mock-data/snackbar-properties.data.ts +++ b/src/app/core/mock-data/snackbar-properties.data.ts @@ -1,73 +1,75 @@ +import deepFreeze from 'deep-freeze-strict'; + import { SnackbarProperties } from '../models/snackbar-properties.model'; -export const snackbarPropertiesRes = { +export const snackbarPropertiesRes = deepFreeze({ data: { icon: 'warning-fill', showCloseButton: true, message: 'Please select one or more expenses to be reported', }, duration: 3000, -}; +}); -export const snackbarPropertiesRes2 = { +export const snackbarPropertiesRes2 = deepFreeze({ data: { icon: 'success', showCloseButton: true, message: 'Expense added to report successfully', }, duration: 3000, -}; +}); -export const snackbarPropertiesRes3 = { +export const snackbarPropertiesRes3 = deepFreeze({ data: { icon: 'success', showCloseButton: true, message: '1 expense has been deleted', }, duration: 3000, -}; +}); -export const snackbarPropertiesRes4 = { +export const snackbarPropertiesRes4 = deepFreeze({ data: { icon: 'warning-fill', showCloseButton: true, message: 'We could not delete the expenses. Please try again', }, duration: 3000, -}; +}); -export const snackbarPropertiesRes5 = { +export const snackbarPropertiesRes5 = deepFreeze({ data: { icon: 'success', showCloseButton: true, message: 'Expenses merged Successfully', }, duration: 3000, -}; +}); -export const snackbarPropertiesRes6: SnackbarProperties = { +export const snackbarPropertiesRes6: SnackbarProperties = deepFreeze({ data: { icon: 'success', showCloseButton: true, message: '1 Transaction successfully hidden!', }, duration: 3000, -}; +}); -export const snackbarPropertiesRes7: SnackbarProperties = { +export const snackbarPropertiesRes7: SnackbarProperties = deepFreeze({ data: { icon: 'success', showCloseButton: true, message: '2 Transactions successfully hidden!', }, duration: 3000, -}; +}); -export const dismissExpenseSnackbarProps: SnackbarProperties = { +export const dismissExpenseSnackbarProps: SnackbarProperties = deepFreeze({ data: { icon: 'success', showCloseButton: true, message: 'Expense dismissed', }, duration: 3000, -}; +}); diff --git a/src/app/core/mock-data/split-expense-policy.data.ts b/src/app/core/mock-data/split-expense-policy.data.ts index 126069dbc0..8e2e46c8f9 100644 --- a/src/app/core/mock-data/split-expense-policy.data.ts +++ b/src/app/core/mock-data/split-expense-policy.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { SplitExpensePolicy } from '../models/platform/v1/split-expense-policy.model'; -export const splitPolicyExp1: SplitExpensePolicy = { +export const splitPolicyExp1: SplitExpensePolicy = deepFreeze({ data: [ { individual_desired_states: [], @@ -15,4 +17,4 @@ export const splitPolicyExp1: SplitExpensePolicy = { }, }, ], -}; +}); diff --git a/src/app/core/mock-data/split-expense-data.ts b/src/app/core/mock-data/split-expense.data.ts similarity index 84% rename from src/app/core/mock-data/split-expense-data.ts rename to src/app/core/mock-data/split-expense.data.ts index 5f1feb4ebb..0da1b90d37 100644 --- a/src/app/core/mock-data/split-expense-data.ts +++ b/src/app/core/mock-data/split-expense.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import * as dayjs from 'dayjs'; import { SplitExpense } from '../models/split-expense.model'; -export const splitExpense1: SplitExpense = { +export const splitExpense1: SplitExpense = deepFreeze({ amount: 15000, currency: 'INR', percentage: 60, @@ -25,9 +27,9 @@ export const splitExpense1: SplitExpense = { projectv2_name: '3M', sub_project_name: null, }, -}; +}); -export const splitExpense2: SplitExpense = { +export const splitExpense2: SplitExpense = deepFreeze({ amount: 2160, currency: 'INR', percentage: 60, @@ -44,48 +46,48 @@ export const splitExpense2: SplitExpense = { sub_category: '1', updated_at: '2023-04-17T12:55:49.475665+00:00', }, -}; +}); -export const splitExpense3 = { +export const splitExpense3 = deepFreeze({ amount: 2000, currency: 'INR', percentage: 50, txn_dt: '2023-02-08', category: '', -}; +}); -export const splitExpense4 = { +export const splitExpense4 = deepFreeze({ amount: 2000, currency: 'INR', percentage: 50, txn_dt: dayjs(new Date()).format('YYYY-MM-DD'), category: '', -}; +}); -export const splitExpense5 = { +export const splitExpense5 = deepFreeze({ amount: 2000, currency: 'INR', percentage: 50, txn_dt: '2023-02-08', project: '', -}; +}); -export const splitExpense6 = { +export const splitExpense6 = deepFreeze({ amount: 2000, currency: 'INR', percentage: 50, txn_dt: '2023-02-08', cost_center: '', -}; +}); -export const splitExpense7 = { +export const splitExpense7 = deepFreeze({ ...splitExpense3, amount: null, currency: null, percentage: null, -}; +}); -export const splitExpenseDataWithProject: SplitExpense = { +export const splitExpenseDataWithProject: SplitExpense = deepFreeze({ amount: 120, currency: 'INR', percentage: 60, @@ -130,14 +132,14 @@ export const splitExpenseDataWithProject: SplitExpense = { sub_project_name: 'Sub 103', }, txn_dt: '2023-08-10', -}; +}); -export const splitExpenseDataWithProject2: SplitExpense = { +export const splitExpenseDataWithProject2: SplitExpense = deepFreeze({ ...splitExpenseDataWithProject, project: undefined, -}; +}); -export const splitExpenseDataWithCostCenter: SplitExpense = { +export const splitExpenseDataWithCostCenter: SplitExpense = deepFreeze({ ...splitExpenseDataWithProject, project: undefined, cost_center: { @@ -150,9 +152,9 @@ export const splitExpenseDataWithCostCenter: SplitExpense = { org_id: 'orOTDe765hQp', updated_at: '2023-01-04T04:00:32.338131+00:00', }, -}; +}); -export const splitExpenseDataWithCostCenter2: SplitExpense = { +export const splitExpenseDataWithCostCenter2: SplitExpense = deepFreeze({ ...splitExpenseDataWithCostCenter, cost_center: undefined, -}; +}); diff --git a/src/app/core/mock-data/split-payload.data.ts b/src/app/core/mock-data/split-payload.data.ts index 1794d84182..ee18786929 100644 --- a/src/app/core/mock-data/split-payload.data.ts +++ b/src/app/core/mock-data/split-payload.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { SplitPayload } from '../models/platform/v1/split-payload.model'; import { splitsData1 } from './splits.data'; -export const splitPayloadData1: SplitPayload = { +export const splitPayloadData1: SplitPayload = deepFreeze({ id: 'sdfd2391', claim_amount: 1900, splits: [ @@ -47,9 +49,9 @@ export const splitPayloadData1: SplitPayload = { value: 'string1', }, ], -}; +}); -export const splitPayloadData2: SplitPayload = { +export const splitPayloadData2: SplitPayload = deepFreeze({ is_reimbursable: true, source: 'MOBILE', spent_at: new Date('Mon Feb 13 2023 22:30:00 GMT+0530 (India Standard Time)'), @@ -95,10 +97,10 @@ export const splitPayloadData2: SplitPayload = { splits: splitsData1, travel_classes: [], report_id: 'rp0AGAoeQfQX', -}; +}); -export const splitPayloadData3: SplitPayload = { +export const splitPayloadData3: SplitPayload = deepFreeze({ ...splitPayloadData2, category_id: 16569, is_reimbursable: null, -}; +}); diff --git a/src/app/core/mock-data/splits.data.ts b/src/app/core/mock-data/splits.data.ts index 0dca1ec6fb..06f13e1b98 100644 --- a/src/app/core/mock-data/splits.data.ts +++ b/src/app/core/mock-data/splits.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { Splits } from '../models/platform/v1/splits.model'; -export const splitsData1: Splits[] = [ +export const splitsData1: Splits[] = deepFreeze([ { claim_amount: 56.6, spent_at: new Date(), @@ -12,9 +14,9 @@ export const splitsData1: Splits[] = [ purpose: 'split test 1', custom_fields: [], }, -]; +]); -export const splitData2: Splits[] = [ +export const splitData2: Splits[] = deepFreeze([ { claim_amount: null, spent_at: new Date('Tue Jan 31 2023 22:30:00 GMT+0530 (India Standard Time)'), @@ -53,4 +55,4 @@ export const splitData2: Splits[] = [ ], claim_amount: null, }, -]; +]); diff --git a/src/app/core/mock-data/static-map-properties.data.ts b/src/app/core/mock-data/static-map-properties.data.ts index 4161abd0e6..96ff4eab9e 100644 --- a/src/app/core/mock-data/static-map-properties.data.ts +++ b/src/app/core/mock-data/static-map-properties.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { StaticMapProperties } from '../models/static-map-properties.interface'; -export const staticMapPropertiesData: StaticMapProperties = { +export const staticMapPropertiesData: StaticMapProperties = deepFreeze({ zoom: 18, routeColor: '0x00BFFF', markers: [ @@ -34,4 +36,4 @@ export const staticMapPropertiesData: StaticMapProperties = { width: window.innerWidth, height: 266, resolutionScale: 2, -}; +}); diff --git a/src/app/core/mock-data/stats-dimension-response.data.ts b/src/app/core/mock-data/stats-dimension-response.data.ts index 0495023096..87df5d8622 100644 --- a/src/app/core/mock-data/stats-dimension-response.data.ts +++ b/src/app/core/mock-data/stats-dimension-response.data.ts @@ -1,8 +1,8 @@ -import { PlatformApiResponse } from '../models/platform/platform-api-response.model'; +import deepFreeze from 'deep-freeze-strict'; + import { StatsDimensionResponse } from '../models/stats-dimension-response.model'; -import { ApiV2Response } from '../models/v2/api-v2-response.model'; -export const apiTxnUnreportedStatsRes: StatsDimensionResponse[] = [ +export const apiTxnUnreportedStatsRes: StatsDimensionResponse[] = deepFreeze([ { aggregates: [ { @@ -17,17 +17,17 @@ export const apiTxnUnreportedStatsRes: StatsDimensionResponse[] = [ dimensions: [], name: 'scalar_stat', }, -]; +]); -export const apiTxnUnreportedStatsEmptyRes: StatsDimensionResponse[] = [ +export const apiTxnUnreportedStatsEmptyRes: StatsDimensionResponse[] = deepFreeze([ { aggregates: [], dimensions: [], name: 'scalar_stat', }, -]; +]); -export const apiTxnIncompleteStatsRes: StatsDimensionResponse[] = [ +export const apiTxnIncompleteStatsRes: StatsDimensionResponse[] = deepFreeze([ { aggregates: [ { @@ -42,30 +42,30 @@ export const apiTxnIncompleteStatsRes: StatsDimensionResponse[] = [ dimensions: [], name: 'scalar_stat', }, -]; +]); -export const apiTxnIncompleteStatsEmptyRes: StatsDimensionResponse[] = [ +export const apiTxnIncompleteStatsEmptyRes: StatsDimensionResponse[] = deepFreeze([ { aggregates: [], dimensions: [], name: 'scalar_stat', }, -]; +]); -export const apiUnreportedParams: Partial = { +export const apiUnreportedParams: Partial = deepFreeze({ scalar: true, tx_state: 'in.(COMPLETE)', or: '(tx_policy_amount.is.null,tx_policy_amount.gt.0.0001)', tx_report_id: 'is.null', -}; +}); -export const apiIncompleteParams: Partial = { +export const apiIncompleteParams: Partial = deepFreeze({ scalar: true, tx_state: 'in.(DRAFT)', tx_report_id: 'is.null', -}; +}); -export const expectedReportRawStats: StatsDimensionResponse[] = [ +export const expectedReportRawStats: StatsDimensionResponse[] = deepFreeze([ { aggregates: [ { @@ -80,4 +80,4 @@ export const expectedReportRawStats: StatsDimensionResponse[] = [ dimensions: [], name: 'scalar_stat', }, -]; +]); diff --git a/src/app/core/mock-data/stats-response.data.ts b/src/app/core/mock-data/stats-response.data.ts index b35eddd255..64232096de 100644 --- a/src/app/core/mock-data/stats-response.data.ts +++ b/src/app/core/mock-data/stats-response.data.ts @@ -1,3 +1,5 @@ +import deepFreeze from 'deep-freeze-strict'; + import { Datum, StatsResponse } from '../models/v2/stats-response.model'; // type StatsResponse = { // data: { @@ -317,7 +319,7 @@ export const txnStats = new StatsResponse({ url: '/v2/expenses/stats', }); -export const transactionDatum1: Datum[] = [ +export const transactionDatum1: Datum[] = deepFreeze([ { name: '', dimensions: [], @@ -360,9 +362,9 @@ export const transactionDatum1: Datum[] = [ }, ], }, -]; +]); -export const transactionDatum2: Datum[] = [ +export const transactionDatum2: Datum[] = deepFreeze([ { name: '', dimensions: [], @@ -396,9 +398,9 @@ export const transactionDatum2: Datum[] = [ }, ], }, -]; +]); -export const transactionDatum3: Datum[] = [ +export const transactionDatum3: Datum[] = deepFreeze([ { name: '', dimensions: [], @@ -413,4 +415,4 @@ export const transactionDatum3: Datum[] = [ }, ], }, -]; +]); diff --git a/src/app/core/mock-data/stats.data.ts b/src/app/core/mock-data/stats.data.ts index b9cc6a454a..c2b5f3e323 100644 --- a/src/app/core/mock-data/stats.data.ts +++ b/src/app/core/mock-data/stats.data.ts @@ -1,31 +1,33 @@ +import deepFreeze from 'deep-freeze-strict'; + import { Stats } from '../models/stats.model'; -export const expectedUnreportedExpStats: Stats = { +export const expectedUnreportedExpStats: Stats = deepFreeze({ count: 6, sum: 16748.73, -}; +}); -export const expectedIncompleteExpStats: Stats = { +export const expectedIncompleteExpStats: Stats = deepFreeze({ count: 1130, sum: 1148487.57555147, -}; +}); -export const expectedEmptyStats: Stats = { +export const expectedEmptyStats: Stats = deepFreeze({ count: undefined, sum: undefined, -}; +}); -export const expectedUnreportedExpStats2: Stats = { +export const expectedUnreportedExpStats2: Stats = deepFreeze({ count: 3, sum: 30, -}; +}); -export const expectedIncompleteExpStats2: Stats = { +export const expectedIncompleteExpStats2: Stats = deepFreeze({ count: 339, sum: 76234.47290692403, -}; +}); -export const emptyStatsAgg: Stats = { +export const emptyStatsAgg: Stats = deepFreeze({ count: 0, sum: 0, -}; +}); diff --git a/src/app/core/mock-data/task-cta.data.ts b/src/app/core/mock-data/task-cta.data.ts index 02e009bf41..13d61add33 100644 --- a/src/app/core/mock-data/task-cta.data.ts +++ b/src/app/core/mock-data/task-cta.data.ts @@ -1,47 +1,49 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TaskCta } from '../models/task-cta.model'; import { TASKEVENT } from '../models/task-event.enum'; -export const taskCtaData: TaskCta = { +export const taskCtaData: TaskCta = deepFreeze({ event: TASKEVENT.expensesAddToReport, content: 'Add To Report', -}; +}); -export const taskCtaData2: TaskCta = { +export const taskCtaData2: TaskCta = deepFreeze({ event: TASKEVENT.openDraftReports, content: 'Draft Reports', -}; +}); -export const taskCtaData3: TaskCta = { +export const taskCtaData3: TaskCta = deepFreeze({ event: TASKEVENT.openSentBackReport, content: 'Sent Back Report', -}; +}); -export const taskCtaData4: TaskCta = { +export const taskCtaData4: TaskCta = deepFreeze({ event: TASKEVENT.reviewExpenses, content: 'Review Expenses', -}; +}); -export const taskCtaData5: TaskCta = { +export const taskCtaData5: TaskCta = deepFreeze({ event: TASKEVENT.openTeamReport, content: 'Team Reports', -}; +}); -export const taskCtaData6: TaskCta = { +export const taskCtaData6: TaskCta = deepFreeze({ event: TASKEVENT.openPotentialDuplicates, content: 'Potential Duplicates', -}; +}); -export const taskCtaData7: TaskCta = { +export const taskCtaData7: TaskCta = deepFreeze({ event: TASKEVENT.openSentBackAdvance, content: 'Sent Back Advances', -}; +}); -export const taskCtaData8: TaskCta = { +export const taskCtaData8: TaskCta = deepFreeze({ event: TASKEVENT.expensesCreateNewReport, content: 'Create New Report', -}; +}); -export const taskCtaData9: TaskCta = { +export const taskCtaData9: TaskCta = deepFreeze({ event: TASKEVENT.mobileNumberVerification, content: 'Verify Mobile Number', -}; +}); diff --git a/src/app/core/mock-data/task-filters.data.ts b/src/app/core/mock-data/task-filters.data.ts index 2e221d17ae..68fd8ffff2 100644 --- a/src/app/core/mock-data/task-filters.data.ts +++ b/src/app/core/mock-data/task-filters.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TaskFilters } from '../models/task-filters.model'; -export const taskFiltersData: TaskFilters = { +export const taskFiltersData: TaskFilters = deepFreeze({ sentBackReports: true, draftReports: false, draftExpenses: true, @@ -8,9 +10,9 @@ export const taskFiltersData: TaskFilters = { potentialDuplicates: false, teamReports: false, sentBackAdvances: false, -}; +}); -export const taskFiltersData2: TaskFilters = { +export const taskFiltersData2: TaskFilters = deepFreeze({ sentBackReports: false, draftReports: false, draftExpenses: false, @@ -18,9 +20,9 @@ export const taskFiltersData2: TaskFilters = { potentialDuplicates: false, teamReports: false, sentBackAdvances: false, -}; +}); -export const taskFiltersParams: TaskFilters = { +export const taskFiltersParams: TaskFilters = deepFreeze({ sentBackReports: true, draftReports: false, draftExpenses: false, @@ -28,9 +30,9 @@ export const taskFiltersParams: TaskFilters = { potentialDuplicates: false, teamReports: false, sentBackAdvances: false, -}; +}); -export const taskFiltersParams2: TaskFilters = { +export const taskFiltersParams2: TaskFilters = deepFreeze({ sentBackReports: false, draftReports: false, draftExpenses: true, @@ -38,9 +40,9 @@ export const taskFiltersParams2: TaskFilters = { potentialDuplicates: false, teamReports: false, sentBackAdvances: false, -}; +}); -export const taskFiltersParams3: TaskFilters = { +export const taskFiltersParams3: TaskFilters = deepFreeze({ sentBackReports: true, draftReports: false, draftExpenses: true, @@ -48,27 +50,27 @@ export const taskFiltersParams3: TaskFilters = { potentialDuplicates: false, teamReports: false, sentBackAdvances: false, -}; +}); -export const taskFiltersParams4: TaskFilters = { +export const taskFiltersParams4: TaskFilters = deepFreeze({ ...taskFiltersData2, unreportedExpenses: true, draftExpenses: true, potentialDuplicates: true, -}; +}); -export const taskFiltersParams5: TaskFilters = { +export const taskFiltersParams5: TaskFilters = deepFreeze({ ...taskFiltersData2, draftReports: true, sentBackReports: true, -}; +}); -export const taskFiltersParams6: TaskFilters = { +export const taskFiltersParams6: TaskFilters = deepFreeze({ ...taskFiltersData2, teamReports: true, -}; +}); -export const taskFiltersParams7: TaskFilters = { +export const taskFiltersParams7: TaskFilters = deepFreeze({ ...taskFiltersData2, sentBackAdvances: true, -}; +}); diff --git a/src/app/core/mock-data/task.data.ts b/src/app/core/mock-data/task.data.ts index b438cb0595..41f5e32fdd 100644 --- a/src/app/core/mock-data/task.data.ts +++ b/src/app/core/mock-data/task.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TASKEVENT } from '../models/task-event.enum'; import { TaskIcon } from '../models/task-icon.enum'; -export const draftExpenseTaskSample = { +export const draftExpenseTaskSample = deepFreeze({ amount: '132.57B', count: 161, header: 'Incomplete expenses', @@ -13,9 +15,9 @@ export const draftExpenseTaskSample = { event: TASKEVENT.reviewExpenses, }, ], -}; +}); -export const draftExpenseTaskSample2 = { +export const draftExpenseTaskSample2 = deepFreeze({ amount: '132.57B', count: 339, header: 'Incomplete expenses', @@ -27,9 +29,9 @@ export const draftExpenseTaskSample2 = { event: TASKEVENT.reviewExpenses, }, ], -}; +}); -export const potentailDuplicateTaskSample = { +export const potentailDuplicateTaskSample = deepFreeze({ hideAmount: true, count: 13, header: '34 Potential Duplicates', @@ -41,9 +43,9 @@ export const potentailDuplicateTaskSample = { event: TASKEVENT.openPotentialDuplicates, }, ], -}; +}); -export const teamReportTaskSample = { +export const teamReportTaskSample = deepFreeze({ amount: '733.48K', count: 2, header: 'Reports to be approved', @@ -55,9 +57,9 @@ export const teamReportTaskSample = { event: TASKEVENT.openTeamReport, }, ], -}; +}); -export const sentBackReportTaskSample = { +export const sentBackReportTaskSample = deepFreeze({ amount: '44.53', count: 1, header: 'Report sent back!', @@ -69,9 +71,9 @@ export const sentBackReportTaskSample = { event: TASKEVENT.openSentBackReport, }, ], -}; +}); -export const unreportedExpenseTaskSample = { +export const unreportedExpenseTaskSample = deepFreeze({ amount: '142.26K', count: 13, header: 'Expenses are ready to report', @@ -83,9 +85,9 @@ export const unreportedExpenseTaskSample = { event: TASKEVENT.expensesAddToReport, }, ], -}; +}); -export const unreportedExpenseTaskSample2 = { +export const unreportedExpenseTaskSample2 = deepFreeze({ amount: '142.26K', count: 3, header: 'Expenses are ready to report', @@ -97,9 +99,9 @@ export const unreportedExpenseTaskSample2 = { event: TASKEVENT.expensesAddToReport, }, ], -}; +}); -export const unsubmittedReportTaskSample = { +export const unsubmittedReportTaskSample = deepFreeze({ amount: '0.00', count: 2, header: 'Unsubmitted reports', @@ -111,9 +113,9 @@ export const unsubmittedReportTaskSample = { event: TASKEVENT.openDraftReports, }, ], -}; +}); -export const sentBackAdvanceTaskSample = { +export const sentBackAdvanceTaskSample = deepFreeze({ amount: '123.37M', count: 5, header: 'Advances sent back!', @@ -125,9 +127,9 @@ export const sentBackAdvanceTaskSample = { event: TASKEVENT.openSentBackAdvance, }, ], -}; +}); -export const addMobileNumberTask = { +export const addMobileNumberTask = deepFreeze({ hideAmount: true, header: 'Add Mobile Number', subheader: 'Add and verify your mobile number to text the receipts directly', @@ -138,9 +140,9 @@ export const addMobileNumberTask = { event: TASKEVENT.mobileNumberVerification, }, ], -}; +}); -export const verifyMobileNumberTask = { +export const verifyMobileNumberTask = deepFreeze({ hideAmount: true, header: 'Verify Mobile Number', subheader: 'Verify your mobile number to text the receipts directly', @@ -151,9 +153,9 @@ export const verifyMobileNumberTask = { event: TASKEVENT.mobileNumberVerification, }, ], -}; +}); -export const commuteDeductionTask = { +export const commuteDeductionTask = deepFreeze({ hideAmount: true, header: 'Add Commute Details', subheader: 'Add your Home and Work locations to easily deduct commute distance from your mileage expenses', @@ -164,4 +166,4 @@ export const commuteDeductionTask = { event: TASKEVENT.commuteDetails, }, ], -}; +}); diff --git a/src/app/core/mock-data/tax-group.data.ts b/src/app/core/mock-data/tax-group.data.ts index 13c2f7b687..6408f0b7aa 100644 --- a/src/app/core/mock-data/tax-group.data.ts +++ b/src/app/core/mock-data/tax-group.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TaxGroup } from '../models/tax-group.model'; -export const taxGroupData: TaxGroup[] = [ +export const taxGroupData: TaxGroup[] = deepFreeze([ { id: 'tgXEJA6YUoZ1', name: 'GST', @@ -19,9 +21,9 @@ export const taxGroupData: TaxGroup[] = [ org_id: 'orwruogwnngg', is_enabled: true, }, -]; +]); -export const expectedTaxGroupData: { label: string; value: TaxGroup }[] = [ +export const expectedTaxGroupData: { label: string; value: TaxGroup }[] = deepFreeze([ { label: 'GST', value: { @@ -46,4 +48,4 @@ export const expectedTaxGroupData: { label: string; value: TaxGroup }[] = [ is_enabled: true, }, }, -]; +]); diff --git a/src/app/core/mock-data/tax-settings.data.ts b/src/app/core/mock-data/tax-settings.data.ts index 10de6ff13d..d2b635b6c3 100644 --- a/src/app/core/mock-data/tax-settings.data.ts +++ b/src/app/core/mock-data/tax-settings.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TaxSettings } from '../models/org-settings.model'; -export const taxSettingsData: TaxSettings = { +export const taxSettingsData: TaxSettings = deepFreeze({ allowed: true, enabled: true, name: null, @@ -27,4 +29,4 @@ export const taxSettingsData: TaxSettings = { }, }, ], -}; +}); diff --git a/src/app/core/mock-data/team-reports-filters.data.ts b/src/app/core/mock-data/team-reports-filters.data.ts index 8bd1eb2e61..bdda30d475 100644 --- a/src/app/core/mock-data/team-reports-filters.data.ts +++ b/src/app/core/mock-data/team-reports-filters.data.ts @@ -1,63 +1,65 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TeamReportsFilters } from '../models/team-reports-filters.model'; -export const teamReportsFiltersData: Partial = { +export const teamReportsFiltersData: Partial = deepFreeze({ sortDir: 'desc', sortParam: 'rp_created_at', date: 'custom', -}; +}); -export const teamReportsFiltersData2: Partial = { +export const teamReportsFiltersData2: Partial = deepFreeze({ sortDir: 'desc', state: 'DRAFT', sortParam: 'rp_created_at', date: 'custom', customDateStart: new Date('2023-01-01'), customDateEnd: new Date('2023-02-02'), -}; +}); -export const teamReportsFiltersParams: Partial = { +export const teamReportsFiltersParams: Partial = deepFreeze({ sortParam: 'rp_purpose', sortDir: 'asc', -}; +}); -export const teamReportsFiltersParams2: Partial = { +export const teamReportsFiltersParams2: Partial = deepFreeze({ sortParam: 'rp_purpose', sortDir: 'desc', -}; +}); -export const teamReportsFiltersData3: Partial = { +export const teamReportsFiltersData3: Partial = deepFreeze({ state: 'DRAFT', date: 'custom', customDateStart: new Date('2023-01-01'), customDateEnd: new Date('2023-02-02'), -}; +}); -export const teamReportsFiltersData4: Partial = { +export const teamReportsFiltersData4: Partial = deepFreeze({ state: 'DRAFT', date: 'custom', customDateStart: undefined, customDateEnd: undefined, -}; +}); -export const teamReportsFiltersParams3: Partial = { +export const teamReportsFiltersParams3: Partial = deepFreeze({ state: ['DRAFT', 'PAID', 'CANCELLED'], -}; +}); -export const teamReportsFiltersParams4: Partial = { +export const teamReportsFiltersParams4: Partial = deepFreeze({ sortParam: 'rp_submitted_at', sortDir: 'asc', -}; +}); -export const teamReportsFiltersParams5: Partial = { +export const teamReportsFiltersParams5: Partial = deepFreeze({ sortParam: 'rp_amount', sortDir: 'desc', -}; +}); -export const teamReportsFiltersParams6: Partial = { +export const teamReportsFiltersParams6: Partial = deepFreeze({ sortParam: 'rp_purpose', sortDir: 'asc', -}; +}); -export const teamReportsFiltersParams7: Partial = { +export const teamReportsFiltersParams7: Partial = deepFreeze({ date: 'thisWeek', -}; +}); diff --git a/src/app/core/mock-data/track-expense-properties.data.ts b/src/app/core/mock-data/track-expense-properties.data.ts index 9fe56d7e65..abccf4ded3 100644 --- a/src/app/core/mock-data/track-expense-properties.data.ts +++ b/src/app/core/mock-data/track-expense-properties.data.ts @@ -1,3 +1,5 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ExpenseProperties } from '../models/tracking-properties.model'; import { expectedUnflattendedTxnData4, @@ -6,7 +8,7 @@ import { unflattenedTxnWithTrackData, } from './unflattened-txn.data'; -export const createExpenseProperties: ExpenseProperties = { +export const createExpenseProperties: ExpenseProperties = deepFreeze({ Type: 'Receipt', Amount: expectedUnflattendedTxnData4.tx.amount, Currency: expectedUnflattendedTxnData4.tx.currency, @@ -17,9 +19,9 @@ export const createExpenseProperties: ExpenseProperties = { Used_Autofilled_CostCenter: true, Used_Autofilled_Currency: true, Instafyle: false, -}; +}); -export const createExpenseProperties2: ExpenseProperties = { +export const createExpenseProperties2: ExpenseProperties = deepFreeze({ Type: 'Receipt', Amount: trackAddExpenseWoCurrency.tx.amount, Currency: trackAddExpenseWoCurrency.tx.currency, @@ -30,9 +32,9 @@ export const createExpenseProperties2: ExpenseProperties = { Used_Autofilled_CostCenter: true, Used_Autofilled_Currency: true, Instafyle: false, -}; +}); -export const editExpenseProperties1: ExpenseProperties = { +export const editExpenseProperties1: ExpenseProperties = deepFreeze({ Type: 'Mileage', Amount: unflattenedTxnWithTrackData.tx.amount, Currency: unflattenedTxnWithTrackData.tx.currency, @@ -42,9 +44,9 @@ export const editExpenseProperties1: ExpenseProperties = { Used_Autofilled_CostCenter: true, Used_Autofilled_VehicleType: true, Used_Autofilled_StartLocation: true, -}; +}); -export const createExpenseProperties3: ExpenseProperties = { +export const createExpenseProperties3: ExpenseProperties = deepFreeze({ Type: 'Receipt', Amount: 344, Currency: 'INR', @@ -52,9 +54,9 @@ export const createExpenseProperties3: ExpenseProperties = { Time_Spent: '180 secs', Used_Autofilled_Project: true, Used_Autofilled_CostCenter: true, -}; +}); -export const createExpenseProperties4: ExpenseProperties = { +export const createExpenseProperties4: ExpenseProperties = deepFreeze({ Type: 'Mileage', Amount: expenseTrackCreate.tx.amount, Currency: expenseTrackCreate.tx.currency, @@ -64,14 +66,14 @@ export const createExpenseProperties4: ExpenseProperties = { Used_Autofilled_CostCenter: true, Used_Autofilled_VehicleType: true, Used_Autofilled_StartLocation: true, -}; +}); -export const editExpenseProperties: ExpenseProperties = { +export const editExpenseProperties: ExpenseProperties = deepFreeze({ ...createExpenseProperties3, Type: 'Per Diem', -}; +}); -export const editExpensePropertiesPlatform: ExpenseProperties = { +export const editExpensePropertiesPlatform: ExpenseProperties = deepFreeze({ Type: 'Per Diem', Amount: 2263.68, Currency: 'USD', @@ -79,4 +81,4 @@ export const editExpensePropertiesPlatform: ExpenseProperties = { Time_Spent: '180 secs', Used_Autofilled_Project: null, Used_Autofilled_CostCenter: null, -}; +}); diff --git a/src/app/core/mock-data/transaction-status.data.ts b/src/app/core/mock-data/transaction-status.data.ts index 67693ec1c8..cc135cff28 100644 --- a/src/app/core/mock-data/transaction-status.data.ts +++ b/src/app/core/mock-data/transaction-status.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TransactionStatus } from '../models/transaction-status.model'; -export const txnStatusData: TransactionStatus = { +export const txnStatusData: TransactionStatus = deepFreeze({ id: 'stjIdPp8BX8O', created_at: new Date('2022-11-17T06:07:38.590Z'), org_user_id: 'ouX8dwsbLCLv', @@ -10,9 +12,9 @@ export const txnStatusData: TransactionStatus = { transaction_id: null, report_id: 'rpkpSa8guCuR', advance_request_id: null, -}; +}); -export const expenseStatusData: TransactionStatus = { +export const expenseStatusData: TransactionStatus = deepFreeze({ advance_request_id: null, comment: 'A comment', created_at: new Date('2024-02-11T16:43:25.675Z'), @@ -22,9 +24,9 @@ export const expenseStatusData: TransactionStatus = { report_id: null, state: null, transaction_id: 'txNWAit6pFgw', -}; +}); -export const txnStatusData1: TransactionStatus = { +export const txnStatusData1: TransactionStatus = deepFreeze({ id: 'stjIdPp7BX81', created_at: new Date('2022-11-17T06:07:38.590Z'), org_user_id: 'ouX8dwsbLCLv', @@ -34,9 +36,9 @@ export const txnStatusData1: TransactionStatus = { transaction_id: 'txxkBruL0EO9', report_id: null, advance_request_id: null, -}; +}); -export const txnStatusData2: TransactionStatus = { +export const txnStatusData2: TransactionStatus = deepFreeze({ id: 'stjIdPp7BX81', created_at: new Date('2022-11-17T06:07:38.590Z'), org_user_id: 'ouX8dwsbLCLv', @@ -46,4 +48,4 @@ export const txnStatusData2: TransactionStatus = { transaction_id: 'txNVtsqF8Siq', report_id: null, advance_request_id: null, -}; +}); diff --git a/src/app/core/mock-data/transaction.data.ts b/src/app/core/mock-data/transaction.data.ts index 1933336e12..32a6dfd4f0 100644 --- a/src/app/core/mock-data/transaction.data.ts +++ b/src/app/core/mock-data/transaction.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TransactionStatus } from '../models/platform/v1/expense.model'; import { Transaction } from '../models/v1/transaction.model'; import { optionsData15, optionsData33 } from './merge-expenses-options-data.data'; import { expectedTxnCustomProperties, txnCustomPropertiesData } from './txn-custom-properties.data'; -export const txnList: Transaction[] = [ +export const txnList: Transaction[] = deepFreeze([ { created_at: new Date('2023-01-31T04:03:12.575Z'), updated_at: new Date('2023-01-31T04:03:12.575Z'), @@ -172,9 +174,9 @@ export const txnList: Transaction[] = [ policy_amount: null, locations: [], }, -]; +]); -export const txnData: Transaction = { +export const txnData: Transaction = deepFreeze({ source: 'MOBILE_DASHCAM_BULK', txn_dt: new Date('2023-02-08T17:00:00.000Z'), currency: 'INR', @@ -184,9 +186,9 @@ export const txnData: Transaction = { custom_attributes: null, source_account_id: 'acc5APeygFjRd', skip_reimbursement: false, -}; +}); -export const txnData2: Transaction = { +export const txnData2: Transaction = deepFreeze({ created_at: new Date('2023-02-08T06:47:48.414Z'), updated_at: new Date('2023-02-08T06:47:48.414Z'), id: 'txNVtsqF8Siq', @@ -260,9 +262,9 @@ export const txnData2: Transaction = { physical_bill_at: null, policy_amount: null, locations: [], -}; +}); -export const upsertTxnParam: Transaction = { +export const upsertTxnParam: Transaction = deepFreeze({ skip_reimbursement: false, source: 'MOBILE', txn_dt: new Date('2023-02-13T17:00:00.000Z'), @@ -395,9 +397,9 @@ export const upsertTxnParam: Transaction = { admin_amount: null, custom_attributes: null, id: 'txT5J30Rsnbd', -}; +}); -export const txnData4: Transaction = { +export const txnData4: Transaction = deepFreeze({ created_at: new Date('2023-02-13T07:26:41.582Z'), updated_at: new Date('2023-02-13T07:26:44.188Z'), id: 'txT5J30Rsnbd', @@ -504,9 +506,9 @@ export const txnData4: Transaction = { physical_bill_at: null, policy_amount: null, locations: [], -}; +}); -export const txnDataPayload: Transaction = { +export const txnDataPayload: Transaction = deepFreeze({ skip_reimbursement: false, source: 'MOBILE', txn_dt: new Date('2023-02-13T17:00:00.000Z'), @@ -556,9 +558,9 @@ export const txnDataPayload: Transaction = { user_amount: null, admin_amount: null, custom_attributes: null, -}; +}); -export const splitPurposeTxn: Transaction = { +export const splitPurposeTxn: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -674,9 +676,9 @@ export const splitPurposeTxn: Transaction = { is_implicit_merge_blocked: false, categoryDisplayName: 'Unspecified', custom_attributes: null, -}; +}); -export const sourceSplitTxn: Transaction = { +export const sourceSplitTxn: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -784,9 +786,9 @@ export const sourceSplitTxn: Transaction = { ], is_implicit_merge_blocked: false, categoryDisplayName: '1 / ABCDFEIAPCALP ABCDFEIAPCALP ABCDFEIAPCALP ABCDFEIAPCALP ABCDFEIAPCALP', -}; +}); -export const splitTxn: Transaction = { +export const splitTxn: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -892,9 +894,9 @@ export const splitTxn: Transaction = { ], is_implicit_merge_blocked: false, categoryDisplayName: '1 / ABCDFEIAPCALP ABCDFEIAPCALP ABCDFEIAPCALP ABCDFEIAPCALP ABCDFEIAPCALP', -}; +}); -export const sourceTxn2: Transaction = { +export const sourceTxn2: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -1002,9 +1004,9 @@ export const sourceTxn2: Transaction = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Others', -}; +}); -export const splitTxns: Transaction[] = [ +export const splitTxns: Transaction[] = deepFreeze([ { risk_state: null, is_duplicate_expense: null, @@ -1221,9 +1223,9 @@ export const splitTxns: Transaction[] = [ is_implicit_merge_blocked: false, categoryDisplayName: 'Others', }, -]; +]); -export const createSourceTxn: Transaction = { +export const createSourceTxn: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -1410,9 +1412,9 @@ export const createSourceTxn: Transaction = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Food / Travelling - Inland', -}; +}); -export const createSourceTxn2: Transaction = { +export const createSourceTxn2: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -1513,9 +1515,9 @@ export const createSourceTxn2: Transaction = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Food / Travelling - Inland', -}; +}); -export const splitTxn2: Transaction[] = [ +export const splitTxn2: Transaction[] = deepFreeze([ { risk_state: null, is_duplicate_expense: null, @@ -1888,9 +1890,9 @@ export const splitTxn2: Transaction[] = [ is_implicit_merge_blocked: false, categoryDisplayName: 'Food / Travelling - Inland', }, -]; +]); -export const txnParam1: Transaction = { +export const txnParam1: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -2077,9 +2079,9 @@ export const txnParam1: Transaction = { is_implicit_merge_blocked: false, categoryDisplayName: 'Food / Travelling - Inland', custom_attributes: null, -}; +}); -export const txnParam2: Transaction = { +export const txnParam2: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -2266,9 +2268,9 @@ export const txnParam2: Transaction = { is_implicit_merge_blocked: false, categoryDisplayName: 'Food / Travelling - Inland', custom_attributes: null, -}; +}); -export const txnData5: Transaction = { +export const txnData5: Transaction = deepFreeze({ ...txnData, orig_currency: 'USD', orig_amount: 200, @@ -2293,17 +2295,17 @@ export const txnData5: Transaction = { value: [], }, ], -}; +}); -export const expectedTxnParams: Transaction = { +export const expectedTxnParams: Transaction = deepFreeze({ ...txnData5, split_group_id: 'txOJVaaPxo9O', split_group_user_amount: 100, orig_amount: 100, amount: 1000, -}; +}); -export const expectedTxnParams2: Transaction = { +export const expectedTxnParams2: Transaction = deepFreeze({ ...txnData5, orig_amount: 100, amount: 1000, @@ -2311,9 +2313,9 @@ export const expectedTxnParams2: Transaction = { split_group_user_amount: 100, cost_center_id: 13795, org_category_id: 123032, -}; +}); -export const expectedTxnParams3: Transaction = { +export const expectedTxnParams3: Transaction = deepFreeze({ ...txnData5, orig_currency: undefined, split_group_user_amount: 100, @@ -2321,9 +2323,9 @@ export const expectedTxnParams3: Transaction = { amount: null, cost_center_id: null, org_category_id: 117013, -}; +}); -export const expectedTxnParams4: Transaction = { +export const expectedTxnParams4: Transaction = deepFreeze({ ...txnData5, orig_currency: undefined, split_group_user_amount: 100, @@ -2331,16 +2333,16 @@ export const expectedTxnParams4: Transaction = { amount: null, cost_center_id: 13795, org_category_id: 123032, -}; +}); -export const expectedTxnParams5: Transaction = { +export const expectedTxnParams5: Transaction = deepFreeze({ ...txnData5, source: 'MOBILE_SPLIT', orig_amount: null, amount: 0, -}; +}); -export const splitExpenseTxn1: Transaction = { +export const splitExpenseTxn1: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -2431,9 +2433,9 @@ export const splitExpenseTxn1: Transaction = { custom_properties: [], is_implicit_merge_blocked: false, categoryDisplayName: 'Bus', -}; +}); -export const splitExpenseTxn1_1: Transaction = { +export const splitExpenseTxn1_1: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -2524,9 +2526,9 @@ export const splitExpenseTxn1_1: Transaction = { custom_properties: [], is_implicit_merge_blocked: false, categoryDisplayName: 'Bus', -}; +}); -export const txnAmount1: Transaction = { +export const txnAmount1: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -2618,9 +2620,9 @@ export const txnAmount1: Transaction = { custom_properties: [], is_implicit_merge_blocked: false, categoryDisplayName: 'Bus', -}; +}); -export const splitExpenseTxn2: Transaction = { +export const splitExpenseTxn2: Transaction = deepFreeze({ skip_reimbursement: false, source: 'MOBILE', id: 'txmsakgYZeCV', @@ -2641,9 +2643,9 @@ export const splitExpenseTxn2: Transaction = { fyle_category: 'Entertainment', admin_amount: 0, user_amount: 0, -}; +}); -export const splitExpenseTxn2_2: Transaction = { +export const splitExpenseTxn2_2: Transaction = deepFreeze({ skip_reimbursement: false, source: 'MOBILE', state: 'COMPLETE', @@ -2664,9 +2666,9 @@ export const splitExpenseTxn2_2: Transaction = { fyle_category: 'Entertainment', admin_amount: 0, user_amount: 0, -}; +}); -export const splitExpenseTxn2_3: Transaction = { +export const splitExpenseTxn2_3: Transaction = deepFreeze({ skip_reimbursement: false, source: 'MOBILE', id: 'txmsakgYZeCV', @@ -2687,9 +2689,9 @@ export const splitExpenseTxn2_3: Transaction = { fyle_category: 'Entertainment', admin_amount: 0, user_amount: 0, -}; +}); -export const txnAmount2: Transaction = { +export const txnAmount2: Transaction = deepFreeze({ skip_reimbursement: false, source: 'MOBILE_CAMERA', txn_dt: new Date('2023-06-15T18:30:00.000Z'), @@ -2708,9 +2710,9 @@ export const txnAmount2: Transaction = { fyle_category: 'Entertainment', admin_amount: 0, user_amount: 0, -}; +}); -export const splitExpenseTxn3: Transaction[] = [ +export const splitExpenseTxn3: Transaction[] = deepFreeze([ { risk_state: null, is_duplicate_expense: null, @@ -2957,9 +2959,9 @@ export const splitExpenseTxn3: Transaction[] = [ is_implicit_merge_blocked: false, categoryDisplayName: '1 / Entertainment', }, -]; +]); -export const amtTxn3: Transaction = { +export const amtTxn3: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3084,9 +3086,9 @@ export const amtTxn3: Transaction = { ], is_implicit_merge_blocked: false, categoryDisplayName: '1 / Entertainment', -}; +}); -export const editExpTxn = { +export const editExpTxn = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3190,9 +3192,9 @@ export const editExpTxn = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Software', -}; +}); -export const editExpTxn2 = { +export const editExpTxn2 = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3299,9 +3301,9 @@ export const editExpTxn2 = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'ani test', -}; +}); -export const editExpTxn3 = { +export const editExpTxn3 = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3408,9 +3410,9 @@ export const editExpTxn3 = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'ani test', -}; +}); -export const editExpTxn4 = { +export const editExpTxn4 = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3518,9 +3520,9 @@ export const editExpTxn4 = { is_implicit_merge_blocked: false, categoryDisplayName: 'ani test', tx_policy_amount: 0, -}; +}); -export const editExpTxn5 = { +export const editExpTxn5 = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3628,9 +3630,9 @@ export const editExpTxn5 = { is_implicit_merge_blocked: false, categoryDisplayName: 'ani test', tx_policy_amount: 0, -}; +}); -export const personalCardTxn: Transaction = { +export const personalCardTxn: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3749,9 +3751,9 @@ export const personalCardTxn: Transaction = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Software', -}; +}); -export const modifiedTxnData4: Transaction = { +export const modifiedTxnData4: Transaction = deepFreeze({ ...txnData4, from_dt: new Date('2023-08-04'), to_dt: new Date('2023-08-07'), @@ -3763,26 +3765,26 @@ export const modifiedTxnData4: Transaction = { org_category_id: 184692, txn_dt: new Date('Fri Aug 04 2023 05:30:00 GMT+0530 (India Standard Time)'), custom_properties: txnCustomPropertiesData, -}; +}); -export const modifiedTxnData5: Transaction = { +export const modifiedTxnData5: Transaction = deepFreeze({ ...modifiedTxnData4, project_id: 384582, -}; +}); -export const modifiedTxnData6: Transaction = { +export const modifiedTxnData6: Transaction = deepFreeze({ ...modifiedTxnData4, cost_center_id: 384582, project_id: undefined, -}; +}); -export const modifiedTxnData7: Transaction = { +export const modifiedTxnData7: Transaction = deepFreeze({ ...modifiedTxnData4, cost_center_id: undefined, project_id: undefined, -}; +}); -export const txnData6: Transaction = { +export const txnData6: Transaction = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -3882,9 +3884,9 @@ export const txnData6: Transaction = { proposed_exchange_rate: 0, status_id: '', updated_at: undefined, -}; +}); -export const perDiemTransaction: Partial = { +export const perDiemTransaction: Partial = deepFreeze({ source_account_id: 'accWUsrRlinFb', billable: true, org_category_id: 129140, @@ -3907,9 +3909,9 @@ export const perDiemTransaction: Partial = { cost_center_name: 'Test3', cost_center_code: 'code3', user_reason_for_duplicate_expenses: null, -}; +}); -export const editUnflattenedTransaction: Partial = { +export const editUnflattenedTransaction: Partial = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -4012,9 +4014,9 @@ export const editUnflattenedTransaction: Partial = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Software / Subscriptions', -}; +}); -export const editUnflattenedTransactionPlatform: Partial = { +export const editUnflattenedTransactionPlatform: Partial = deepFreeze({ id: 'txD5hIQgLuR5', created_at: new Date('2024-02-09T01:20:13.098Z'), txn_dt: new Date('2024-02-09T06:00:00.000Z'), @@ -4099,19 +4101,19 @@ export const editUnflattenedTransactionPlatform: Partial = { project_code: null, physical_bill: null, physical_bill_at: null, -}; +}); -export const editUnflattenedTransactionPlatform2: Partial = { +export const editUnflattenedTransactionPlatform2: Partial = deepFreeze({ ...editUnflattenedTransactionPlatform, report_id: 'rpbNc3kn5baq', -}; +}); -export const editUnflattenedTransactionPlatform3: Partial = { +export const editUnflattenedTransactionPlatform3: Partial = deepFreeze({ ...editUnflattenedTransactionPlatform, report_id: 'rplD17WeBlha', -}; +}); -export const editUnflattenedTransactionWithMatchCCCPlatform: Partial = { +export const editUnflattenedTransactionWithMatchCCCPlatform: Partial = deepFreeze({ id: 'txmF3wgfj0Bs', created_at: new Date('2024-01-23T01:19:49.370Z'), txn_dt: new Date('2018-07-03T13:00:00.000Z'), @@ -4184,9 +4186,9 @@ export const editUnflattenedTransactionWithMatchCCCPlatform: Partial = { +export const editTransaction2: Partial = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -4289,9 +4291,9 @@ export const editTransaction2: Partial = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Software / Subscriptions', -}; +}); -export const editTransaction3: Partial = { +export const editTransaction3: Partial = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -4420,9 +4422,9 @@ export const editTransaction3: Partial = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'ani test', -}; +}); -export const editTransaction4: Partial = { +export const editTransaction4: Partial = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -4551,9 +4553,9 @@ export const editTransaction4: Partial = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'ani test', -}; +}); -export const editTransaction5: Partial = { +export const editTransaction5: Partial = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -4656,9 +4658,9 @@ export const editTransaction5: Partial = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'Software / Subscriptions', -}; +}); -export const editTransaction6: Partial = { +export const editTransaction6: Partial = deepFreeze({ risk_state: null, is_duplicate_expense: null, duplicates: null, @@ -4787,43 +4789,43 @@ export const editTransaction6: Partial = { ], is_implicit_merge_blocked: false, categoryDisplayName: 'ani test', -}; +}); -export const txnData7: Transaction = { +export const txnData7: Transaction = deepFreeze({ ...txnData5, orig_amount: 100, amount: 1000, split_group_id: 'txOJVaaPxo9O', split_group_user_amount: 100, -}; +}); -export const txnData8: Transaction = { +export const txnData8: Transaction = deepFreeze({ ...txnData7, cost_center_id: 13795, org_category_id: 123032, -}; +}); -export const txnData9: Transaction = { +export const txnData9: Transaction = deepFreeze({ ...txnData5, amount: null, orig_currency: undefined, -}; +}); -export const txnData10: Transaction = { +export const txnData10: Transaction = deepFreeze({ ...txnData9, cost_center_id: 13795, org_category_id: 123032, -}; +}); -export const txnData11: Transaction = { +export const txnData11: Transaction = deepFreeze({ ...txnData5, source: 'MOBILE_SPLIT', orig_amount: null, amount: 0, -}; +}); -export const txnData12: Transaction = { +export const txnData12: Transaction = deepFreeze({ ...txnData11, cost_center_id: 13795, org_category_id: 123032, -}; +}); diff --git a/src/app/core/mock-data/transformed-expense.data.ts b/src/app/core/mock-data/transformed-expense.data.ts index f9ed386f80..21308e8801 100644 --- a/src/app/core/mock-data/transformed-expense.data.ts +++ b/src/app/core/mock-data/transformed-expense.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TransactionStatus } from '../models/platform/v1/expense.model'; import { UnflattenedTransaction } from '../models/unflattened-transaction.model'; -export const transformedExpenseData: Partial = { +export const transformedExpenseData: Partial = deepFreeze({ tx: { id: 'txvslh8aQMbu', created_at: new Date('2023-12-05T17:20:43.158Z'), @@ -75,9 +77,9 @@ export const transformedExpenseData: Partial = { id: 'ou6cE4dCLH8d', org_id: 'orNbIQloYtfa', }, -}; +}); -export const transformedExpenseDataWithSubCategory: Partial = { +export const transformedExpenseDataWithSubCategory: Partial = deepFreeze({ tx: { id: 'txD5hIQgLuR5', created_at: new Date('2024-02-09T01:20:13.098Z'), @@ -172,25 +174,25 @@ export const transformedExpenseDataWithSubCategory: Partial = { +export const transformedExpenseDataWithReportId: Partial = deepFreeze({ ...transformedExpenseDataWithSubCategory, tx: { ...transformedExpenseDataWithSubCategory.tx, report_id: 'rpbNc3kn5baq', }, -}; +}); -export const transformedExpenseDataWithReportId2: Partial = { +export const transformedExpenseDataWithReportId2: Partial = deepFreeze({ ...transformedExpenseDataWithSubCategory, tx: { ...transformedExpenseDataWithSubCategory.tx, report_id: 'rplD17WeBlha', }, -}; +}); -export const transformedExpenseWithExtractedData: Partial = { +export const transformedExpenseWithExtractedData: Partial = deepFreeze({ tx: { id: 'txO6d6eiB4JF', created_at: new Date('2024-02-11T17:27:43.416Z'), @@ -290,9 +292,9 @@ export const transformedExpenseWithExtractedData: Partial = { +export const transformedExpenseWithExtractedData2: Partial = deepFreeze({ ...transformedExpenseWithExtractedData, tx: { ...transformedExpenseWithExtractedData.tx, @@ -309,9 +311,9 @@ export const transformedExpenseWithExtractedData2: Partial = { +export const transformedExpenseWithMatchCCCData: Partial = deepFreeze({ tx: { id: 'txmF3wgfj0Bs', created_at: new Date('2024-01-23T01:19:49.370Z'), @@ -392,9 +394,9 @@ export const transformedExpenseWithMatchCCCData: Partial id: 'ouokfwl9OEdl', org_id: 'oroLKHBYQVvj', }, -}; +}); -export const transformedExpenseWithMatchCCCData2: Partial = { +export const transformedExpenseWithMatchCCCData2: Partial = deepFreeze({ ...transformedExpenseWithMatchCCCData, tx: { ...transformedExpenseWithMatchCCCData.tx, @@ -402,9 +404,9 @@ export const transformedExpenseWithMatchCCCData2: Partial = { +export const transformedExpenseWithMatchCCCData3: Partial = deepFreeze({ ...transformedExpenseWithMatchCCCData, tx: { ...transformedExpenseWithMatchCCCData.tx, @@ -428,9 +430,9 @@ export const transformedExpenseWithMatchCCCData3: Partial = { +export const transformedExpenseWithMatchCCCData4: Partial = deepFreeze({ tx: { id: 'txmF3wgfj0Bs', created_at: new Date('2024-01-23T01:19:49.370Z'), @@ -496,14 +498,14 @@ export const transformedExpenseWithMatchCCCData4: Partial = { +export const mileageCategoryTransformedExpenseData: Partial = deepFreeze({ ...transformedExpenseData, tx: { ...transformedExpenseData.tx, org_category: 'MILEAGE' }, -}; +}); -export const perDiemCategoryTransformedExpenseData: Partial = { +export const perDiemCategoryTransformedExpenseData: Partial = deepFreeze({ ...transformedExpenseData, tx: { ...transformedExpenseData.tx, org_category: 'PER DIEM' }, -}; +}); diff --git a/src/app/core/mock-data/transformed-split-expense-missing-fields.data.ts b/src/app/core/mock-data/transformed-split-expense-missing-fields.data.ts index 5eeabfbb18..cf676b1300 100644 --- a/src/app/core/mock-data/transformed-split-expense-missing-fields.data.ts +++ b/src/app/core/mock-data/transformed-split-expense-missing-fields.data.ts @@ -1,16 +1,18 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TransformedSplitExpenseMissingFields } from '../models/transformed-split-expense-missing-fields.model'; -export const transformedSplitExpenseMissingFieldsData: Partial = { +export const transformedSplitExpenseMissingFieldsData: Partial = deepFreeze({ amount: 67, currency: 'USD', name: 'food', type: 'category', -}; +}); -export const transformedSplitExpenseMissingFieldsData2: Partial = { +export const transformedSplitExpenseMissingFieldsData2: Partial = deepFreeze({ amount: 122, currency: 'INR', name: 'Food', type: 'category', data: { missing_amount: false, missing_receipt: false, missing_currency: false, missing_expense_field_ids: [] }, -}; +}); diff --git a/src/app/core/mock-data/txn-account.data.ts b/src/app/core/mock-data/txn-account.data.ts index 901a71b6d0..af804b85a5 100644 --- a/src/app/core/mock-data/txn-account.data.ts +++ b/src/app/core/mock-data/txn-account.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TransactionAccount } from '../models/transaction-account.model'; -export const txnAccountData: TransactionAccount = { +export const txnAccountData: TransactionAccount = deepFreeze({ source_account_id: 'acc5APeygFjRd', skip_reimbursement: false, -}; +}); diff --git a/src/app/core/mock-data/txn-custom-properties.data.ts b/src/app/core/mock-data/txn-custom-properties.data.ts index 1d80867906..8bf77ade39 100644 --- a/src/app/core/mock-data/txn-custom-properties.data.ts +++ b/src/app/core/mock-data/txn-custom-properties.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { TxnCustomProperties } from '../models/txn-custom-properties.model'; -export const txnCustomPropertiesData: TxnCustomProperties[] = [ +export const txnCustomPropertiesData: TxnCustomProperties[] = deepFreeze([ { id: 200227, mandatory: false, @@ -103,9 +105,9 @@ export const txnCustomPropertiesData: TxnCustomProperties[] = [ type: 'DATE', value: '2023-02-13T17:00:00.000Z', }, -]; +]); -export const txnCustomPropertiesData2: TxnCustomProperties[] = [ +export const txnCustomPropertiesData2: TxnCustomProperties[] = deepFreeze([ { id: 200227, mandatory: false, @@ -208,9 +210,9 @@ export const txnCustomPropertiesData2: TxnCustomProperties[] = [ type: 'DATE', value: '2023-02-13T17:00:00.000Z', }, -]; +]); -export const txnCustomPropertiesData3: TxnCustomProperties[] = [ +export const txnCustomPropertiesData3: TxnCustomProperties[] = deepFreeze([ { id: 213300, prefix: '', @@ -286,9 +288,9 @@ export const txnCustomPropertiesData3: TxnCustomProperties[] = [ options: undefined, parent_field_id: null, }, -]; +]); -export const txnCustomPropertiesData4: TxnCustomProperties[] = [ +export const txnCustomPropertiesData4: TxnCustomProperties[] = deepFreeze([ { id: 200227, prefix: '', @@ -377,9 +379,9 @@ export const txnCustomPropertiesData4: TxnCustomProperties[] = [ options: [], parent_field_id: null, }, -]; +]); -export const expectedTxnCustomProperties: TxnCustomProperties[] = [ +export const expectedTxnCustomProperties: TxnCustomProperties[] = deepFreeze([ { id: 200227, mandatory: false, @@ -433,9 +435,9 @@ export const expectedTxnCustomProperties: TxnCustomProperties[] = [ type: 'DATE', value: new Date('2023-02-13T17:00:00.000Z'), }, -]; +]); -export const TxnCustomProperties3: TxnCustomProperties[] = [ +export const TxnCustomProperties3: TxnCustomProperties[] = deepFreeze([ { id: 200227, mandatory: false, @@ -456,9 +458,9 @@ export const TxnCustomProperties3: TxnCustomProperties[] = [ type: 'DATE', value: '2023-02-13T17:00:00.000Z', }, -]; +]); -export const txnCustomProperties4: TxnCustomProperties[] = [ +export const txnCustomProperties4: TxnCustomProperties[] = deepFreeze([ { id: 318297, mandatory: true, @@ -532,9 +534,9 @@ export const txnCustomProperties4: TxnCustomProperties[] = [ type: 'DATE', value: new Date('2023-02-13T17:00:00.000Z'), }, -]; +]); -export const txnCustomPropertiesData6: TxnCustomProperties[] = [ +export const txnCustomPropertiesData6: TxnCustomProperties[] = deepFreeze([ { id: 200227, mandatory: false, @@ -637,9 +639,9 @@ export const txnCustomPropertiesData6: TxnCustomProperties[] = [ type: 'DATE', value: '2023-02-13T17:00:00.000Z', }, -]; +]); -export const txnCustomPropertiesData5: TxnCustomProperties[] = [ +export const txnCustomPropertiesData5: TxnCustomProperties[] = deepFreeze([ { id: 318297, mandatory: true, @@ -713,4 +715,4 @@ export const txnCustomPropertiesData5: TxnCustomProperties[] = [ type: 'DATE', value: new Date('2023-02-13T17:00:00.000Z'), }, -]; +]); diff --git a/src/app/core/mock-data/undo-merge.data.ts b/src/app/core/mock-data/undo-merge.data.ts index d7b15996da..81141300ab 100644 --- a/src/app/core/mock-data/undo-merge.data.ts +++ b/src/app/core/mock-data/undo-merge.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { UndoMerge } from '../models/undo-merge.model'; import { txnList } from './transaction.data'; -export const UndoMergeData: UndoMerge = { +export const UndoMergeData: UndoMerge = deepFreeze({ user_created_expense: { created_at: new Date('2022-02-17T14:12:49.079Z'), updated_at: new Date('2022-06-12T11:37:06.592Z'), @@ -152,9 +154,9 @@ export const UndoMergeData: UndoMerge = { policy_amount: null, locations: [], }, -}; +}); -export const UndoMergeData2: UndoMerge = { +export const UndoMergeData2: UndoMerge = deepFreeze({ user_created_expense: txnList[0], auto_created_expense: txnList[1], -}; +}); diff --git a/src/app/core/mock-data/unflattened-advance-request.data.ts b/src/app/core/mock-data/unflattened-advance-request.data.ts index 5a40adfad3..aa9508beb5 100644 --- a/src/app/core/mock-data/unflattened-advance-request.data.ts +++ b/src/app/core/mock-data/unflattened-advance-request.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { UnflattenedAdvanceRequest } from '../models/unflattened-advance-request.model'; -export const unflattenedAdvanceRequestData: UnflattenedAdvanceRequest = { +export const unflattenedAdvanceRequestData: UnflattenedAdvanceRequest = deepFreeze({ areq: { id: 'areqLFKMxUSAlQ', created_at: new Date('2023-10-03T09:20:22.112Z'), @@ -69,4 +71,4 @@ export const unflattenedAdvanceRequestData: UnflattenedAdvanceRequest = { new: { state: 'APPROVAL_PENDING', }, -}; +}); diff --git a/src/app/core/mock-data/unflattened-expense.data.ts b/src/app/core/mock-data/unflattened-expense.data.ts index 0e6610a666..882c69dad7 100644 --- a/src/app/core/mock-data/unflattened-expense.data.ts +++ b/src/app/core/mock-data/unflattened-expense.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ExpenseSource } from '../models/expense-source.enum'; import { ExpenseState } from '../models/expense-state.enum'; import { PublicPolicyExpense } from '../models/public-policy-expense.model'; import { UnflattenedTransaction } from '../models/unflattened-transaction.model'; -export const unflattenExp1: { tx: PublicPolicyExpense } = { +export const unflattenExp1: { tx: PublicPolicyExpense } = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -111,9 +113,9 @@ export const unflattenExp1: { tx: PublicPolicyExpense } = { status_id: '', updated_at: undefined, }, -}; +}); -export const unflattenExp2: { tx: PublicPolicyExpense } = { +export const unflattenExp2: { tx: PublicPolicyExpense } = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -225,9 +227,9 @@ export const unflattenExp2: { tx: PublicPolicyExpense } = { status_id: '', updated_at: undefined, }, -}; +}); -export const unflattenedTxn: UnflattenedTransaction = { +export const unflattenedTxn: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -352,9 +354,9 @@ export const unflattenedTxn: UnflattenedTransaction = { is: { test_call: false, }, -}; +}); -export const unflattenedExpData = { +export const unflattenedExpData = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -523,9 +525,9 @@ export const unflattenedExpData = { test_call: null, }, dataUrls: [], -}; +}); -export const draftUnflattendedTxn = { +export const draftUnflattendedTxn = deepFreeze({ ...unflattenedExpData, tx: { ...unflattenedExpData.tx, @@ -535,9 +537,9 @@ export const draftUnflattendedTxn = { org_category_id: null, fyle_category: 'UNSPECIFIED', }, -}; +}); -export const draftUnflattendedTxn2: UnflattenedTransaction = { +export const draftUnflattendedTxn2: UnflattenedTransaction = deepFreeze({ ...unflattenedExpData, tx: { ...unflattenedExpData.tx, @@ -547,9 +549,9 @@ export const draftUnflattendedTxn2: UnflattenedTransaction = { org_category_id: null, fyle_category: null, }, -}; +}); -export const draftUnflattendedTxn3 = { +export const draftUnflattendedTxn3 = deepFreeze({ ...unflattenedExpData, tx: { ...unflattenedExpData.tx, @@ -559,9 +561,9 @@ export const draftUnflattendedTxn3 = { org_category_id: null, fyle_category: 'UNSPECIFIED', }, -}; +}); -export const draftUnflattendedTxn4: UnflattenedTransaction = { +export const draftUnflattendedTxn4: UnflattenedTransaction = deepFreeze({ ...unflattenedExpData, tx: { ...unflattenedExpData.tx, @@ -571,9 +573,9 @@ export const draftUnflattendedTxn4: UnflattenedTransaction = { org_category_id: 212690, fyle_category: null, }, -}; +}); -export const unflattenedTxnDataPerDiem = { +export const unflattenedTxnDataPerDiem = deepFreeze({ tx: { // TODO: Enum for state and source skip_reimbursement: false, @@ -593,4 +595,4 @@ export const unflattenedTxnDataPerDiem = { custom_properties: [], org_user_id: 'ouX8dwsbLCLv', }, -}; +}); diff --git a/src/app/core/mock-data/unflattened-txn.data.ts b/src/app/core/mock-data/unflattened-txn.data.ts index 10ce3de82c..29c0ba7168 100644 --- a/src/app/core/mock-data/unflattened-txn.data.ts +++ b/src/app/core/mock-data/unflattened-txn.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { CommuteDeduction } from '../enums/commute-deduction.enum'; import { UnflattenedTransaction } from '../models/unflattened-transaction.model'; import { optionsData15, optionsData33 } from './merge-expenses-options-data.data'; import { personalCardTxn } from './transaction.data'; -export const unflattenedTxnData: UnflattenedTransaction = { +export const unflattenedTxnData: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -151,9 +153,9 @@ export const unflattenedTxnData: UnflattenedTransaction = { is: { test_call: null, }, -}; +}); -export const unflattenedTxnDataWithSubCategory: UnflattenedTransaction = { +export const unflattenedTxnDataWithSubCategory: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -301,9 +303,9 @@ export const unflattenedTxnDataWithSubCategory: UnflattenedTransaction = { is: { test_call: null, }, -}; +}); -export const unflattenedTxnWithExtractedData: UnflattenedTransaction = { +export const unflattenedTxnWithExtractedData: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -322,9 +324,9 @@ export const unflattenedTxnWithExtractedData: UnflattenedTransaction = { invoice_dt: new Date('2023-02-24T12:03:57.680Z'), }, }, -}; +}); -export const expectedUnflattendedTxnData1: UnflattenedTransaction = { +export const expectedUnflattendedTxnData1: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, txn_dt: new Date('2023-01-24T11:30:00.000Z'), @@ -472,9 +474,9 @@ export const expectedUnflattendedTxnData1: UnflattenedTransaction = { is: { test_call: null, }, -}; +}); -export const expectedUnflattendedTxnData2 = { +export const expectedUnflattendedTxnData2 = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -593,18 +595,18 @@ export const expectedUnflattendedTxnData2 = { joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, dataUrls: [], -}; +}); -export const unflattenedTxnData2: UnflattenedTransaction = { +export const unflattenedTxnData2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, amount: 100, user_amount: 100, }, -}; +}); -export const expectedUnflattendedTxnData3: UnflattenedTransaction = { +export const expectedUnflattendedTxnData3: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -761,9 +763,9 @@ export const expectedUnflattendedTxnData3: UnflattenedTransaction = { is: { test_call: false, }, -}; +}); -export const expectedUnflattendedTxnData4: UnflattenedTransaction = { +export const expectedUnflattendedTxnData4: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -914,9 +916,9 @@ export const expectedUnflattendedTxnData4: UnflattenedTransaction = { is: { test_call: false, }, -}; +}); -export const expectedUnflattendedTxnData5 = { +export const expectedUnflattendedTxnData5 = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -1051,9 +1053,9 @@ export const expectedUnflattendedTxnData5 = { joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, dataUrls: [], -}; +}); -export const unflattenedTxnDataWithoutCategoryData: UnflattenedTransaction = { +export const unflattenedTxnDataWithoutCategoryData: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -1061,9 +1063,9 @@ export const unflattenedTxnDataWithoutCategoryData: UnflattenedTransaction = { org_category_id: null, fyle_category: 'unspecified', }, -}; +}); -export const expWithCriticalViolation: { etxn: UnflattenedTransaction; comment: string } = { +export const expWithCriticalViolation: { etxn: UnflattenedTransaction; comment: string } = deepFreeze({ etxn: { tx: { risk_state: null, @@ -1235,9 +1237,9 @@ export const expWithCriticalViolation: { etxn: UnflattenedTransaction; comment: dataUrls: [], }, comment: null, -}; +}); -export const unflattenedPaidExp: UnflattenedTransaction = { +export const unflattenedPaidExp: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -1245,9 +1247,9 @@ export const unflattenedPaidExp: UnflattenedTransaction = { fyle_category: 'TRAVEL', org_category_id: 12345, }, -}; +}); -export const unflattenedDraftExp: UnflattenedTransaction = { +export const unflattenedDraftExp: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -1255,9 +1257,9 @@ export const unflattenedDraftExp: UnflattenedTransaction = { fyle_category: 'unspecified', org_category_id: 12345, }, -}; +}); -export const unflattenedDraftExp2: UnflattenedTransaction = { +export const unflattenedDraftExp2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -1266,18 +1268,18 @@ export const unflattenedDraftExp2: UnflattenedTransaction = { fyle_category: 'unspecified', org_category_id: null, }, -}; +}); -export const unflattenedPaidExp2: UnflattenedTransaction = { +export const unflattenedPaidExp2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, state: 'PAID', fyle_category: 'TRAVEL', }, -}; +}); -export const expectedExpenseObservable: Partial = { +export const expectedExpenseObservable: Partial = deepFreeze({ tx: { skip_reimbursement: false, source: 'MOBILE', @@ -1311,9 +1313,9 @@ export const expectedExpenseObservable: Partial = { thumbnail: 'data-url', }, ], -}; +}); -export const expectedExpenseObservable2 = { +export const expectedExpenseObservable2 = deepFreeze({ tx: { skip_reimbursement: false, source: 'MOBILE', @@ -1330,9 +1332,9 @@ export const expectedExpenseObservable2 = { project_id: 3943, }, dataUrls: [], -}; +}); -export const expectedExpenseObservable3: Partial = { +export const expectedExpenseObservable3: Partial = deepFreeze({ tx: { skip_reimbursement: false, source: 'MOBILE', @@ -1366,9 +1368,9 @@ export const expectedExpenseObservable3: Partial = { thumbnail: 'data-url', }, ], -}; +}); -export const expectedExpenseObservable4: Partial = { +export const expectedExpenseObservable4: Partial = deepFreeze({ tx: { source: 'MOBILE', currency: 'INR', @@ -1400,9 +1402,9 @@ export const expectedExpenseObservable4: Partial = { thumbnail: 'data-url', }, ], -}; +}); -export const expectedExpenseObservable5: Partial = { +export const expectedExpenseObservable5: Partial = deepFreeze({ tx: { source: 'MOBILE', currency: 'USD', @@ -1433,9 +1435,9 @@ export const expectedExpenseObservable5: Partial = { thumbnail: 'data-url', }, ], -}; +}); -export const unflattenedTxnDataWithoutCategoryData2: UnflattenedTransaction = { +export const unflattenedTxnDataWithoutCategoryData2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -1450,17 +1452,17 @@ export const unflattenedTxnDataWithoutCategoryData2: UnflattenedTransaction = { org_category_id: 12345, fyle_category: 'unspecified', }, -}; +}); -export const unflattenedTransactionDataPersonalCard: UnflattenedTransaction = { +export const unflattenedTransactionDataPersonalCard: UnflattenedTransaction = deepFreeze({ ...expectedUnflattendedTxnData3, tx: { ...personalCardTxn, locations: null, }, -}; +}); -export const newUnflattenedTxn = { +export const newUnflattenedTxn = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -1623,9 +1625,9 @@ export const newUnflattenedTxn = { test_call: null, }, dataUrls: [], -}; +}); -export const unflattenedTxnDataWithReportID = { +export const unflattenedTxnDataWithReportID = deepFreeze({ ...expectedUnflattendedTxnData2, tx: { ...expectedUnflattendedTxnData2.tx, @@ -1651,9 +1653,9 @@ export const unflattenedTxnDataWithReportID = { is: { test_call: false, }, -}; +}); -export const unflattenedTxnDataWithReportID2 = { +export const unflattenedTxnDataWithReportID2 = deepFreeze({ ...expectedUnflattendedTxnData2, tx: { ...expectedUnflattendedTxnData2.tx, @@ -1679,9 +1681,9 @@ export const unflattenedTxnDataWithReportID2 = { is: { test_call: false, }, -}; +}); -export const unflattenedTxnDataWithViolationUserReview = { +export const unflattenedTxnDataWithViolationUserReview = deepFreeze({ ...expectedUnflattendedTxnData2, tx: { ...expectedUnflattendedTxnData2.tx, @@ -1708,18 +1710,18 @@ export const unflattenedTxnDataWithViolationUserReview = { is: { test_call: false, }, -}; +}); -export const unflattenedExpenseWithCCCGroupId = { +export const unflattenedExpenseWithCCCGroupId = deepFreeze({ ...unflattenedTxnDataWithViolationUserReview, tx: { ...expectedUnflattendedTxnData2.tx, corporate_credit_card_expense_group_id: 'ccceWauzF1A3oS', report_id: null, }, -}; +}); -export const unflattenedExpenseWithCCCGroupId2 = { +export const unflattenedExpenseWithCCCGroupId2 = deepFreeze({ ...unflattenedTxnDataWithViolationUserReview, tx: { ...expectedUnflattendedTxnData2.tx, @@ -1728,47 +1730,47 @@ export const unflattenedExpenseWithCCCGroupId2 = { report_id: null, policy_amount: -100, }, -}; +}); -export const txnWithCCCGroupID = { +export const txnWithCCCGroupID = deepFreeze({ ...unflattenedTxnData.tx, corporate_credit_card_expense_group_id: 'ccceWauzF1A3oS', report_id: null, -}; +}); -export const unflattenedExpWoProject = { +export const unflattenedExpWoProject = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, project_id: null, }, -}; +}); -export const unflattenedExpWithReport = { +export const unflattenedExpWithReport = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, report_id: 'rprAfNrce73O', }, -}; +}); -export const unflattenedExpWithCostCenter = { +export const unflattenedExpWithCostCenter = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, cost_center_id: 2411, }, -}; +}); -export const unflattenedExpWoCostCenter = { +export const unflattenedExpWoCostCenter = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, cost_center_id: null, }, -}; +}); -export const unflattenedExp2 = { +export const unflattenedExp2 = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -1787,9 +1789,9 @@ export const unflattenedExp2 = { thumbnail: 'data-url', }, ], -}; +}); -export const unflattenedExpWithCCCExpn: UnflattenedTransaction = { +export const unflattenedExpWithCCCExpn: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -1810,26 +1812,26 @@ export const unflattenedExpWithCCCExpn: UnflattenedTransaction = { thumbnail: 'data-url', }, ], -}; +}); -export const unflattenedExpWithCCCExpn1: UnflattenedTransaction = { +export const unflattenedExpWithCCCExpn1: UnflattenedTransaction = deepFreeze({ ...unflattenedExpWithCCCExpn, tx: { ...unflattenedExpWithCCCExpn.tx, split_group_id: 'tx6I9xcOZFU6', }, -}; +}); -export const unflattenedExpWithoutCCExpnSync: UnflattenedTransaction = { +export const unflattenedExpWithoutCCExpnSync: UnflattenedTransaction = deepFreeze({ ...unflattenedExpWithCCCExpn, tx: { ...unflattenedExpWithCCCExpn.tx, matched_corporate_card_transactions: [], split_group_id: 'tx6I9xcOZFU6', }, -}; +}); -export const trackCreateExpData: UnflattenedTransaction = { +export const trackCreateExpData: UnflattenedTransaction = deepFreeze({ ...unflattenedExp2, tx: { ...unflattenedExp2.tx, @@ -1839,9 +1841,9 @@ export const trackCreateExpData: UnflattenedTransaction = { currency: 'USD', orig_currency: 'USD', }, -}; +}); -export const trackCreateExpDataWoCurrency: UnflattenedTransaction = { +export const trackCreateExpDataWoCurrency: UnflattenedTransaction = deepFreeze({ ...unflattenedExp2, tx: { ...unflattenedExp2.tx, @@ -1851,9 +1853,9 @@ export const trackCreateExpDataWoCurrency: UnflattenedTransaction = { currency: null, orig_currency: 'USD', }, -}; +}); -export const trackAddExpenseWoCurrency: Partial = { +export const trackAddExpenseWoCurrency: Partial = deepFreeze({ ...expectedUnflattendedTxnData4, tx: { ...expectedUnflattendedTxnData4.tx, @@ -1886,9 +1888,9 @@ export const trackAddExpenseWoCurrency: Partial = { test_call: false, }, dataUrls: null, -}; +}); -export const newExpFromFg: Partial = { +export const newExpFromFg: Partial = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -2039,9 +2041,9 @@ export const newExpFromFg: Partial = { joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, dataUrls: [], -}; +}); -export const newExpFromFg2: Partial = { +export const newExpFromFg2: Partial = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -2193,9 +2195,9 @@ export const newExpFromFg2: Partial = { joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, dataUrls: [], -}; +}); -export const newExpFromFg3: Partial = { +export const newExpFromFg3: Partial = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -2330,9 +2332,9 @@ export const newExpFromFg3: Partial = { joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, dataUrls: [], -}; +}); -export const newExpFromFg4: Partial = { +export const newExpFromFg4: Partial = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -2467,9 +2469,9 @@ export const newExpFromFg4: Partial = { joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, dataUrls: [], -}; +}); -export const newExpFromFgPlatform: Partial = { +export const newExpFromFgPlatform: Partial = deepFreeze({ tx: { id: 'txD5hIQgLuR5', created_at: new Date('2024-02-09T01:20:13.098Z'), @@ -2581,14 +2583,14 @@ export const newExpFromFgPlatform: Partial = { org_id: 'orNbIQloYtfa', }, dataUrls: [], -}; +}); -export const expWithSplitGroupID: Partial = { +export const expWithSplitGroupID: Partial = deepFreeze({ ...unflattenedTxnData, tx: null, -}; +}); -export const unflattenedTxnWithExtractedData2: UnflattenedTransaction = { +export const unflattenedTxnWithExtractedData2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2607,9 +2609,9 @@ export const unflattenedTxnWithExtractedData2: UnflattenedTransaction = { invoice_dt: new Date('2023-02-24T12:03:57.680Z'), }, }, -}; +}); -export const unflattenedDraftExp3: UnflattenedTransaction = { +export const unflattenedDraftExp3: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2618,9 +2620,9 @@ export const unflattenedDraftExp3: UnflattenedTransaction = { fyle_category: null, org_category_id: null, }, -}; +}); -export const checkSplitExpData1: UnflattenedTransaction = { +export const checkSplitExpData1: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2631,9 +2633,9 @@ export const checkSplitExpData1: UnflattenedTransaction = { org_category_id: null, split_group_id: 'tx3qHxFNgRcZ', }, -}; +}); -export const checkSplitExpData2: UnflattenedTransaction = { +export const checkSplitExpData2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2641,9 +2643,9 @@ export const checkSplitExpData2: UnflattenedTransaction = { state: 'COMPLETE', split_group_id: null, }, -}; +}); -export const checkDebitCCCExpenseData1: UnflattenedTransaction = { +export const checkDebitCCCExpenseData1: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2652,9 +2654,9 @@ export const checkDebitCCCExpenseData1: UnflattenedTransaction = { amount: 100, corporate_credit_card_expense_group_id: 'tx3qHxFNgRcZ', }, -}; +}); -export const checkDebitCCCExpenseData2: UnflattenedTransaction = { +export const checkDebitCCCExpenseData2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2663,9 +2665,9 @@ export const checkDebitCCCExpenseData2: UnflattenedTransaction = { amount: -1, corporate_credit_card_expense_group_id: 'tx3qHxFNgRcZ', }, -}; +}); -export const setupFormExpenseWoCurrency: UnflattenedTransaction = { +export const setupFormExpenseWoCurrency: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData, @@ -2688,9 +2690,9 @@ export const setupFormExpenseWoCurrency: UnflattenedTransaction = { }, ], }, -}; +}); -export const setupFormExpenseWoCurrency2: UnflattenedTransaction = { +export const setupFormExpenseWoCurrency2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2712,9 +2714,9 @@ export const setupFormExpenseWoCurrency2: UnflattenedTransaction = { }, ], }, -}; +}); -export const setupFormExpenseWoCurrency3: UnflattenedTransaction = { +export const setupFormExpenseWoCurrency3: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2727,9 +2729,9 @@ export const setupFormExpenseWoCurrency3: UnflattenedTransaction = { locations: [], project_id: null, }, -}; +}); -export const expectedPersonalTxn: UnflattenedTransaction = { +export const expectedPersonalTxn: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -2878,9 +2880,9 @@ export const expectedPersonalTxn: UnflattenedTransaction = { }, us: undefined, rp: undefined, -}; +}); -export const newExpenseMileageData1: Partial = { +export const newExpenseMileageData1: Partial = deepFreeze({ tx: { skip_reimbursement: false, source: 'MOBILE', @@ -2904,9 +2906,9 @@ export const newExpenseMileageData1: Partial = { locations: [], custom_properties: [], }, -}; +}); -export const newExpenseMileageData2: Partial = { +export const newExpenseMileageData2: Partial = deepFreeze({ tx: { skip_reimbursement: false, source: 'MOBILE', @@ -2940,42 +2942,42 @@ export const newExpenseMileageData2: Partial = { ], custom_properties: [], }, -}; -export const mileageCategoryUnflattenedExpense: UnflattenedTransaction = { +}); +export const mileageCategoryUnflattenedExpense: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, org_category: 'MILEAGE' }, -}; +}); -export const perDiemCategoryUnflattenedExpense: UnflattenedTransaction = { +export const perDiemCategoryUnflattenedExpense: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, org_category: 'PER DIEM' }, -}; +}); -export const unflattenedTxnWithSourceID: UnflattenedTransaction = { +export const unflattenedTxnWithSourceID: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, source_account_id: 'acc6mK6CEesGL', }, -}; +}); -export const unflattenedTxnWithSourceID2: UnflattenedTransaction = { +export const unflattenedTxnWithSourceID2: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, source_account_id: 'acc6mK6CEesXL', }, -}; +}); -export const unflattendedTxnWithPolicyAmount: UnflattenedTransaction = { +export const unflattendedTxnWithPolicyAmount: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, policy_amount: 100, }, -}; +}); -export const unflattenedTxnWithTrackData: UnflattenedTransaction = { +export const unflattenedTxnWithTrackData: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -2988,17 +2990,17 @@ export const unflattenedTxnWithTrackData: UnflattenedTransaction = { }, ], }, -}; +}); -export const unflattenedTxnDataWithReportID2UserReview: UnflattenedTransaction = { +export const unflattenedTxnDataWithReportID2UserReview: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnDataWithReportID2, tx: { ...unflattenedTxnDataWithReportID2.tx, user_review_needed: true, }, -}; +}); -export const expenseTrackCreate: UnflattenedTransaction = { +export const expenseTrackCreate: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, @@ -3011,9 +3013,9 @@ export const expenseTrackCreate: UnflattenedTransaction = { }, ], }, -}; +}); -export const unflattenedTxnWithReportID3: UnflattenedTransaction = { +export const unflattenedTxnWithReportID3: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -3161,9 +3163,9 @@ export const unflattenedTxnWithReportID3: UnflattenedTransaction = { is: { test_call: null, }, -}; +}); -export const newMileageExpFromForm: Partial = { +export const newMileageExpFromForm: Partial = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -3374,9 +3376,9 @@ export const newMileageExpFromForm: Partial = { sub_department: null, joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, -}; +}); -export const newMileageExpFromForm2: Partial = { +export const newMileageExpFromForm2: Partial = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -3494,9 +3496,9 @@ export const newMileageExpFromForm2: Partial = { sub_department: null, joining_dt: new Date('2017-07-25T00:00:00.000Z'), }, -}; +}); -export const unflattenedTxnWithCategory: UnflattenedTransaction = { +export const unflattenedTxnWithCategory: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -3644,17 +3646,17 @@ export const unflattenedTxnWithCategory: UnflattenedTransaction = { is: { test_call: null, }, -}; +}); -export const unflattenedTxnWithCC: UnflattenedTransaction = { +export const unflattenedTxnWithCC: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, cost_center_id: 2411, }, -}; +}); -export const newMileageExpFromForm3: UnflattenedTransaction = { +export const newMileageExpFromForm3: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnWithReportID3, tx: { ...unflattenedTxnWithReportID3.tx, @@ -3689,12 +3691,12 @@ export const newMileageExpFromForm3: UnflattenedTransaction = { }, ], }, -}; +}); -export const unflattenedMileageDataWithPolicyAmount: UnflattenedTransaction = { +export const unflattenedMileageDataWithPolicyAmount: UnflattenedTransaction = deepFreeze({ ...unflattenedTxnData, tx: { ...unflattenedTxnData.tx, policy_amount: 100, }, -}; +}); diff --git a/src/app/core/mock-data/unformatted-transaction.data.ts b/src/app/core/mock-data/unformatted-transaction.data.ts index acc34453b3..6007315d68 100644 --- a/src/app/core/mock-data/unformatted-transaction.data.ts +++ b/src/app/core/mock-data/unformatted-transaction.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { UnformattedTransaction } from '../models/unformatted-transaction.model'; -export const unformattedTxnData: Partial[] = [ +export const unformattedTxnData: Partial[] = deepFreeze([ { created_at: new Date('2023-02-08T06:47:48.414Z'), updated_at: new Date('2023-02-08T06:47:48.414Z'), @@ -72,4 +74,4 @@ export const unformattedTxnData: Partial[] = [ policy_amount: null, locations: [], }, -]; +]); diff --git a/src/app/core/mock-data/unique-cards-stats.data.ts b/src/app/core/mock-data/unique-cards-stats.data.ts index a6b89d9266..908100c6bb 100644 --- a/src/app/core/mock-data/unique-cards-stats.data.ts +++ b/src/app/core/mock-data/unique-cards-stats.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { UniqueCardStats } from '../models/unique-cards-stats.model'; -export const expectedUniqueCardStats: UniqueCardStats[] = [ +export const expectedUniqueCardStats: UniqueCardStats[] = deepFreeze([ { cardNumber: '8698', cardName: 'DAMNA', @@ -21,4 +23,4 @@ export const expectedUniqueCardStats: UniqueCardStats[] = [ totalTxnsCount: 5, totalAmountValue: 371.87, }, -]; +]); diff --git a/src/app/core/mock-data/unique-cards.data.ts b/src/app/core/mock-data/unique-cards.data.ts index 6752ce732b..2f142290d0 100644 --- a/src/app/core/mock-data/unique-cards.data.ts +++ b/src/app/core/mock-data/unique-cards.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { UniqueCards } from '../models/unique-cards.model'; -export const uniqueCardsParam: UniqueCards[] = [ +export const uniqueCardsParam: UniqueCards[] = deepFreeze([ { cardNumber: '8698', cardName: 'DAMNA', @@ -13,4 +15,4 @@ export const uniqueCardsParam: UniqueCards[] = [ cardNumber: '869', cardName: 'PEX BANK', }, -]; +]); diff --git a/src/app/core/mock-data/user-password-status.data.ts b/src/app/core/mock-data/user-password-status.data.ts index e369cc916e..5fa27fcb22 100644 --- a/src/app/core/mock-data/user-password-status.data.ts +++ b/src/app/core/mock-data/user-password-status.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { UserPasswordStatus } from '../models/user-password-status.model'; -export const userPasswordStatus: UserPasswordStatus = { +export const userPasswordStatus: UserPasswordStatus = deepFreeze({ is_password_required: true, is_password_set: true, -}; +}); diff --git a/src/app/core/mock-data/value-error-mapping-for-update-mobile-number-popover.data.ts b/src/app/core/mock-data/value-error-mapping-for-update-mobile-number-popover.data.ts index f084afaa8d..5e1e2e5ebb 100644 --- a/src/app/core/mock-data/value-error-mapping-for-update-mobile-number-popover.data.ts +++ b/src/app/core/mock-data/value-error-mapping-for-update-mobile-number-popover.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + interface ValueErrorMapping { value: string | null; error: string | null; } -export const valueErrorMapping: ValueErrorMapping[] = [ +export const valueErrorMapping: ValueErrorMapping[] = deepFreeze([ { value: null, error: 'Please enter a Mobile Number', @@ -24,4 +26,4 @@ export const valueErrorMapping: ValueErrorMapping[] = [ value: '+918080913866', error: null, }, -]; +]); diff --git a/src/app/core/mock-data/virtual-card-combined-response.data.ts b/src/app/core/mock-data/virtual-card-combined-response.data.ts index 399601946d..70f8fe44aa 100644 --- a/src/app/core/mock-data/virtual-card-combined-response.data.ts +++ b/src/app/core/mock-data/virtual-card-combined-response.data.ts @@ -1,4 +1,6 @@ -export const virtualCardCombinedResponse = { +import deepFreeze from 'deep-freeze-strict'; + +export const virtualCardCombinedResponse = deepFreeze({ vc1234: { full_card_number: '123451234512345', cvv: '1234', @@ -6,4 +8,4 @@ export const virtualCardCombinedResponse = { nick_name: 'Nickname', current_amount: 1000, }, -}; +}); diff --git a/src/app/core/mock-data/virtual-card-details-response.data.ts b/src/app/core/mock-data/virtual-card-details-response.data.ts index 3fb3d94845..ffc8199fa3 100644 --- a/src/app/core/mock-data/virtual-card-details-response.data.ts +++ b/src/app/core/mock-data/virtual-card-details-response.data.ts @@ -1,17 +1,18 @@ +import deepFreeze from 'deep-freeze-strict'; + import { CardDetailsAmountResponse } from '../models/card-details-amount-response'; import { CardDetailsResponse } from '../models/card-details-response.model'; -export const virtualCardDetailsResponse: { data: CardDetailsResponse } = { +export const virtualCardDetailsResponse: { data: CardDetailsResponse } = deepFreeze({ data: { full_card_number: '123412341234123', cvv: '123', - // @ts-ignore expiry_date: '2029-01-01T00:00:00+00:00', }, -}; +}); -export const virtualCardCurrentAmountResponse: { data: CardDetailsAmountResponse } = { +export const virtualCardCurrentAmountResponse: { data: CardDetailsAmountResponse } = deepFreeze({ data: { current_amount: 1000, }, -}; +}); diff --git a/src/app/core/mock-data/virtual-card-response.data.ts b/src/app/core/mock-data/virtual-card-response.data.ts index e86f1a2cbb..826b6775da 100644 --- a/src/app/core/mock-data/virtual-card-response.data.ts +++ b/src/app/core/mock-data/virtual-card-response.data.ts @@ -1,8 +1,10 @@ +import deepFreeze from 'deep-freeze-strict'; + import { CardStatus } from '../enums/card-status.enum'; import { PlatformApiResponse } from '../models/platform/platform-api-response.model'; import { VirtualCard } from '../models/virtual-card.model'; -export const virtualCardResponse: PlatformApiResponse = { +export const virtualCardResponse: PlatformApiResponse = deepFreeze({ count: 1, data: [ { @@ -22,10 +24,10 @@ export const virtualCardResponse: PlatformApiResponse = { }, ], offset: 0, -}; +}); -export const virtualCardUndefinedResponse: PlatformApiResponse = { +export const virtualCardUndefinedResponse: PlatformApiResponse = deepFreeze({ count: 0, data: undefined, offset: 0, -}; +}); diff --git a/src/app/core/mock-data/virtual-cards-combined-request.data.ts b/src/app/core/mock-data/virtual-cards-combined-request.data.ts index a46cd99eea..a14c69f73d 100644 --- a/src/app/core/mock-data/virtual-cards-combined-request.data.ts +++ b/src/app/core/mock-data/virtual-cards-combined-request.data.ts @@ -1,4 +1,6 @@ -export const virtualCardCombinedRequest = { +import deepFreeze from 'deep-freeze-strict'; + +export const virtualCardCombinedRequest = deepFreeze({ virtualCardIds: ['vcgNQmrZvGhL'], includeCurrentAmount: true, -}; +}); diff --git a/src/app/core/mock-data/virtual-select-option.data.ts b/src/app/core/mock-data/virtual-select-option.data.ts index 3f170655f8..9f1a522976 100644 --- a/src/app/core/mock-data/virtual-select-option.data.ts +++ b/src/app/core/mock-data/virtual-select-option.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { VirtualSelectOption } from 'src/app/shared/components/virtual-select/virtual-select-modal/virtual-select-option.interface'; -export const virtualSelectOptionData: VirtualSelectOption = { +export const virtualSelectOptionData: VirtualSelectOption = deepFreeze({ label: 'Airlines', value: { code: null, @@ -15,9 +17,9 @@ export const virtualSelectOptionData: VirtualSelectOption = { updated_at: '2023-07-20T09:58:39.922648+00:00', }, selected: false, -}; +}); -export const virtualSelectOptionData2: VirtualSelectOption = { +export const virtualSelectOptionData2: VirtualSelectOption = deepFreeze({ label: 'Mail', value: { code: null, @@ -32,9 +34,9 @@ export const virtualSelectOptionData2: VirtualSelectOption = { updated_at: '2023-07-20T09:58:39.922648+00:00', }, selected: false, -}; +}); -export const virtualSelectOptionData3: VirtualSelectOption = { +export const virtualSelectOptionData3: VirtualSelectOption = deepFreeze({ label: 'Train', value: { code: null, @@ -49,30 +51,33 @@ export const virtualSelectOptionData3: VirtualSelectOption = { updated_at: '2023-07-20T09:58:39.922648+00:00', }, selected: false, -}; +}); -export const virtualSelectOptionData4: VirtualSelectOption[] = [virtualSelectOptionData, virtualSelectOptionData2]; +export const virtualSelectOptionData4: VirtualSelectOption[] = deepFreeze([ + virtualSelectOptionData, + virtualSelectOptionData2, +]); -export const virtualSelectOptionData5: VirtualSelectOption[] = [ +export const virtualSelectOptionData5: VirtualSelectOption[] = deepFreeze([ { ...virtualSelectOptionData2 }, virtualSelectOptionData3, -]; +]); -export const expectedVirtualSelectOptionData: VirtualSelectOption[] = [ +export const expectedVirtualSelectOptionData: VirtualSelectOption[] = deepFreeze([ { label: 'None', value: null }, virtualSelectOptionData2, -]; +]); -export const expectedSelectableOptionsData: VirtualSelectOption[] = [ +export const expectedSelectableOptionsData: VirtualSelectOption[] = deepFreeze([ { ...virtualSelectOptionData2, isRecentlyUsed: true }, { ...virtualSelectOptionData3, isRecentlyUsed: true }, virtualSelectOptionData, virtualSelectOptionData2, -]; +]); -export const expectedFilteredOptionsData: VirtualSelectOption[] = [ +export const expectedFilteredOptionsData: VirtualSelectOption[] = deepFreeze([ { label: 'None', value: null }, virtualSelectOptionData, virtualSelectOptionData2, { label: 'Train', value: virtualSelectOptionData3, selected: true }, -]; +]); diff --git a/src/app/core/mock-data/yoodle-token.data.ts b/src/app/core/mock-data/yoodle-token.data.ts index ed7a39489c..a9511d07c1 100644 --- a/src/app/core/mock-data/yoodle-token.data.ts +++ b/src/app/core/mock-data/yoodle-token.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { YodleeAccessToken } from '../models/yoodle-token.model'; -export const apiToken: YodleeAccessToken = { +export const apiToken: YodleeAccessToken = deepFreeze({ access_token: 'bMWGrqpBH4ZEamNIh1VKSOvJBzvG', fast_link_url: 'https://fl4.preprod.yodlee.com/authenticate/development-448/fastlink/?channelAppName=tieredpreprod', -}; +}); diff --git a/src/app/core/models/card-details-combined-response.model.ts b/src/app/core/models/card-details-combined-response.model.ts index a17609c26d..6ea57d5d49 100644 --- a/src/app/core/models/card-details-combined-response.model.ts +++ b/src/app/core/models/card-details-combined-response.model.ts @@ -1,7 +1,7 @@ export interface CardDetailsCombinedResponse { full_card_number: string; cvv: string; - expiry_date: Date; + expiry_date: Date | string; nick_name?: string; current_amount?: number; } diff --git a/src/app/core/models/card-details-response.model.ts b/src/app/core/models/card-details-response.model.ts index 8975bd1321..67f0c7f150 100644 --- a/src/app/core/models/card-details-response.model.ts +++ b/src/app/core/models/card-details-response.model.ts @@ -1,5 +1,5 @@ export interface CardDetailsResponse { full_card_number: string; cvv: string; - expiry_date: Date; + expiry_date: Date | string; } diff --git a/src/app/core/services/advance-request.service.spec.ts b/src/app/core/services/advance-request.service.spec.ts index 502907c65c..1a81496382 100644 --- a/src/app/core/services/advance-request.service.spec.ts +++ b/src/app/core/services/advance-request.service.spec.ts @@ -461,16 +461,16 @@ describe('AdvanceRequestService', () => { describe('fixDates():', () => { it('should convert string values to dates', () => { + const mockAdvanceReqData = cloneDeep(extendedAdvReqWithoutDates); //@ts-ignore - expect(advanceRequestService.fixDates(extendedAdvReqWithoutDates)).toEqual(extendedAdvReqWithDates); + expect(advanceRequestService.fixDates(mockAdvanceReqData)).toEqual(extendedAdvReqWithDates); }); }); it('fixDatesForPlatformFields(): should convert string values to dates', () => { + const mockAdvanceReqData = cloneDeep(advanceRequestPlatform.data[0]); //@ts-ignore - expect(advanceRequestService.fixDatesForPlatformFields(advanceRequestPlatform.data[0])).toEqual( - advanceRequestPlatform.data[0] - ); + expect(advanceRequestService.fixDatesForPlatformFields(mockAdvanceReqData)).toEqual(advanceRequestPlatform.data[0]); }); it('getEReq(): should get advance request', (done) => { @@ -532,10 +532,11 @@ describe('AdvanceRequestService', () => { fileService.post.and.returnValue(of(fileObjectData3)); spyOn(advanceRequestService, 'submit').and.returnValue(of(advanceRequests)); - advanceRequestService.createAdvReqWithFilesAndSubmit(advanceRequests, of(fileData1)).subscribe((res) => { + const mockFileObject = cloneDeep(fileData1); + advanceRequestService.createAdvReqWithFilesAndSubmit(advanceRequests, of(mockFileObject)).subscribe((res) => { expect(res).toEqual(advRequestFile); expect(advanceRequestService.submit).toHaveBeenCalledOnceWith(advanceRequests); - expect(fileService.post).toHaveBeenCalledOnceWith(fileData1[0]); + expect(fileService.post).toHaveBeenCalledOnceWith(mockFileObject[0]); done(); }); }); @@ -556,10 +557,11 @@ describe('AdvanceRequestService', () => { fileService.post.and.returnValue(of(fileObjectData4)); spyOn(advanceRequestService, 'saveDraft').and.returnValue(of(advancedRequests2)); - advanceRequestService.saveDraftAdvReqWithFiles(advancedRequests2, of(fileData2)).subscribe((res) => { + const mockFileObject = cloneDeep(fileData2); + advanceRequestService.saveDraftAdvReqWithFiles(advancedRequests2, of(mockFileObject)).subscribe((res) => { expect(res).toEqual(advRequestFile2); expect(advanceRequestService.saveDraft).toHaveBeenCalledOnceWith(advancedRequests2); - expect(fileService.post).toHaveBeenCalledOnceWith(fileData2[0]); + expect(fileService.post).toHaveBeenCalledOnceWith(mockFileObject[0]); done(); }); }); @@ -592,11 +594,15 @@ describe('AdvanceRequestService', () => { describe('modifyAdvanceRequestCustomFields():', () => { it('should modify advance request custom fields', () => { - expect(advanceRequestService.modifyAdvanceRequestCustomFields(customFields)).toEqual(expectedCustomFieldsWoDate); + const mockCustomFields = cloneDeep(customFields); + expect(advanceRequestService.modifyAdvanceRequestCustomFields(mockCustomFields)).toEqual( + expectedCustomFieldsWoDate + ); }); it('should modify custom fields with date value', () => { - expect(advanceRequestService.modifyAdvanceRequestCustomFields(customField2)).toEqual( + const mockCustomFields = cloneDeep(customField2); + expect(advanceRequestService.modifyAdvanceRequestCustomFields(mockCustomFields)).toEqual( expectedCustomFieldsWithDate ); }); @@ -728,6 +734,7 @@ describe('AdvanceRequestService', () => { done(); }); }); + it('should get all advance request with default params', (done) => { spenderService.get.and.returnValue(of(advanceRequestPlatform)); @@ -747,8 +754,9 @@ describe('AdvanceRequestService', () => { describe('getMyadvanceRequests():', () => { it('should get all advance request', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - apiv2Service.get.and.returnValue(of(allAdvanceRequestsRes)); + authService.getEou.and.resolveTo(apiEouRes); + const mockApiV2Res = cloneDeep(allAdvanceRequestsRes); + apiv2Service.get.and.returnValue(of(mockApiV2Res)); const param = { offset: 0, @@ -760,7 +768,7 @@ describe('AdvanceRequestService', () => { }; advanceRequestService.getMyadvanceRequests(param).subscribe((res) => { - expect(res).toEqual(allAdvanceRequestsRes); + expect(res).toEqual(mockApiV2Res); expect(apiv2Service.get).toHaveBeenCalledOnceWith('/advance_requests', { params: { offset: param.offset, @@ -773,12 +781,14 @@ describe('AdvanceRequestService', () => { done(); }); }); + it('should get all advance request with default params', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - apiv2Service.get.and.returnValue(of(allAdvanceRequestsRes)); + authService.getEou.and.resolveTo(apiEouRes); + const mockApiV2Res = cloneDeep(allAdvanceRequestsRes); + apiv2Service.get.and.returnValue(of(mockApiV2Res)); advanceRequestService.getMyadvanceRequests().subscribe((res) => { - expect(res).toEqual(allAdvanceRequestsRes); + expect(res).toEqual(mockApiV2Res); expect(apiv2Service.get).toHaveBeenCalledOnceWith('/advance_requests', { params: { offset: 0, @@ -827,8 +837,9 @@ describe('AdvanceRequestService', () => { describe('getTeamAdvanceRequests():', () => { it('should get all team advance requests | APPROVAL PENDING AND APPROVED', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - apiv2Service.get.and.returnValue(of(allTeamAdvanceRequestsRes)); + authService.getEou.and.resolveTo(apiEouRes); + const mockApiV2Res = cloneDeep(allTeamAdvanceRequestsRes); + apiv2Service.get.and.returnValue(of(mockApiV2Res)); const params = { offset: 0, @@ -849,7 +860,7 @@ describe('AdvanceRequestService', () => { }; advanceRequestService.getTeamAdvanceRequests(params).subscribe((res) => { - expect(res).toEqual(allTeamAdvanceRequestsRes); + expect(res).toEqual(mockApiV2Res); expect(apiv2Service.get).toHaveBeenCalledOnceWith('/advance_requests', { params: { offset: params.offset, @@ -866,8 +877,9 @@ describe('AdvanceRequestService', () => { }); it('should get all team advance requests | APPROVAL PENDING', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - apiv2Service.get.and.returnValue(of(allTeamAdvanceRequestsRes)); + authService.getEou.and.resolveTo(apiEouRes); + const mockApiV2Res = cloneDeep(allTeamAdvanceRequestsRes); + apiv2Service.get.and.returnValue(of(mockApiV2Res)); const params = { offset: 0, @@ -888,7 +900,7 @@ describe('AdvanceRequestService', () => { }; advanceRequestService.getTeamAdvanceRequests(params).subscribe((res) => { - expect(res).toEqual(allTeamAdvanceRequestsRes); + expect(res).toEqual(mockApiV2Res); expect(apiv2Service.get).toHaveBeenCalledOnceWith('/advance_requests', { params: { offset: params.offset, @@ -905,8 +917,9 @@ describe('AdvanceRequestService', () => { }); it('should get all team advance requests | APPROVED', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - apiv2Service.get.and.returnValue(of(allTeamAdvanceRequestsRes)); + authService.getEou.and.resolveTo(apiEouRes); + const mockApiV2Res = cloneDeep(allTeamAdvanceRequestsRes); + apiv2Service.get.and.returnValue(of(mockApiV2Res)); const params = { offset: 0, @@ -927,7 +940,7 @@ describe('AdvanceRequestService', () => { }; advanceRequestService.getTeamAdvanceRequests(params).subscribe((res) => { - expect(res).toEqual(allTeamAdvanceRequestsRes); + expect(res).toEqual(mockApiV2Res); expect(apiv2Service.get).toHaveBeenCalledOnceWith('/advance_requests', { params: { offset: params.offset, diff --git a/src/app/core/services/advance.service.spec.ts b/src/app/core/services/advance.service.spec.ts index 9928262776..0c2fc4fc66 100644 --- a/src/app/core/services/advance.service.spec.ts +++ b/src/app/core/services/advance.service.spec.ts @@ -9,6 +9,7 @@ import { apiEouRes } from '../mock-data/extended-org-user.data'; import { of } from 'rxjs'; import { SpenderService } from './platform/v1/spender/spender.service'; import { advancePlatform } from '../mock-data/advance-platform.data'; +import { cloneDeep } from 'lodash'; describe('AdvanceService', () => { let advanceService: AdvanceService; @@ -59,8 +60,9 @@ describe('AdvanceService', () => { }); it('fixDates(): should convert string values to dates', () => { + const mockExtendedAdvData = cloneDeep(extendedAdvWithoutDates); //@ts-ignore - expect(advanceService.fixDates(extendedAdvWithoutDates)).toEqual(extendedAdvWithDates); + expect(advanceService.fixDates(mockExtendedAdvData)).toEqual(extendedAdvWithDates); }); describe('getSpenderAdvances():', () => { diff --git a/src/app/core/services/categories.service.spec.ts b/src/app/core/services/categories.service.spec.ts index cf2350a90d..29365f7a00 100644 --- a/src/app/core/services/categories.service.spec.ts +++ b/src/app/core/services/categories.service.spec.ts @@ -31,6 +31,7 @@ import { displayOrgCategoriesByName, expectedOrgCategoryByName, } from '../mock-data/org-category.data'; +import { cloneDeep } from 'lodash'; describe('CategoriesService', () => { let categoriesService: CategoriesService; @@ -133,7 +134,8 @@ describe('CategoriesService', () => { }); it('addDisplayName(): should modify display name', () => { - expect(categoriesService.addDisplayName(orgCategoryWoDisplayName)).toEqual(orgCategoryWithDisplayName); + const mockCategory = cloneDeep(orgCategoryWoDisplayName); + expect(categoriesService.addDisplayName(mockCategory)).toEqual(orgCategoryWithDisplayName); }); it('filterByOrgCategoryId(): should filter a category by ID', () => { @@ -146,11 +148,13 @@ describe('CategoriesService', () => { describe('sortCategories():', () => { it('should sort categories', () => { - expect(categoriesService.sortCategories(transformedOrgCategories)).toEqual(sortedCategory); + const mockCategories = cloneDeep(transformedOrgCategories); + expect(categoriesService.sortCategories(mockCategories)).toEqual(sortedCategory); }); it('should sort categories when categories and sub-categories are same', () => { - expect(categoriesService.sortCategories(unsortedCategories1)).toEqual(sortedCategories1); + const mockCategories = cloneDeep(unsortedCategories1); + expect(categoriesService.sortCategories(mockCategories)).toEqual(sortedCategories1); }); }); diff --git a/src/app/core/services/custom-fields.service.spec.ts b/src/app/core/services/custom-fields.service.spec.ts index e44f62bbdd..2e9db98db7 100644 --- a/src/app/core/services/custom-fields.service.spec.ts +++ b/src/app/core/services/custom-fields.service.spec.ts @@ -9,6 +9,7 @@ import { import { customInputData, platformApiResponse } from '../test-data/custom-inputs.spec.data'; import { CustomFieldsService } from './custom-fields.service'; +import { cloneDeep } from 'lodash'; describe('CustomFieldsService', () => { let customFieldsService: CustomFieldsService; @@ -41,22 +42,26 @@ describe('CustomFieldsService', () => { describe('setDefaultValue():', () => { it('should set default value to false for boolean type', () => { - const result = customFieldsService.setDefaultValue(txnCustomPropertiesData3[0], 'BOOLEAN'); - expect(result.value).toBe(false); + const mockTxnCustomProperties = cloneDeep(txnCustomPropertiesData3[0]); + const result = customFieldsService.setDefaultValue(mockTxnCustomProperties, 'BOOLEAN'); + expect(result.value).toBeFalse(); }); it('should set default value to empty string for select type', () => { - const result = customFieldsService.setDefaultValue(txnCustomPropertiesData3[1], 'SELECT'); + const mockTxnCustomProperties = cloneDeep(txnCustomPropertiesData3[1]); + const result = customFieldsService.setDefaultValue(mockTxnCustomProperties, 'SELECT'); expect(result.value).toBe(''); }); it('should set default value to empty string for multi select type', () => { - const result = customFieldsService.setDefaultValue(txnCustomPropertiesData[2], 'MULTI_SELECT'); + const mockTxnCustomProperties = cloneDeep(txnCustomPropertiesData3[2]); + const result = customFieldsService.setDefaultValue(mockTxnCustomProperties, 'MULTI_SELECT'); expect(result.value).toBe(''); }); it('should set default value to empty string for user select type', () => { - const result = customFieldsService.setDefaultValue(txnCustomPropertiesData[0], 'USER_LIST'); + const mockTxnCustomProperties = cloneDeep(txnCustomPropertiesData[0]); + const result = customFieldsService.setDefaultValue(mockTxnCustomProperties, 'USER_LIST'); expect(result.value).toEqual([]); }); }); diff --git a/src/app/core/services/date.service.spec.ts b/src/app/core/services/date.service.spec.ts index b01cce04d3..cf2961e769 100644 --- a/src/app/core/services/date.service.spec.ts +++ b/src/app/core/services/date.service.spec.ts @@ -24,11 +24,11 @@ describe('DateService', () => { }); it('firstOfThisMonth(): get the first day of the month', () => { - expect(dateService.firstOfThisMonth()).toEqual(new Date(year, month, 1)); + expect(dateService.firstOfThisMonth().toDateString()).toEqual(new Date(year, month, 1).toDateString()); }); it('lastOfThisMonth(): get the last day of the month', () => { - expect(dateService.lastOfThisMonth()).toEqual(new Date(year, month + 1, 0, 23, 59)); + expect(dateService.lastOfThisMonth().toDateString()).toEqual(new Date(year, month + 1, 0, 23, 59).toDateString()); }); it('isValidDate(): check if date is valid', () => { @@ -60,11 +60,11 @@ describe('DateService', () => { }); it('firstOfLastMonth(): should get the first of last month', () => { - expect(dateService.firstOfLastMonth()).toEqual(new Date(year, month - 1, 1)); + expect(dateService.firstOfLastMonth().toDateString()).toEqual(new Date(year, month - 1, 1).toDateString()); }); it('lastOfLastMonth(): should get the last of last month', () => { - expect(dateService.lastOfLastMonth()).toEqual(new Date(year, month, 0, 23, 59)); + expect(dateService.lastOfLastMonth().toDateString()).toEqual(new Date(year, month, 0, 23, 59).toDateString()); }); it("getLastMonthRange(): should get last month's range", () => { diff --git a/src/app/core/services/dependent-fields.service.spec.ts b/src/app/core/services/dependent-fields.service.spec.ts index 9befd32cf5..df87cd6712 100644 --- a/src/app/core/services/dependent-fields.service.spec.ts +++ b/src/app/core/services/dependent-fields.service.spec.ts @@ -16,6 +16,7 @@ import { import { DependentFieldsService } from './dependent-fields.service'; import { SpenderPlatformV1ApiService } from './spender-platform-v1-api.service'; import { CustomInputsService } from './custom-inputs.service'; +import { cloneDeep } from 'lodash'; describe('DependentFieldsService', () => { let dependentFieldsService: DependentFieldsService; @@ -82,7 +83,8 @@ describe('DependentFieldsService', () => { describe('getDependentFieldsForBaseField(): ', () => { it('should return the dependent expense fields for the parent field', () => { const parentFieldId = 219175; - customInputsService.getAll.and.returnValue(of(customExpenseFields)); + const mockCustomExpenseFields = cloneDeep(customExpenseFields); + customInputsService.getAll.and.returnValue(of(mockCustomExpenseFields)); dependentFieldsService.getDependentFieldsForBaseField(parentFieldId).subscribe((res) => { expect(res).toEqual(dependentExpenseFields); @@ -93,11 +95,13 @@ describe('DependentFieldsService', () => { describe('getDependentFieldValuesForBaseField(): ', () => { it('should return the dependent field values for parent field and txn custom properties', () => { const parentFieldId = 219175; - customInputsService.getAll.and.returnValue(of(customExpenseFields)); + const mockCustomExpenseFields = cloneDeep(customExpenseFields); + customInputsService.getAll.and.returnValue(of(mockCustomExpenseFields)); spyOn(dependentFieldsService, 'getDependentFieldsForBaseField').and.returnValue(of(dependentExpenseFields)); + const mockTxnCustomProperties = cloneDeep(txnCustomProperties); dependentFieldsService - .getDependentFieldValuesForBaseField(txnCustomProperties, parentFieldId) + .getDependentFieldValuesForBaseField(mockTxnCustomProperties, parentFieldId) .subscribe((res) => { expect(res).toEqual(dependentFieldValues); }); diff --git a/src/app/core/services/expense-fields.service.spec.ts b/src/app/core/services/expense-fields.service.spec.ts index bdd8c9cc81..dece8e2e40 100644 --- a/src/app/core/services/expense-fields.service.spec.ts +++ b/src/app/core/services/expense-fields.service.spec.ts @@ -19,6 +19,7 @@ import { SpenderPlatformV1ApiService } from './spender-platform-v1-api.service'; import { AuthService } from './auth.service'; import { ExpenseFieldsService } from './expense-fields.service'; +import { cloneDeep } from 'lodash'; describe('ExpenseFieldsService', () => { let expenseFieldsService: ExpenseFieldsService; @@ -84,8 +85,9 @@ describe('ExpenseFieldsService', () => { it('filterbyCategory(): should filter expense fields by category', (done) => { const fields = ['purpose', 'txn_dt', 'vendor_id', 'org_category_id']; + const mockExpenseFieldsMapResponse = cloneDeep(expenseFieldsMapResponse); expenseFieldsService - .filterByOrgCategoryId(expenseFieldsMapResponse, fields, orgCategoryData) + .filterByOrgCategoryId(mockExpenseFieldsMapResponse, fields, orgCategoryData) .subscribe((expenseFields) => { expect(expenseFields).toEqual(expenseFieldObjData); done(); diff --git a/src/app/core/services/file.service.spec.ts b/src/app/core/services/file.service.spec.ts index 551911ecf4..7e6eadb746 100644 --- a/src/app/core/services/file.service.spec.ts +++ b/src/app/core/services/file.service.spec.ts @@ -5,6 +5,7 @@ import { ApiService } from './api.service'; import { DateService } from './date.service'; import { FileService } from './file.service'; +import { cloneDeep } from 'lodash'; describe('FileService', () => { let fileService: FileService; @@ -118,7 +119,7 @@ describe('FileService', () => { describe('setFileType():', () => { it('should set the file type', () => { spyOn(fileService, 'getFileExtension').and.returnValue('jpeg'); - const file = fileObjectAdv[0]; + const file = cloneDeep(fileObjectAdv[0]); const fileWithFileType = fileService.setFileType(file); expect(fileWithFileType.file_type).toEqual('image'); expect(fileService.getFileExtension).toHaveBeenCalledOnceWith(file.name); @@ -126,7 +127,7 @@ describe('FileService', () => { it('should set the file pdf type', () => { spyOn(fileService, 'getFileExtension').and.returnValue('pdf'); - const file = fileObjectAdv1; + const file = cloneDeep(fileObjectAdv1); const fileWithFileType = fileService.setFileType(file); expect(fileWithFileType.file_type).toEqual('pdf'); expect(fileService.getFileExtension).toHaveBeenCalledOnceWith(file.name); diff --git a/src/app/core/services/location.service.spec.ts b/src/app/core/services/location.service.spec.ts index fee47c6bcd..74bdd84cf3 100644 --- a/src/app/core/services/location.service.spec.ts +++ b/src/app/core/services/location.service.spec.ts @@ -4,6 +4,7 @@ import { of, delay } from 'rxjs'; import { LocationService } from './location.service'; import { locationData1, locationData2, locationData4, predictedLocation1 } from '../mock-data/location.data'; import { HttpParams } from '@angular/common/http'; +import { cloneDeep } from 'lodash'; describe('LocationService', () => { let locationService: LocationService; @@ -101,7 +102,7 @@ describe('LocationService', () => { it('should return location details with display name if displayName is provided', () => { const placeId = 'pLcId123'; const displayName = 'Tollygunge, Kolkata, West Bengal, India'; - const locationDetails = locationData1; + const locationDetails = cloneDeep(locationData1); locationService.getGeocode(placeId, displayName).subscribe((result) => { expect(result).toEqual(locationDetails); }); @@ -114,7 +115,7 @@ describe('LocationService', () => { it('should not add the displayName to locationDetails when displayName is not provided', () => { const placeId = '12345'; const displayName = ''; - const locationDetails = locationData4; + const locationDetails = cloneDeep(locationData4); locationService.getGeocode(placeId, displayName).subscribe((result) => { expect(result).toEqual(locationDetails); }); diff --git a/src/app/core/services/merge-expenses.service.spec.ts b/src/app/core/services/merge-expenses.service.spec.ts index b71ad8c355..38f2b9a759 100644 --- a/src/app/core/services/merge-expenses.service.spec.ts +++ b/src/app/core/services/merge-expenses.service.spec.ts @@ -96,6 +96,7 @@ import { customInputData } from '../test-data/custom-inputs.spec.data'; import * as dayjs from 'dayjs'; import { expectedOrgCategoryByName2, orgCategoryData1 } from '../mock-data/org-category.data'; import { taxGroupData } from '../mock-data/tax-group.data'; +import { cloneDeep } from 'lodash'; describe('MergeExpensesService', () => { let mergeExpensesService: MergeExpensesService; @@ -371,19 +372,20 @@ describe('MergeExpensesService', () => { }); it('getAttachements(): should return the attachments', (done) => { - fileService.findByTransactionId.and.returnValue(of(fileObject5)); + const mockFileObject = cloneDeep(fileObject5); + fileService.findByTransactionId.and.returnValue(of(mockFileObject)); fileService.downloadUrl.and.returnValue(of('mock-url')); fileService.getReceiptsDetails.and.returnValue({ - thumbnail: fileObject5[0].thumbnail, - type: fileObject5[0].type, + thumbnail: mockFileObject[0].thumbnail, + type: mockFileObject[0].type, }); const transactionId = 'txz2vohKxBXu'; mergeExpensesService.getAttachements(transactionId).subscribe((res) => { - expect(res).toEqual(fileObject5); + expect(res).toEqual(mockFileObject); expect(fileService.findByTransactionId).toHaveBeenCalledOnceWith(transactionId); - expect(fileService.downloadUrl).toHaveBeenCalledOnceWith(fileObject5[0].id); - expect(fileService.getReceiptsDetails).toHaveBeenCalledOnceWith(fileObject5[0].name, 'mock-url'); + expect(fileService.downloadUrl).toHaveBeenCalledOnceWith(mockFileObject[0].id); + expect(fileService.getReceiptsDetails).toHaveBeenCalledOnceWith(mockFileObject[0].name, 'mock-url'); done(); }); }); @@ -405,17 +407,19 @@ describe('MergeExpensesService', () => { describe('formatProjectOptions():', () => { it('should return the project options', (done) => { projectService.getAllActive.and.returnValue(of(projectsV1Data)); + const mockProjectOptions = cloneDeep(projectOptionsData); // @ts-ignore - mergeExpensesService.formatProjectOptions(projectOptionsData).subscribe((res) => { - expect(res).toEqual(projectOptionsData); + mergeExpensesService.formatProjectOptions(mockProjectOptions).subscribe((res) => { + expect(res).toEqual(mockProjectOptions); done(); }); }); it('should return the project options with label as project name if id matches with option', (done) => { projectService.getAllActive.and.returnValue(of(projectsV1Data)); + const mockProjectOptions = cloneDeep(projectOptionsData); // @ts-ignore - mergeExpensesService.formatProjectOptions({ ...projectOptionsData, value: 257528 }).subscribe((res) => { + mergeExpensesService.formatProjectOptions({ ...mockProjectOptions, value: 257528 }).subscribe((res) => { expect(res).toEqual({ label: 'Customer Mapped Project', value: 257528 }); done(); }); @@ -838,7 +842,7 @@ describe('MergeExpensesService', () => { categoriesService.getAll.and.returnValue(of(orgCategoryData1)); const categoryId = '201951'; mergeExpensesService.getCategoryName(categoryId).subscribe((res) => { - expect(res).toEqual(undefined); + expect(res).toBeUndefined(); expect(categoriesService.getAll).toHaveBeenCalledTimes(1); }); }); @@ -847,7 +851,7 @@ describe('MergeExpensesService', () => { categoriesService.getAll.and.returnValue(of([expectedOrgCategoryByName2])); const categoryId = '201951'; mergeExpensesService.getCategoryName(categoryId).subscribe((res) => { - expect(res).toEqual(undefined); + expect(res).toBeUndefined(); expect(categoriesService.getAll).toHaveBeenCalledTimes(1); }); }); @@ -901,8 +905,9 @@ describe('MergeExpensesService', () => { describe('formatTaxGroupOption():', () => { it('formatTaxGroupOption(): should return the formatted tax group option', (done) => { taxGroupService.get.and.returnValue(of(taxGroupData)); + const mockOptions = cloneDeep(optionsData11.options[0]); // @ts-ignore - mergeExpensesService.formatTaxGroupOption(optionsData11.options[0]).subscribe((res) => { + mergeExpensesService.formatTaxGroupOption(mockOptions).subscribe((res) => { expect(res).toEqual(mergeExpensesOptionData5[0]); expect(taxGroupService.get).toHaveBeenCalledTimes(1); done(); @@ -928,71 +933,78 @@ describe('MergeExpensesService', () => { it('should return the formatted custom input options by type with valid date', () => { dateService.isValidDate.and.returnValues(false, true); spyOn(mergeExpensesService, 'setFormattedDate').and.returnValue('Mar 10, 2021'); + const mockOptions = cloneDeep(optionsData22); // @ts-ignore - const res = mergeExpensesService.formatCustomInputOptionsByType(optionsData22); + const res = mergeExpensesService.formatCustomInputOptionsByType(mockOptions); expect(res).toEqual(optionsData23); - expect(dateService.isValidDate).toHaveBeenCalledWith(optionsData22[1].value); + expect(dateService.isValidDate).toHaveBeenCalledWith(mockOptions[1].value as Date); }); it('should return the formatted custom input options by type without date', () => { dateService.isValidDate.and.returnValues(false, false); + const mockOptions = cloneDeep(optionsData24); // @ts-ignore - const res = mergeExpensesService.formatCustomInputOptionsByType(optionsData24); + const res = mergeExpensesService.formatCustomInputOptionsByType(mockOptions); expect(res).toEqual(optionsData25); }); it('should return the formatted custom input options by type with repeated string options', () => { dateService.isValidDate.and.returnValues(false, false); + const mockOptions = cloneDeep(optionsData27); // @ts-ignore - const res = mergeExpensesService.formatCustomInputOptionsByType(optionsData27); + const res = mergeExpensesService.formatCustomInputOptionsByType(mockOptions); expect(res).toEqual(optionsData28); }); it('should return the formatted custom input options by type with repeated number options', () => { dateService.isValidDate.and.returnValues(false, false); + const mockOptions = cloneDeep(optionsData29); // @ts-ignore - const res = mergeExpensesService.formatCustomInputOptionsByType(optionsData29); + const res = mergeExpensesService.formatCustomInputOptionsByType(mockOptions); expect(res).toEqual(optionsData30); }); it('should return the formatted custom input options by type with repeated select options', () => { dateService.isValidDate.and.returnValues(false, false); + const mockOptions = cloneDeep(optionsData22); // @ts-ignore - const res = mergeExpensesService.formatCustomInputOptionsByType([optionsData22[0], optionsData22[0]]); - expect(res).toEqual([optionsData22[0]]); + const res = mergeExpensesService.formatCustomInputOptionsByType([mockOptions[0], mockOptions[0]]); + expect(res).toEqual([mockOptions[0]]); }); }); describe('formatCustomInputOptions():', () => { it('should return the formatted custom input options', () => { + const mockOptions = cloneDeep(optionsData22); // @ts-ignore - spyOn(mergeExpensesService, 'formatCustomInputOptionsByType').and.returnValue([optionsData22[0]]); + spyOn(mergeExpensesService, 'formatCustomInputOptionsByType').and.returnValue([mockOptions[0]]); // @ts-ignore - const res = mergeExpensesService.formatCustomInputOptions(optionsData22); + const res = mergeExpensesService.formatCustomInputOptions(mockOptions); const expectedRes = { // eslint-disable-next-line quote-props - userlist: optionsData22[0], + userlist: mockOptions[0], }; expect(res).toEqual(expectedRes); // @ts-ignore - expect(mergeExpensesService.formatCustomInputOptionsByType).toHaveBeenCalledWith(optionsData22); + expect(mergeExpensesService.formatCustomInputOptionsByType).toHaveBeenCalledWith(mockOptions); }); it('should return the formatted custom input options without options', () => { + const mockOptions = cloneDeep(optionsData26); // @ts-ignore - spyOn(mergeExpensesService, 'formatCustomInputOptionsByType').and.returnValue([optionsData26[0]]); + spyOn(mergeExpensesService, 'formatCustomInputOptionsByType').and.returnValue([mockOptions[0]]); // @ts-ignore - const res = mergeExpensesService.formatCustomInputOptions(optionsData26); + const res = mergeExpensesService.formatCustomInputOptions(mockOptions); const expectedRes = { // eslint-disable-next-line quote-props numberfield: { options: [], - ...optionsData26[0], + ...mockOptions[0], }, }; expect(res).toEqual(expectedRes); // @ts-ignore - expect(mergeExpensesService.formatCustomInputOptionsByType).toHaveBeenCalledWith(optionsData26); + expect(mergeExpensesService.formatCustomInputOptionsByType).toHaveBeenCalledWith(mockOptions); }); }); @@ -1008,9 +1020,10 @@ describe('MergeExpensesService', () => { }); it('should return the formatted category option', (done) => { + const mockOptions = cloneDeep(mergeExpensesOptionData4[0]); // @ts-ignore - mergeExpensesService.formatCategoryOption(mergeExpensesOptionData4[0]).subscribe((res) => { - expect(res).toEqual(mergeExpensesOptionData4[0]); + mergeExpensesService.formatCategoryOption(mockOptions).subscribe((res) => { + expect(res).toEqual(mockOptions); expect(categoriesService.getAll).toHaveBeenCalledTimes(1); expect(categoriesService.filterRequired).toHaveBeenCalledOnceWith(orgCategoryData1); done(); @@ -1018,8 +1031,9 @@ describe('MergeExpensesService', () => { }); it('should return the formatted category option with label as Unspecified if id does not matches with options', (done) => { + const mockOptions = cloneDeep({ ...mergeExpensesOptionData4[0], value: 201951 }); // @ts-ignore - mergeExpensesService.formatCategoryOption({ ...mergeExpensesOptionData4[0], value: 201951 }).subscribe((res) => { + mergeExpensesService.formatCategoryOption(mockOptions).subscribe((res) => { expect(res).toEqual({ label: 'Unspecified', value: 201951, diff --git a/src/app/core/services/org-settings.service.spec.ts b/src/app/core/services/org-settings.service.spec.ts index ee72ec870c..efc7e942f5 100644 --- a/src/app/core/services/org-settings.service.spec.ts +++ b/src/app/core/services/org-settings.service.spec.ts @@ -26,6 +26,7 @@ import { } from '../test-data/org-settings.service.spec.data'; import { OrgSettingsService } from './org-settings.service'; +import { cloneDeep } from 'lodash'; const getApiData: OrgSettings = orgSettingsGetData; const postApiData: OrgSettingsResponse = orgSettingsPostData; @@ -68,7 +69,8 @@ describe('OrgSettingsService', () => { }); it('should be able to get the org settings properly', (done) => { - apiService.get.and.returnValue(of(postApiData)); + const mockApiResponse = cloneDeep(postApiData); + apiService.get.and.returnValue(of(mockApiResponse)); orgSettingsService.get().subscribe((res) => { expect(res).toEqual(getApiData); done(); @@ -84,9 +86,8 @@ describe('OrgSettingsService', () => { }); it('should be able to get incoming tally account object', () => { - expect(orgSettingsService.getIncomingAccountingObject(outgoingTallyAccountObject)).toEqual( - incomingTallyAccountObject - ); + const mockAccountingObject = cloneDeep(outgoingTallyAccountObject); + expect(orgSettingsService.getIncomingAccountingObject(mockAccountingObject)).toEqual(incomingTallyAccountObject); }); it('should be able to set outgoing tally account object', () => { @@ -96,7 +97,8 @@ describe('OrgSettingsService', () => { }); it('should be able to get incoming quick books account object', () => { - expect(orgSettingsService.getIncomingAccountingObject(outgoingQuickbooksAccountObject)).toEqual( + const mockAccountingObject = cloneDeep(outgoingQuickbooksAccountObject); + expect(orgSettingsService.getIncomingAccountingObject(mockAccountingObject)).toEqual( incomingQuickBooksAccountObject ); }); diff --git a/src/app/core/services/org.service.spec.ts b/src/app/core/services/org.service.spec.ts index 75ba3cb592..f457707502 100644 --- a/src/app/core/services/org.service.spec.ts +++ b/src/app/core/services/org.service.spec.ts @@ -8,6 +8,7 @@ import { ApiService } from './api.service'; import { AuthService } from './auth.service'; import { OrgService } from './org.service'; import { TrackingService } from './tracking.service'; +import { cloneDeep } from 'lodash'; describe('OrgService', () => { let orgService: OrgService; @@ -112,17 +113,19 @@ describe('OrgService', () => { describe('suggestOrgCurrency():', () => { it('should suggest org currency', (done) => { - apiService.get.and.returnValue(of(currencyIpData)); + const mockCurrencyIpData = cloneDeep(currencyIpData); + apiService.get.and.returnValue(of(mockCurrencyIpData)); orgService.suggestOrgCurrency().subscribe((res) => { - expect(res).toEqual(currencyIpData.currency); + expect(res).toEqual(mockCurrencyIpData.currency); expect(apiService.get).toHaveBeenCalledOnceWith('/currency/ip'); done(); }); }); it('should return `USD` if api does not return currency', (done) => { - apiService.get.and.returnValue(of(currencyIpData2)); + const mockCurrencyIpData = cloneDeep(currencyIpData2); + apiService.get.and.returnValue(of(mockCurrencyIpData)); orgService.suggestOrgCurrency().subscribe((res) => { expect(res).toEqual('USD'); @@ -134,14 +137,15 @@ describe('OrgService', () => { it('setCurrencyBasedOnIp(): should set currency based on ip', (done) => { spyOn(orgService, 'suggestOrgCurrency').and.returnValue(of(currencyIpData.currency)); - spyOn(orgService, 'getCurrentOrg').and.returnValue(of(orgData1[0])); - spyOn(orgService, 'updateOrg').and.returnValue(of(orgData1[0])); + const mockOrgData = cloneDeep(orgData1[0]); + spyOn(orgService, 'getCurrentOrg').and.returnValue(of(mockOrgData)); + spyOn(orgService, 'updateOrg').and.returnValue(of(mockOrgData)); orgService.setCurrencyBasedOnIp().subscribe((res) => { - expect(res).toEqual(orgData1[0]); + expect(res).toEqual(mockOrgData); expect(orgService.suggestOrgCurrency).toHaveBeenCalledTimes(1); expect(orgService.getCurrentOrg).toHaveBeenCalledTimes(1); - expect(orgService.updateOrg).toHaveBeenCalledOnceWith(orgData1[0]); + expect(orgService.updateOrg).toHaveBeenCalledOnceWith(mockOrgData); done(); }); }); diff --git a/src/app/core/services/recent-local-storage-items.service.spec.ts b/src/app/core/services/recent-local-storage-items.service.spec.ts index ae6f6d1f98..bff4c7fb2c 100644 --- a/src/app/core/services/recent-local-storage-items.service.spec.ts +++ b/src/app/core/services/recent-local-storage-items.service.spec.ts @@ -9,6 +9,7 @@ import { postRecentItemsRes, } from '../mock-data/recent-local-storage-items.data'; import * as dayjs from 'dayjs'; +import { cloneDeep } from 'lodash'; describe('RecentLocalStorageItemsService', () => { let recentLocalStorageItemsService: RecentLocalStorageItemsService; @@ -71,7 +72,7 @@ describe('RecentLocalStorageItemsService', () => { updatedAt: dayjs().toISOString(), recentItems, }; - storageService.get.and.returnValue(Promise.resolve(cache)); + storageService.get.and.resolveTo(cache); const result = await recentLocalStorageItemsService.get(cacheName); expect(storageService.get).toHaveBeenCalledOnceWith(cacheName); @@ -84,7 +85,7 @@ describe('RecentLocalStorageItemsService', () => { updatedAt: dayjs().diff(5, 'minute').toString(), recentItems: recentLocalStorageItemsRes, }; - storageService.get.and.returnValue(Promise.resolve(outdatedCache)); + storageService.get.and.resolveTo(outdatedCache); const result = await recentLocalStorageItemsService.get(cacheName); expect(storageService.get).toHaveBeenCalledOnceWith(cacheName); expect(result).toEqual([]); @@ -115,40 +116,42 @@ describe('RecentLocalStorageItemsService', () => { describe('post():', () => { it('should maintain and update a cache of recent items in the local storage', async () => { const cacheName = 'mileageSubCategoryName'; - const recentItems = postRecentItemsRes; + const mockPostRecentItemsRes = cloneDeep(postRecentItemsRes); + const recentItems = mockPostRecentItemsRes; const cache = { recentItems, updatedAt: jasmine.any(Date), }; const indexOfItemSpy = spyOn(recentLocalStorageItemsService, 'indexOfItem'); - const getSpy = spyOn(recentLocalStorageItemsService, 'get').and.returnValue(Promise.resolve(postRecentItemsRes)); + const getSpy = spyOn(recentLocalStorageItemsService, 'get').and.resolveTo(mockPostRecentItemsRes); await recentLocalStorageItemsService.post(cacheName, itemsRes, propertyRes); - storageService.set.and.returnValue(Promise.resolve()); + storageService.set.and.resolveTo(); expect(indexOfItemSpy).toHaveBeenCalledOnceWith(recentItems, itemsRes, propertyRes); expect(getSpy).toHaveBeenCalledOnceWith(cacheName); recentLocalStorageItemsService.post(cacheName, itemsRes, propertyRes).then((res) => { - expect(res).toEqual(postRecentItemsRes); + expect(res).toEqual(mockPostRecentItemsRes); }); expect(storageService.set).toHaveBeenCalledOnceWith(cacheName, cache); }); it('should find the index of an item without the property argument', async () => { const cacheName = 'mileageSubCategoryName'; - const recentItems = postRecentItemsRes; + const mockPostRecentItemsRes = cloneDeep(postRecentItemsRes); + const recentItems = mockPostRecentItemsRes; const cache = { recentItems, updatedAt: jasmine.any(Date), }; - const getSpy = spyOn(recentLocalStorageItemsService, 'get').and.returnValue(Promise.resolve(postRecentItemsRes)); + const getSpy = spyOn(recentLocalStorageItemsService, 'get').and.resolveTo(mockPostRecentItemsRes); await recentLocalStorageItemsService.post(cacheName, itemsRes); - storageService.set.and.returnValue(Promise.resolve()); + storageService.set.and.resolveTo(); expect(getSpy).toHaveBeenCalledOnceWith(cacheName); recentLocalStorageItemsService.post(cacheName, itemsRes).then((res) => { - expect(res).toEqual(postRecentItemsRes); + expect(res).toEqual(mockPostRecentItemsRes); }); expect(storageService.set).toHaveBeenCalledOnceWith(cacheName, cache); }); diff --git a/src/app/core/services/report.service.spec.ts b/src/app/core/services/report.service.spec.ts index a6960cd6fc..ba2be279b8 100644 --- a/src/app/core/services/report.service.spec.ts +++ b/src/app/core/services/report.service.spec.ts @@ -73,6 +73,7 @@ import { dataErtpTransformed, apiErptReporDataParam } from '../mock-data/data-tr import { platformReportData } from '../mock-data/platform-report.data'; import { ApproverPlatformApiService } from './approver-platform-api.service'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { cloneDeep } from 'lodash'; describe('ReportService', () => { let reportService: ReportService; @@ -269,7 +270,7 @@ describe('ReportService', () => { describe('getMyReports()', () => { it('should get reports from API as specified by params', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); apiv2Service.get.and.returnValue(of(apiReportRes)); spyOn(dateService, 'fixDates').and.returnValues( apiReportRes.data[0], @@ -303,7 +304,7 @@ describe('ReportService', () => { }); it('should get reports from API when no order is specified', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); apiv2Service.get.and.returnValue(of(apiReportRes)); spyOn(dateService, 'fixDates').and.returnValues( apiReportRes.data[0], @@ -366,7 +367,8 @@ describe('ReportService', () => { it('getERpt(): should get an extended report', (done) => { apiService.get.and.returnValue(of(apiExtendedReportRes[0])); - dataTransformService.unflatten.and.returnValue(unflattenedErptc); + const mockUnflattenedErptc = cloneDeep(unflattenedErptc); + dataTransformService.unflatten.and.returnValue(mockUnflattenedErptc); spyOn(dateService, 'fixDates').and.returnValue(singleERptcFixDatesMock); spyOn(dateService, 'getLocalDate').and.returnValue(new Date('2023-01-21T07:29:01.958Z')); @@ -399,7 +401,7 @@ describe('ReportService', () => { }); it('getReport(): should get the report from API as per report ID given', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); spyOn(reportService, 'getMyReports').and.returnValue(of(apiReportSingleRes)); const reportID = 'rpfClhA1lglE'; @@ -437,7 +439,7 @@ describe('ReportService', () => { describe('getTeamReports()', () => { it('should get all team reports', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); apiv2Service.get.and.returnValue(of(apiTeamReportPaginated1)); spyOn(dateService, 'fixDates').and.returnValues(apiTeamReportPaginated1.data[0], apiTeamReportPaginated1.data[1]); @@ -467,7 +469,7 @@ describe('ReportService', () => { }); it('should get all team reports when order is not specified', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); apiv2Service.get.and.returnValue(of(apiTeamReportPaginated1)); spyOn(dateService, 'fixDates').and.returnValues(apiTeamReportPaginated1.data[0], apiTeamReportPaginated1.data[1]); @@ -613,7 +615,8 @@ describe('ReportService', () => { describe('getReportAutoSubmissionDetails():', () => { it('should get submission details', (done) => { - spenderPlatformV1ApiService.post.and.returnValue(of(apiReportAutoSubmissionDetails)); + const mockApiReportAutoSubmissionDetails = cloneDeep(apiReportAutoSubmissionDetails); + spenderPlatformV1ApiService.post.and.returnValue(of(mockApiReportAutoSubmissionDetails)); reportService.getReportAutoSubmissionDetails().subscribe((res) => { expect(res).toEqual({ @@ -871,7 +874,7 @@ describe('ReportService', () => { it('should get extended reports count', (done) => { networkService.isOnline.and.returnValue(of(true)); apiService.get.and.returnValue(of({ count: 4 })); - storageService.set.and.returnValue(Promise.resolve(null)); + storageService.set.and.resolveTo(null); const apiParam = ['DRAFT', 'APPROVER_PENDING', 'APPROVER_INQUIRY']; @@ -887,7 +890,7 @@ describe('ReportService', () => { it('should return count when device is offline and use storage to give count', (done) => { networkService.isOnline.and.returnValue(of(false)); - storageService.get.and.returnValue(Promise.resolve({ count: 4 })); + storageService.get.and.resolveTo({ count: 4 }); reportService.getPaginatedERptcCount({}).subscribe((res) => { expect(res).toEqual({ count: 4 }); @@ -1026,7 +1029,9 @@ describe('ReportService', () => { }); it('addApprovers(): add approvers to reports', () => { - const res = reportService.addApprovers(addApproverERpts, approversData1); + const mockApproverData = cloneDeep(approversData1); + const mockERpts = cloneDeep(addApproverERpts); + const res = reportService.addApprovers(mockERpts, mockApproverData); expect(res).toEqual(expectedAddedApproverERpts); }); @@ -1057,7 +1062,7 @@ describe('ReportService', () => { describe('getReportStatsData()', () => { it('should get report stats data', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); apiv2Service.get.and.returnValue(of(apiReportStatsRawRes)); const params = { @@ -1079,7 +1084,7 @@ describe('ReportService', () => { }); it('should get report stats data when default stats has been set to false', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); apiv2Service.get.and.returnValue(of(new StatsResponse(apiReportStatsRawRes))); const params = { @@ -1101,7 +1106,7 @@ describe('ReportService', () => { }); it('getReportStats(): should get report stats', (done) => { - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); apiv2Service.get.and.returnValue(of(new StatsResponse(apiReportStatsRes))); reportService.getReportStats(apiReportStatParams).subscribe((res) => { diff --git a/src/app/core/services/status.service.spec.ts b/src/app/core/services/status.service.spec.ts index cd8c87ac73..aaa84be579 100644 --- a/src/app/core/services/status.service.spec.ts +++ b/src/app/core/services/status.service.spec.ts @@ -8,6 +8,7 @@ import { getApiResponse, updateReponseWithFlattenedEStatus, } from '../test-data/status.service.spec.data'; +import { cloneDeep } from 'lodash'; describe('StatusService', () => { let statusService: StatusService; @@ -37,7 +38,8 @@ describe('StatusService', () => { }); it('should find all estatuses', (done) => { - apiService.get.and.returnValue(of(getApiResponse)); + const mockGetApiResponse = cloneDeep(getApiResponse); + apiService.get.and.returnValue(of(mockGetApiResponse)); statusService.find(type, id).subscribe((res) => { expect(res).toEqual(getEstatusApiResponse); @@ -49,18 +51,20 @@ describe('StatusService', () => { apiService.get.and.returnValue(of(null)); statusService.find(type, id).subscribe((res) => { - expect(res).toEqual(undefined); + expect(res).toBeUndefined(); done(); }); }); it('should use status map and update the comments accordingly by adding statuses', () => { - const result = statusService.createStatusMap(apiCommentsResponse, 'reports'); + const mockApiCommentsResponse = cloneDeep(apiCommentsResponse); + const result = statusService.createStatusMap(mockApiCommentsResponse, 'reports'); expect(result).toEqual(updateReponseWithFlattenedEStatus); }); it('should find and return the latest comment', (done) => { - apiService.get.and.returnValue(of(getApiResponse)); + const mockGetApiResponse = cloneDeep(getApiResponse); + apiService.get.and.returnValue(of(mockGetApiResponse)); const result = statusService.findLatestComment(id, type, 'POLICY'); result.subscribe((res) => { diff --git a/src/app/core/services/transaction.service.spec.ts b/src/app/core/services/transaction.service.spec.ts index 92c60e12f2..06308a10f4 100644 --- a/src/app/core/services/transaction.service.spec.ts +++ b/src/app/core/services/transaction.service.spec.ts @@ -58,6 +58,7 @@ import { matchCCCExpenseResponseData, unmatchCCCExpenseResponseData, } from '../mock-data/corporate-card-transaction-response.data'; +import { cloneDeep } from 'lodash'; describe('TransactionService', () => { let transactionService: TransactionService; @@ -249,7 +250,7 @@ describe('TransactionService', () => { it('getDefaultVehicleType(): should get default vehicle type', (done) => { const defaultVehicleType = 'two_wheeler'; - storageService.get.and.returnValue(Promise.resolve(defaultVehicleType)); + storageService.get.and.resolveTo(defaultVehicleType); transactionService.getDefaultVehicleType().subscribe((res) => { expect(res).toEqual(defaultVehicleType); expect(storageService.get).toHaveBeenCalledTimes(1); @@ -317,6 +318,7 @@ describe('TransactionService', () => { beforeEach(() => { spyOn(lodash, 'cloneDeep').and.returnValue(params); }); + it('should return receipt attached params if receipt attached is YES', () => { const filters = { receiptsAttached: 'YES' }; const receiptsAttachedParams = { or: [], tx_num_files: 'gt.0' }; @@ -412,8 +414,9 @@ describe('TransactionService', () => { }); it('fixDates(): should fix dates', () => { + const mockExpenseData = cloneDeep(expenseDataWithDateString); // @ts-ignore - expect(transactionService.fixDates(expenseDataWithDateString)).toEqual(expenseData1); + expect(transactionService.fixDates(mockExpenseData)).toEqual(expenseData1); }); it('getPaymentModeforEtxn(): should return payment mode for etxn', () => { @@ -858,7 +861,7 @@ describe('TransactionService', () => { }); it('getMyExpenses(): should return my expenses with order', (done) => { - authService.getEou.and.returnValue(Promise.resolve(eouRes2)); + authService.getEou.and.resolveTo(eouRes2); apiV2Service.get.and.returnValue(of(expenseV2Data)); dateService.fixDatesV2.and.returnValue(expenseV2Data.data[0]); @@ -891,7 +894,7 @@ describe('TransactionService', () => { }); it('getMyExpenses(): should return my expenses without order using default date order', (done) => { - authService.getEou.and.returnValue(Promise.resolve(eouRes2)); + authService.getEou.and.resolveTo(eouRes2); apiV2Service.get.and.returnValue(of(expenseV2Data)); dateService.fixDatesV2.and.returnValue(expenseV2Data.data[0]); @@ -1201,7 +1204,7 @@ describe('TransactionService', () => { spyOn(transactionService, 'getIsCriticalPolicyViolated').and.returnValue(false); spyOn(transactionService, 'getIsDraft').and.returnValue(false); - expect(transactionService.getReportableExpenses(null)).toEqual(undefined); + expect(transactionService.getReportableExpenses(null)).toBeUndefined(); expect(transactionService.getIsCriticalPolicyViolated).not.toHaveBeenCalled(); expect(transactionService.getIsDraft).not.toHaveBeenCalled(); }); @@ -1231,10 +1234,11 @@ describe('TransactionService', () => { orgUserSettingsService.get.and.returnValue(of(orgUserSettingsData2)); spenderPlatformV1ApiService.post.and.returnValue(of(expensePolicyData)); - transactionService.checkPolicy(platformPolicyExpenseData1).subscribe((res) => { + const mockPlatformExpense = cloneDeep(platformPolicyExpenseData1); + transactionService.checkPolicy(mockPlatformExpense).subscribe((res) => { expect(res).toEqual(expensePolicyData); expect(spenderPlatformV1ApiService.post).toHaveBeenCalledOnceWith('/expenses/check_policies', { - data: platformPolicyExpenseData1, + data: mockPlatformExpense, }); expect(orgUserSettingsService.get).toHaveBeenCalledTimes(1); done(); @@ -1245,7 +1249,8 @@ describe('TransactionService', () => { spyOn(transactionService, 'upsert').and.returnValue(of(txnData2)); fileService.post.and.returnValue(of(fileObjectData2)); - transactionService.createTxnWithFiles(txnData, of(fileObjectData1)).subscribe((res) => { + const mockFileObject = cloneDeep(fileObjectData1); + transactionService.createTxnWithFiles(txnData, of(mockFileObject)).subscribe((res) => { expect(res).toEqual(txnData2); expect(transactionService.upsert).toHaveBeenCalledOnceWith(txnData); expect(fileService.post).toHaveBeenCalledOnceWith(fileObjectData2); @@ -1262,7 +1267,8 @@ describe('TransactionService', () => { apiService.post.and.returnValue(of(txnData4)); utilityService.discardRedundantCharacters.and.returnValue(txnDataPayload); - transactionService.upsert(upsertTxnParam).subscribe((res) => { + const mockUpsertTxnParam = cloneDeep(upsertTxnParam); + transactionService.upsert(mockUpsertTxnParam).subscribe((res) => { expect(res).toEqual(txnData4); expect(apiService.post).toHaveBeenCalledOnceWith('/transactions', txnDataPayload); expect(orgUserSettingsService.get).toHaveBeenCalledTimes(1); diff --git a/src/app/core/services/utility.service.spec.ts b/src/app/core/services/utility.service.spec.ts index 3900d3fa30..459a591973 100644 --- a/src/app/core/services/utility.service.spec.ts +++ b/src/app/core/services/utility.service.spec.ts @@ -12,6 +12,7 @@ import { SortingDirection } from '../models/sorting-direction.model'; import { SortingParam } from '../models/sorting-param.model'; import { UtilityService } from './utility.service'; +import { cloneDeep } from 'lodash'; describe('UtilityService', () => { let utilityService: UtilityService; @@ -36,12 +37,14 @@ describe('UtilityService', () => { describe('refineNestedObject():', () => { it('should return the nested object when the custom field type is number, string etc', () => { - expect(utilityService.refineNestedObject(customFieldData1)).toEqual(customFieldData1); + const mockCustomField = cloneDeep(customFieldData1); + expect(utilityService.refineNestedObject(mockCustomField)).toEqual(customFieldData1); }); it('should return the nested object when the custom field type is select', () => { spyOn(utilityService, 'discardNullChar').and.returnValue('select-1'); - expect(utilityService.refineNestedObject(customFieldData2)).toEqual(customFieldData2); + const mockCustomFieldData = cloneDeep(customFieldData2); + expect(utilityService.refineNestedObject(mockCustomFieldData)).toEqual(customFieldData2); expect(utilityService.discardNullChar).toHaveBeenCalledOnceWith('select-1'); }); }); diff --git a/src/app/core/services/virtual-cards.service.spec.ts b/src/app/core/services/virtual-cards.service.spec.ts index 92f1512845..d84591a7e0 100644 --- a/src/app/core/services/virtual-cards.service.spec.ts +++ b/src/app/core/services/virtual-cards.service.spec.ts @@ -13,6 +13,7 @@ import { virtualCardResponse, virtualCardUndefinedResponse } from '../mock-data/ import { VirtualCardsCombinedRequest } from '../models/virtual-cards-combined-request.model'; import { cardDetailsRes } from '../mock-data/platform-corporate-card-detail.data'; import { virtualCardCombinedRequest } from '../mock-data/virtual-cards-combined-request.data'; +import { cloneDeep } from 'lodash'; describe('VirtualCardsService', () => { let virtualCardsService: VirtualCardsService; @@ -48,9 +49,9 @@ describe('VirtualCardsService', () => { const virtualCardsRequest: VirtualCardsRequest = { id: 'vc1234', }; - const expectedResponse: { data: CardDetailsResponse } = virtualCardDetailsResponse; + const expectedResponse: { data: CardDetailsResponse } = cloneDeep(virtualCardDetailsResponse); expectedResponse.data.expiry_date = new Date(expectedResponse.data.expiry_date); - spenderPlatformV1ApiService.post.and.returnValue(of(virtualCardDetailsResponse)); + spenderPlatformV1ApiService.post.and.returnValue(of(expectedResponse)); virtualCardsService.getCardDetails(virtualCardsRequest).subscribe((res) => { expect(res).toEqual(expectedResponse.data); @@ -108,7 +109,7 @@ describe('VirtualCardsService', () => { spenderPlatformV1ApiService.get.and.returnValue(of(virtualCardUndefinedResponse)); virtualCardsService.getVirtualCard(virtualCardsRequest).subscribe((res) => { - expect(res).toEqual(undefined); + expect(res).toBeUndefined(); done(); }); }); diff --git a/src/app/core/test-data/accounts.service.spec.data.ts b/src/app/core/test-data/accounts.service.spec.data.ts index c7bc8d4711..1cf0bed068 100644 --- a/src/app/core/test-data/accounts.service.spec.data.ts +++ b/src/app/core/test-data/accounts.service.spec.data.ts @@ -1,4 +1,6 @@ /* eslint-disable id-blacklist */ +import deepFreeze from 'deep-freeze-strict'; + import { AccountType } from '../enums/account-type.enum'; import { ExpenseType } from '../enums/expense-type.enum'; import { unflattenedTxn } from '../mock-data/unflattened-expense.data'; @@ -7,7 +9,7 @@ import { ExtendedAccount } from '../models/extended-account.model'; import { OrgSettings } from '../models/org-settings.model'; import { UnflattenedTransaction } from '../models/unflattened-transaction.model'; -export const account1Data = { +export const account1Data = deepFreeze({ acc_id: 'accfziaxbGFVW', acc_created_at: new Date('2018-10-08T07:04:42.753Z'), acc_updated_at: new Date('2022-04-27T08:57:52.221Z'), @@ -31,9 +33,9 @@ export const account1Data = { orig_amount: null, amount: null, advance_id: null, -}; +}); -export const unflattenedAccount1Data = { +export const unflattenedAccount1Data = deepFreeze({ acc: { id: 'accfziaxbGFVW', created_at: new Date('2018-10-08T07:04:42.753Z'), @@ -60,9 +62,9 @@ export const unflattenedAccount1Data = { orig: { currency: null, amount: null }, currency: null, amount: null, -}; +}); -export const account2Data = { +export const account2Data = deepFreeze({ acc_id: 'acct0IxPgGvLa', acc_created_at: new Date('2018-11-05T18:35:59.912Z'), acc_updated_at: new Date('2021-09-29T19:35:23.965Z'), @@ -86,9 +88,9 @@ export const account2Data = { orig_amount: null, amount: 800000, advance_id: 'advT96eCXZtCo', -}; +}); -export const unflattenedAccount2Data = { +export const unflattenedAccount2Data = deepFreeze({ acc: { id: 'acc6mK6CEesGL', created_at: new Date('2018-11-15T06:25:00.402Z'), @@ -126,9 +128,9 @@ export const unflattenedAccount2Data = { }, currency: 'USD', amount: 23213, -}; +}); -export const unflattenedAccount3Data = { +export const unflattenedAccount3Data = deepFreeze({ acc: { id: 'acct0IxPgGvLa', created_at: new Date('2018-11-05T18:35:59.912Z'), @@ -148,9 +150,9 @@ export const unflattenedAccount3Data = { orig: { currency: 'USD', amount: 500 }, currency: 'USD', amount: 800000, -}; +}); -export const unflattenedAccount4Data = { +export const unflattenedAccount4Data = deepFreeze({ acc: { id: 'acct0IxPgGvLa', created_at: new Date('2018-11-05T18:35:59.912Z'), @@ -170,9 +172,9 @@ export const unflattenedAccount4Data = { orig: null, currency: 'USD', amount: 800000, -}; +}); -export const unflattenedTransactionPersonal: UnflattenedTransaction = { +export const unflattenedTransactionPersonal: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -339,9 +341,9 @@ export const unflattenedTransactionPersonal: UnflattenedTransaction = { is: { test_call: null, }, -}; +}); -export const paymentModeDataPersonal = { +export const paymentModeDataPersonal = deepFreeze({ acc: { id: 'accZ1IWjhjLyu4', created_at: new Date('2019-01-11T16:41:56.485Z'), @@ -379,9 +381,9 @@ export const paymentModeDataPersonal = { }, currency: null, amount: null, -}; +}); -export const paymentModeDataPersonal2 = { +export const paymentModeDataPersonal2 = deepFreeze({ acc: { id: 'accZ1IWjhjLyu4', created_at: new Date('2019-01-11T16:41:56.485Z'), @@ -419,9 +421,9 @@ export const paymentModeDataPersonal2 = { }, currency: null, amount: null, -}; +}); -export const unflattenedTransactionCCC: UnflattenedTransaction = { +export const unflattenedTransactionCCC: UnflattenedTransaction = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -588,9 +590,9 @@ export const unflattenedTransactionCCC: UnflattenedTransaction = { is: { test_call: null, }, -}; +}); -export const paymentModeDataCCC = { +export const paymentModeDataCCC = deepFreeze({ acc: { id: 'accZ1IWjhjLv4', created_at: new Date('2019-01-11T16:41:56.485Z'), @@ -628,9 +630,9 @@ export const paymentModeDataCCC = { }, currency: null, amount: null, -}; +}); -export const paymentModesData = [ +export const paymentModesData = deepFreeze([ { label: 'Personal Card/Cash', value: { @@ -757,9 +759,9 @@ export const paymentModesData = [ amount: null, }, }, -]; +]); -export const unflattenedTxnWithoutSourceAccountIdData = { +export const unflattenedTxnWithoutSourceAccountIdData = deepFreeze({ tx: { risk_state: null, is_duplicate_expense: null, @@ -927,9 +929,9 @@ export const unflattenedTxnWithoutSourceAccountIdData = { is: { test_call: null, }, -}; +}); -export const paymentModeDataCCCWithoutAccountProperty = { +export const paymentModeDataCCCWithoutAccountProperty = deepFreeze({ acc: { id: 'accZ1IWjhjLv4', created_at: new Date('2019-01-11T16:41:56.485Z'), @@ -965,9 +967,9 @@ export const paymentModeDataCCCWithoutAccountProperty = { }, currency: null, amount: null, -}; +}); -export const paymentModeDataAdvance = { +export const paymentModeDataAdvance = deepFreeze({ acc: { id: 'acc6mK6CEesGL', created_at: new Date('2018-11-15T06:25:00.402Z'), @@ -1005,9 +1007,9 @@ export const paymentModeDataAdvance = { }, currency: 'USD', amount: 23213, -}; +}); -export const paymentModeDataMultipleAdvance = { +export const paymentModeDataMultipleAdvance = deepFreeze({ acc: { id: 'acct0IxPgGvLa', created_at: new Date('2018-11-05T18:35:59.912Z'), @@ -1029,9 +1031,9 @@ export const paymentModeDataMultipleAdvance = { orig: { currency: 'USD', amount: 500 }, currency: 'USD', amount: 800000, -}; +}); -export const paymentModeDataMultipleAdvWithoutOrigAmt = { +export const paymentModeDataMultipleAdvWithoutOrigAmt = deepFreeze({ acc: { id: 'acct0IxPgGvLa', created_at: new Date('2018-11-05T18:35:59.912Z'), @@ -1053,9 +1055,9 @@ export const paymentModeDataMultipleAdvWithoutOrigAmt = { orig: null, currency: 'USD', amount: 800000, -}; +}); -export const multiplePaymentModesData: ExtendedAccount[] = [ +export const multiplePaymentModesData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'accWUsrRlinFb', @@ -1167,9 +1169,9 @@ export const multiplePaymentModesData: ExtendedAccount[] = [ currency: 'USD', amount: 23213, }, -]; +]); -export const multiplePaymentModesWithoutAdvData: ExtendedAccount[] = [ +export const multiplePaymentModesWithoutAdvData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'accWUsrRlinFb', @@ -1244,9 +1246,9 @@ export const multiplePaymentModesWithoutAdvData: ExtendedAccount[] = [ currency: null, amount: null, }, -]; +]); -export const multiplePaymentModesWithoutPersonalAccData: ExtendedAccount[] = [ +export const multiplePaymentModesWithoutPersonalAccData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'accWUsrRlinFb', @@ -1321,9 +1323,9 @@ export const multiplePaymentModesWithoutPersonalAccData: ExtendedAccount[] = [ currency: null, amount: null, }, -]; +]); -export const multiplePaymentModesWithCompanyAccData: ExtendedAccount[] = [ +export const multiplePaymentModesWithCompanyAccData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'accYoo40xd0C1', @@ -1441,9 +1443,9 @@ export const multiplePaymentModesWithCompanyAccData: ExtendedAccount[] = [ currency: null, amount: null, }, -]; +]); -export const multiplePaymentModesWithoutCCCAccData: ExtendedAccount[] = [ +export const multiplePaymentModesWithoutCCCAccData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'accWUsrRlinFb', @@ -1522,9 +1524,9 @@ export const multiplePaymentModesWithoutCCCAccData: ExtendedAccount[] = [ currency: null, amount: null, }, -]; +]); -export const multiplePaymentModesIncPersonalAccData: ExtendedAccount[] = [ +export const multiplePaymentModesIncPersonalAccData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'accWUsrRlinFb', @@ -1603,9 +1605,9 @@ export const multiplePaymentModesIncPersonalAccData: ExtendedAccount[] = [ currency: null, amount: null, }, -]; +]); -export const multipleAdvAccountsData: ExtendedAccount[] = [ +export const multipleAdvAccountsData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'accWUsrRlinFb', @@ -1684,9 +1686,9 @@ export const multipleAdvAccountsData: ExtendedAccount[] = [ currency: 'USD', amount: 23213, }, -]; +]); -export const etxnObjData = { +export const etxnObjData = deepFreeze({ tx: { skip_reimbursement: false, source: 'MOBILE', @@ -1701,9 +1703,9 @@ export const etxnObjData = { org_user_id: 'ouvyOFOSx5bh', }, dataUrls: [], -}; +}); -export const etxnObjWithSourceData = { +export const etxnObjWithSourceData = deepFreeze({ tx: { skip_reimbursement: true, source: 'MOBILE', @@ -1722,9 +1724,9 @@ export const etxnObjWithSourceData = { account_type: AccountType.PERSONAL, account_id: 'accZ1IWjhjLv4', }, -}; +}); -export const etxnObjWithAdvSourceData = { +export const etxnObjWithAdvSourceData = deepFreeze({ tx: { skip_reimbursement: true, source: 'MOBILE', @@ -1743,9 +1745,9 @@ export const etxnObjWithAdvSourceData = { account_type: AccountType.ADVANCE, account_id: 'accYoo40xd0C1', }, -}; +}); -export const orgSettingsData: OrgSettings = { +export const orgSettingsData: OrgSettings = deepFreeze({ org_id: 'orrb8EW1zZsy', mileage: { allowed: true, @@ -2139,9 +2141,9 @@ export const orgSettingsData: OrgSettings = { enabled: true, virtual_card_settings_enabled: true, }, -}; +}); -export const orgSettingsAdvDisabledData: OrgSettings = { +export const orgSettingsAdvDisabledData: OrgSettings = deepFreeze({ org_id: 'orrb8EW1zZsy', mileage: { allowed: true, @@ -2535,9 +2537,9 @@ export const orgSettingsAdvDisabledData: OrgSettings = { enabled: true, virtual_card_settings_enabled: true, }, -}; +}); -export const paymentModesResData = [ +export const paymentModesResData = deepFreeze([ { label: 'Corporate Card', value: { @@ -2706,9 +2708,9 @@ export const paymentModesResData = [ amount: 23213, }, }, -]; +]); -export const paymentModesAccountsData = [ +export const paymentModesAccountsData = deepFreeze([ { acc: { id: 'accWUsrRlinFb', @@ -2820,9 +2822,9 @@ export const paymentModesAccountsData = [ currency: 'USD', amount: 23213, }, -]; +]); -export const accountsData: ExtendedAccount[] = [ +export const accountsData: ExtendedAccount[] = deepFreeze([ { acc: { id: 'acc5APeygFjRd', @@ -2934,26 +2936,26 @@ export const accountsData: ExtendedAccount[] = [ currency: 'INR', amount: 499, }, -]; +]); -export const orgSettingsDataWithoutAdvPro = { +export const orgSettingsDataWithoutAdvPro = deepFreeze({ ...orgSettingsData, advanced_projects: { allowed: true, enabled: true, enable_individual_projects: true, }, -}; +}); -export const orgSettingsWithoutAutofill: OrgSettings = { +export const orgSettingsWithoutAutofill: OrgSettings = deepFreeze({ ...orgSettingsData, org_expense_form_autofills: { allowed: false, enabled: false, }, -}; +}); -export const paymentModesConfig = { +export const paymentModesConfig = deepFreeze({ etxn: unflattenedTxn, orgSettings: { ...orgSettingsData, @@ -2965,4 +2967,4 @@ export const paymentModesConfig = { }, expenseType: ExpenseType.MILEAGE, isPaymentModeConfigurationsEnabled: true, -}; +}); diff --git a/src/app/core/test-data/custom-inputs.spec.data.ts b/src/app/core/test-data/custom-inputs.spec.data.ts index 71f0ca8e8b..ce48677190 100644 --- a/src/app/core/test-data/custom-inputs.spec.data.ts +++ b/src/app/core/test-data/custom-inputs.spec.data.ts @@ -1,7 +1,9 @@ +import deepFreeze from 'deep-freeze-strict'; + import { CustomProperty } from '../models/custom-properties.model'; import { ExpenseField } from '../models/v1/expense-field.model'; -export const platformApiResponse = { +export const platformApiResponse = deepFreeze({ count: 6, data: [ { @@ -168,9 +170,9 @@ export const platformApiResponse = { }, ], offset: 0, -}; +}); -export const authRespone = { +export const authRespone = deepFreeze({ ou: { id: 'ouX8dwsbLCLv', created_at: new Date('2018-02-01T02:32:25.267Z'), @@ -332,9 +334,9 @@ export const authRespone = { customer_id: 'dwcJzfwZCgwkdfG', bank_account_added: true, }, -}; +}); -export const filterTestData: ExpenseField[] = [ +export const filterTestData: ExpenseField[] = deepFreeze([ { id: 200226, created_at: new Date('2022-02-25T05:44:36.169Z'), @@ -1185,9 +1187,9 @@ export const filterTestData: ExpenseField[] = [ 'AUDITOR', ], }, -]; +]); -export const responseAfterAppliedFilter: ExpenseField[] = [ +export const responseAfterAppliedFilter: ExpenseField[] = deepFreeze([ { id: 200227, created_at: new Date('2022-02-25T05:44:59.645Z'), @@ -1836,9 +1838,9 @@ export const responseAfterAppliedFilter: ExpenseField[] = [ 'AUDITOR', ], }, -]; +]); -export const customProperties: CustomProperty[] = [ +export const customProperties: CustomProperty[] = deepFreeze([ { name: 'USer List CF', value: [], @@ -1863,9 +1865,9 @@ export const customProperties: CustomProperty = { +export const dependentFieldValuesApiResponse: PlatformApiResponse = deepFreeze({ count: 2, data: [ { @@ -49,16 +51,16 @@ export const dependentFieldValuesApiResponse: PlatformApiResponse = { - count: 1, - data: [ - { - created_at: '2023-02-23T10:50:56.756648+00:00', - expense_field_id: 219199, - expense_field_value: 'Cost Code 2', - id: 8, - is_enabled: true, - org_id: 'orN6GkZNaD8b', - parent_expense_field_id: 219175, - parent_expense_field_value: 'Project 1', - updated_at: '2023-02-23T10:51:06.155705+00:00', - }, - ], - offset: 0, -}; +export const dependentFieldValuesApiResponseForSearchQuery: PlatformApiResponse = + deepFreeze({ + count: 1, + data: [ + { + created_at: '2023-02-23T10:50:56.756648+00:00', + expense_field_id: 219199, + expense_field_value: 'Cost Code 2', + id: 8, + is_enabled: true, + org_id: 'orN6GkZNaD8b', + parent_expense_field_id: 219175, + parent_expense_field_value: 'Project 1', + updated_at: '2023-02-23T10:51:06.155705+00:00', + }, + ], + offset: 0, + }); -export const customExpenseFields: ExpenseField[] = [ +export const customExpenseFields: ExpenseField[] = deepFreeze([ { id: 219199, code: null, @@ -185,9 +188,9 @@ export const customExpenseFields: ExpenseField[] = [ updated_at: new Date('2023-03-17T12:29:13.566689+00:00'), parent_field_id: null, }, -]; +]); -export const dependentExpenseFields: ExpenseField[] = [ +export const dependentExpenseFields: ExpenseField[] = deepFreeze([ { id: 219199, code: null, @@ -226,9 +229,9 @@ export const dependentExpenseFields: ExpenseField[] = [ updated_at: new Date('2023-02-23T10:45:53.853907+00:00'), parent_field_id: 219199, }, -]; +]); -export const txnCustomProperties: CustomProperty[] = [ +export const txnCustomProperties: CustomProperty[] = deepFreeze([ { name: 'CUSTOM FIELD', value: 'qwwq', @@ -241,9 +244,9 @@ export const txnCustomProperties: CustomProperty[] = [ name: 'Cost Area', value: null, }, -]; +]); -export const dependentFieldValues: CustomProperty[] = [ +export const dependentFieldValues: CustomProperty[] = deepFreeze([ { name: 'Cost Code', value: 'Wow this Works', @@ -252,9 +255,9 @@ export const dependentFieldValues: CustomProperty[] = [ name: 'Cost Area', value: '-', }, -]; +]); -export const txnCustomProperties2: CustomProperty[] = [ +export const txnCustomProperties2: CustomProperty[] = deepFreeze([ { name: 'CUSTOM FIELD', value: 'custom field', @@ -263,4 +266,4 @@ export const txnCustomProperties2: CustomProperty[] = [ name: 'Cost Code', value: 'Wow this Works', }, -]; +]); diff --git a/src/app/core/test-data/org-settings.service.spec.data.ts b/src/app/core/test-data/org-settings.service.spec.data.ts index 5e790afea4..2150e1d4c2 100644 --- a/src/app/core/test-data/org-settings.service.spec.data.ts +++ b/src/app/core/test-data/org-settings.service.spec.data.ts @@ -1,3 +1,5 @@ +import deepFreeze from 'deep-freeze-strict'; + import { AllowedPaymentModes } from '../models/allowed-payment-modes.enum'; import { AccountingExportSettings, @@ -6,7 +8,7 @@ import { OrgSettingsResponse, } from '../models/org-settings.model'; -export const orgSettingsGetData: OrgSettings = { +export const orgSettingsGetData: OrgSettings = deepFreeze({ org_id: 'orNVthTo2Zyo', mileage: { allowed: true, @@ -442,9 +444,9 @@ export const orgSettingsGetData: OrgSettings = { enabled: true, }, pending_cct_expense_restriction: { enabled: true, allowed: true }, -}; +}); -export const orgSettingsPostData: OrgSettingsResponse = { +export const orgSettingsPostData: OrgSettingsResponse = deepFreeze({ org_id: 'orNVthTo2Zyo', project_settings: { allowed: true, @@ -876,23 +878,23 @@ export const orgSettingsPostData: OrgSettingsResponse = { enabled: true, }, pending_cct_expense_restriction: { enabled: true, allowed: true }, -}; +}); -export const orgSettingsAmexFeedDataRequest: OrgSettingsResponse = { +export const orgSettingsAmexFeedDataRequest: OrgSettingsResponse = deepFreeze({ ...orgSettingsPostData, amex_feed_enrollment_settings: null, -}; +}); -export const orgSettingsAmexFeedDataResponse: OrgSettingsResponse = { +export const orgSettingsAmexFeedDataResponse: OrgSettingsResponse = deepFreeze({ ...orgSettingsGetData, amex_feed_enrollment_settings: { allowed: undefined, enabled: undefined, virtual_card_settings_enabled: undefined, }, -}; +}); -export const outgoingTallyAccountObj: AccountingExportSettings = { +export const outgoingTallyAccountObj: AccountingExportSettings = deepFreeze({ allowed: undefined, tally_settings: { enabled: true, @@ -910,9 +912,9 @@ export const outgoingTallyAccountObj: AccountingExportSettings = { blocked_payment_types: [], }, integration_exports_enabled: true, -}; +}); -export const incomingTallyAccoutingObj: IncomingAccountObject = { +export const incomingTallyAccoutingObj: IncomingAccountObject = deepFreeze({ enabled: true, type: 'TALLY', settings: { @@ -931,9 +933,9 @@ export const incomingTallyAccoutingObj: IncomingAccountObject = { blocked_payment_types: [], }, integration_exports_enabled: true, -}; +}); -export const outgoingQuickbooksAccountObj: AccountingExportSettings = { +export const outgoingQuickbooksAccountObj: AccountingExportSettings = deepFreeze({ allowed: undefined, quick_books_settings: { enabled: true, @@ -949,9 +951,9 @@ export const outgoingQuickbooksAccountObj: AccountingExportSettings = { separate_org_user_advance_ledger: true, }, integration_exports_enabled: true, -}; +}); -export const incomingQuickbooksAccoutingObj: IncomingAccountObject = { +export const incomingQuickbooksAccoutingObj: IncomingAccountObject = deepFreeze({ enabled: true, type: 'QUICKBOOKS', settings: { @@ -968,9 +970,9 @@ export const incomingQuickbooksAccoutingObj: IncomingAccountObject = { separate_org_user_advance_ledger: true, }, integration_exports_enabled: true, -}; +}); -export const outgoingAccountSettingsObj: AccountingExportSettings = { +export const outgoingAccountSettingsObj: AccountingExportSettings = deepFreeze({ allowed: undefined, accounting_settings: { enabled: true, @@ -983,9 +985,9 @@ export const outgoingAccountSettingsObj: AccountingExportSettings = { collapse_expenses: true, }, integration_exports_enabled: true, -}; +}); -export const incomingAccountSettingsObj: IncomingAccountObject = { +export const incomingAccountSettingsObj: IncomingAccountObject = deepFreeze({ enabled: true, type: null, settings: { @@ -999,42 +1001,42 @@ export const incomingAccountSettingsObj: IncomingAccountObject = { collapse_expenses: true, }, integration_exports_enabled: true, -}; +}); -export const incomingAccountingObj: IncomingAccountObject = { +export const incomingAccountingObj: IncomingAccountObject = deepFreeze({ enabled: false, type: null, settings: null, integration_exports_enabled: undefined, -}; +}); -export const incomingTallyAccountingObjWithoutSettings: IncomingAccountObject = { +export const incomingTallyAccountingObjWithoutSettings: IncomingAccountObject = deepFreeze({ enabled: false, type: 'TALLY', settings: null, integration_exports_enabled: false, -}; +}); -export const incomingQuickbooksAccountingObjWithoutSettings: IncomingAccountObject = { +export const incomingQuickbooksAccountingObjWithoutSettings: IncomingAccountObject = deepFreeze({ enabled: false, type: 'QUICKBOOKS', settings: null, integration_exports_enabled: false, -}; +}); -export const outgoingAccountingTallyObjWithoutSettings: AccountingExportSettings = { +export const outgoingAccountingTallyObjWithoutSettings: AccountingExportSettings = deepFreeze({ allowed: undefined, integration_exports_enabled: false, tally_settings: {}, -}; +}); -export const outgoingAccountingQuickbooksObjWithoutSettings: AccountingExportSettings = { +export const outgoingAccountingQuickbooksObjWithoutSettings: AccountingExportSettings = deepFreeze({ allowed: undefined, integration_exports_enabled: false, quick_books_settings: {}, -}; +}); -export const orgSettingsData: OrgSettings = { +export const orgSettingsData: OrgSettings = deepFreeze({ org_id: 'orNVthTo2Zyo', mileage: { allowed: true, @@ -1436,4 +1438,4 @@ export const orgSettingsData: OrgSettings = { enabled: true, virtual_card_settings_enabled: true, }, -}; +}); diff --git a/src/app/core/test-data/org-user.service.spec.data.ts b/src/app/core/test-data/org-user.service.spec.data.ts index 3f189ec3c9..93e27242a5 100644 --- a/src/app/core/test-data/org-user.service.spec.data.ts +++ b/src/app/core/test-data/org-user.service.spec.data.ts @@ -1,8 +1,10 @@ +import deepFreeze from 'deep-freeze-strict'; + import { AccessTokenData } from '../models/access-token-data.model'; import { EouApiResponse } from '../models/eou-api-response.model'; import { ExtendedOrgUser } from '../models/extended-org-user.model'; -export const currentEouRes: ExtendedOrgUser = { +export const currentEouRes: ExtendedOrgUser = deepFreeze({ ou: { id: 'ouX8dwsbLCLv', created_at: new Date('2018-02-01T02:32:25.267Z'), @@ -86,9 +88,9 @@ export const currentEouRes: ExtendedOrgUser = { customer_id: 'dwcJzfwZCgwkdfG', bank_account_added: true, }, -}; +}); -export const currentEouUnflatted: EouApiResponse = { +export const currentEouUnflatted: EouApiResponse = deepFreeze({ ou_id: 'ouX8dwsbLCLv', ou_created_at: new Date('2018-02-01T02:32:25.267Z'), ou_org_id: 'orNVthTo2Zyo', @@ -166,9 +168,9 @@ export const currentEouUnflatted: EouApiResponse = { dwolla_customer_id: 'dwcJzfwZCgwkdfG', dwolla_bank_account_added: true, ou_cost_center_ids: [13792, 13793, 13794], -}; +}); -export const employeesRes = { +export const employeesRes = deepFreeze({ count: 95, data: [ { @@ -195,9 +197,9 @@ export const employeesRes = { limit: 5, offset: 0, url: '/v2/spender_employees', -}; +}); -export const employeesParamsRes = { +export const employeesParamsRes = deepFreeze({ count: 929, data: [ { @@ -233,9 +235,9 @@ export const employeesParamsRes = { limit: 20, offset: 0, url: '/v2/spender_employees', -}; +}); -export const eouListWithDisabledUser = [ +export const eouListWithDisabledUser = deepFreeze([ { ou: { id: 'ouwszMqKW1JR', @@ -395,9 +397,9 @@ export const eouListWithDisabledUser = [ bank_account_added: null, }, }, -]; +]); -export const switchToDelegatorParams = { +export const switchToDelegatorParams = deepFreeze({ id: 'ou5qrPJbGfWM', created_at: new Date('2019-06-20T07:33:45.690Z'), org_id: 'orNVthTo2Zyo', @@ -447,9 +449,9 @@ export const switchToDelegatorParams = { default_cost_center_name: null, default_cost_center_code: null, cost_center_ids: [13696, 14018, 13701], -}; +}); -export const extendedOrgUserResponse = { +export const extendedOrgUserResponse = deepFreeze({ ou: { id: 'ou5qrPJbGfWM', created_at: new Date('2019-06-20T07:33:45.690Z'), @@ -533,15 +535,15 @@ export const extendedOrgUserResponse = { customer_id: 'dwcMdzMqqWLD9Ds', bank_account_added: null, }, -}; +}); -export const postUserParam = { +export const postUserParam = deepFreeze({ full_name: 'Dimple', email: 'dimple.kh+321@fyle.in', password: 'Test@1234523456', -}; +}); -export const postUserResponse = { +export const postUserResponse = deepFreeze({ created_at: new Date('2023-01-05T08:44:47.180Z'), email: 'dimple.kh+321@fyle.in', email_verified_at: new Date('2023-01-05T08:46:21.970Z'), @@ -549,9 +551,9 @@ export const postUserResponse = { id: 'usXHGWJ1UXMP', onboarded: false, password: 'Test@1234523456', -}; +}); -export const postOrgUser = { +export const postOrgUser = deepFreeze({ id: 'ou5tyO64Eg0L', created_at: new Date('2021-11-17T02:54:07.855Z'), updated_at: new Date('2023-01-05T08:57:31.543Z'), @@ -583,9 +585,9 @@ export const postOrgUser = { dwolla_customers_metadata_id: null, bank_account_type: null, bank_routing_number: null, -}; +}); -export const accessTokenData: AccessTokenData = { +export const accessTokenData: AccessTokenData = deepFreeze({ allowed_CIDRs: '[]', cluster_domain: '"https://staging.fyle.tech"', exp: 1672915952, @@ -597,9 +599,9 @@ export const accessTokenData: AccessTokenData = { scopes: '[]', user_id: 'usMjLibmye7s', version: '3', -}; +}); -export const accessTokenWithProxyOrgUserId: AccessTokenData = { +export const accessTokenWithProxyOrgUserId: AccessTokenData = deepFreeze({ allowed_CIDRs: '[]', cluster_domain: '"https://staging.fyle.tech"', exp: 1672915952, @@ -612,4 +614,4 @@ export const accessTokenWithProxyOrgUserId: AccessTokenData = { scopes: '[]', user_id: 'usMjLibmye7s', version: '3', -}; +}); diff --git a/src/app/core/test-data/per-diem.service.spec.data.ts b/src/app/core/test-data/per-diem.service.spec.data.ts index 067e490574..14d02449d9 100644 --- a/src/app/core/test-data/per-diem.service.spec.data.ts +++ b/src/app/core/test-data/per-diem.service.spec.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { AccountType } from '../enums/account-type.enum'; -export const apiPerDiemByID = { +export const apiPerDiemByID = deepFreeze({ count: 1, data: [ { @@ -17,9 +19,9 @@ export const apiPerDiemByID = { }, ], offset: 0, -}; +}); -export const expectPerDiemByID = { +export const expectPerDiemByID = deepFreeze({ active: false, created_at: new Date('2018-10-25T09:40:40.729Z'), currency: 'INR', @@ -28,9 +30,9 @@ export const expectPerDiemByID = { org_id: 'orrjqbDbeP9p', rate: 140, updated_at: new Date('2022-08-11T09:50:26.804Z'), -}; +}); -export const apiPerDiemSingleResponse = { +export const apiPerDiemSingleResponse = deepFreeze({ count: 4, data: [ { @@ -47,9 +49,9 @@ export const apiPerDiemSingleResponse = { }, ], offset: 0, -}; +}); -export const expectedPerDiems = [ +export const expectedPerDiems = deepFreeze([ { active: true, created_at: new Date('2018-10-08T06:37:01.337Z'), @@ -90,9 +92,9 @@ export const expectedPerDiems = [ rate: 3, updated_at: new Date('2023-01-10T07:18:10.082Z'), }, -]; +]); -export const apiPerDiem = { +export const apiPerDiem = deepFreeze({ count: 4, data: [ { @@ -145,9 +147,9 @@ export const apiPerDiem = { }, ], offset: 0, -}; +}); -export const apiPerDiemFirst = { +export const apiPerDiemFirst = deepFreeze({ count: 4, data: [ { @@ -176,9 +178,9 @@ export const apiPerDiemFirst = { }, ], offset: 0, -}; +}); -export const apiPerDiemSecond = { +export const apiPerDiemSecond = deepFreeze({ count: 4, data: [ { @@ -207,9 +209,9 @@ export const apiPerDiemSecond = { }, ], offset: 2, -}; +}); -export const allPerDiemRatesParam = [ +export const allPerDiemRatesParam = deepFreeze([ { active: true, created_at: '2020-08-12T16:09:14.551376+00:00', @@ -246,9 +248,9 @@ export const allPerDiemRatesParam = [ full_name: 'aaaa (12 AED per day)', readableRate: 'AED 12.00 per day', }, -]; +]); -export const apiOrgUserSettings = { +export const apiOrgUserSettings = deepFreeze({ id: 'ous7cvGj3iOsi', created_at: new Date('2019-10-10T06:33:08.192Z'), updated_at: new Date('2022-12-07T10:37:57.155Z'), @@ -392,9 +394,9 @@ export const apiOrgUserSettings = { enabled: true, allowed_payment_modes: [AccountType.PERSONAL], }, -}; +}); -export const allowedPerDiem = [ +export const allowedPerDiem = deepFreeze([ { active: true, created_at: '2020-08-12T16:09:14.551Z', @@ -419,4 +421,4 @@ export const allowedPerDiem = [ full_name: 'aaaa (12 AED per day)', readableRate: 'AED 12.00 per day', }, -]; +]); diff --git a/src/app/core/test-data/projects.spec.data.ts b/src/app/core/test-data/projects.spec.data.ts index 83c9fd8f96..2955b44f1c 100644 --- a/src/app/core/test-data/projects.spec.data.ts +++ b/src/app/core/test-data/projects.spec.data.ts @@ -1,9 +1,11 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ProjectParams } from '../models/project-params.model'; import { ProjectV1 } from '../models/v1/extended-project.model'; import { OrgCategory, OrgCategoryListItem } from '../models/v1/org-category.model'; import { ExtendedProject } from '../models/v2/extended-project.model'; -export const apiResponseActiveOnly = [ +export const apiResponseActiveOnly = deepFreeze([ { id: 257528, created_at: new Date('2021-05-12T10:28:40.834Z'), @@ -46,9 +48,9 @@ export const apiResponseActiveOnly = [ approver2_id: null, org_category_ids: null, }, -]; +]); -export const expectedReponseActiveOnly = [ +export const expectedReponseActiveOnly = deepFreeze([ { id: 257528, created_at: new Date('2021-05-12T10:28:40.834Z'), @@ -91,9 +93,9 @@ export const expectedReponseActiveOnly = [ approver2_id: null, org_category_ids: null, }, -]; +]); -export const apiV2ResponseMultiple = { +export const apiV2ResponseMultiple = deepFreeze({ count: 2, data: [ { @@ -138,9 +140,9 @@ export const apiV2ResponseMultiple = { limit: 4, offset: 0, url: '/v2/projects', -}; +}); -export const apiV2ResponseSingle = { +export const apiV2ResponseSingle = deepFreeze({ count: 1, data: [ { @@ -166,9 +168,9 @@ export const apiV2ResponseSingle = { limit: 1, offset: 0, url: '/v2/projects', -}; +}); -export const testActiveCategoryList: OrgCategory[] = [ +export const testActiveCategoryList: OrgCategory[] = deepFreeze([ { code: '4060340', created_at: new Date('2018-01-31T23:50:27.215171+00:00'), @@ -205,9 +207,9 @@ export const testActiveCategoryList: OrgCategory[] = [ sub_category: 'Cell phone', updated_at: new Date('2022-05-05T17:46:15.434494+00:00'), }, -]; +]); -export const testActiveCategoryListOptions: OrgCategoryListItem[] = [ +export const testActiveCategoryListOptions: OrgCategoryListItem[] = deepFreeze([ { label: 'Snacks', value: { @@ -253,9 +255,9 @@ export const testActiveCategoryListOptions: OrgCategoryListItem[] = [ updated_at: new Date('2022-05-05T17:46:15.434494+00:00'), }, }, -]; +]); -export const allowedActiveCategories: OrgCategory[] = [ +export const allowedActiveCategories: OrgCategory[] = deepFreeze([ { code: '4060340', created_at: new Date('2018-01-31T23:50:27.215171+00:00'), @@ -280,9 +282,9 @@ export const allowedActiveCategories: OrgCategory[] = [ sub_category: 'Induction', updated_at: new Date('2022-07-05T07:52:00.417939+00:00'), }, -]; +]); -export const allowedActiveCategoriesListOptions: OrgCategoryListItem[] = [ +export const allowedActiveCategoriesListOptions: OrgCategoryListItem[] = deepFreeze([ { label: 'Snacks', value: { @@ -313,9 +315,9 @@ export const allowedActiveCategoriesListOptions: OrgCategoryListItem[] = [ updated_at: new Date('2022-07-05T07:52:00.417939+00:00'), }, }, -]; +]); -export const expectedProjectsResponse: ExtendedProject[] = [ +export const expectedProjectsResponse: ExtendedProject[] = deepFreeze([ { ap1_email: null, ap1_full_name: null, @@ -354,9 +356,9 @@ export const expectedProjectsResponse: ExtendedProject[] = [ projectv2_name: 'Fyle Engineering', sub_project_name: null, }, -]; +]); -export const testProjectParams: ProjectParams = { +export const testProjectParams: ProjectParams = deepFreeze({ orgId: 'orNVthTo2Zyo', active: true, sortDirection: 'asc', @@ -366,9 +368,9 @@ export const testProjectParams: ProjectParams = { offset: 0, limit: 10, searchNameText: 'search', -}; +}); -export const testProjectV2: ExtendedProject = { +export const testProjectV2: ExtendedProject = deepFreeze({ ap1_email: null, ap1_full_name: null, ap2_email: null, @@ -386,11 +388,11 @@ export const testProjectV2: ExtendedProject = { project_updated_at: new Date('2022-11-23T08:55:29.400Z'), projectv2_name: 'Staging Project', sub_project_name: null, -}; +}); -export const testCategoryIds = ['145429', '140530', '145458', '122269']; +export const testCategoryIds = deepFreeze(['145429', '140530', '145458', '122269']); -export const params = { +export const params = deepFreeze({ project_org_id: 'eq.orNVthTo2Zyo', order: 'project_name.asc', limit: 10, @@ -399,9 +401,9 @@ export const params = { project_org_category_ids: 'ov.{,122269,122270,122271,122272,122273}', project_id: 'in.(3943,305792,148971,247936)', project_name: 'ilike.%search%', -}; +}); -export const projectsV1Data: ProjectV1[] = [ +export const projectsV1Data: ProjectV1[] = deepFreeze([ { created_at: new Date('2021-05-12T10:28:40.834844'), updated_at: new Date('2021-07-08T10:28:27.686886'), @@ -412,9 +414,9 @@ export const projectsV1Data: ProjectV1[] = [ updated_at: new Date('2021-07-08T10:28:27.686886'), ...apiResponseActiveOnly[1], }, -]; +]); -export const projectsV1Data2: ProjectV1[] = [ +export const projectsV1Data2: ProjectV1[] = deepFreeze([ { created_at: new Date('2021-05-12T10:28:40.834844'), updated_at: new Date('2021-07-08T10:28:27.686886'), @@ -422,4 +424,4 @@ export const projectsV1Data2: ProjectV1[] = [ name: 'Staging Project', ...apiResponseActiveOnly[0], }, -]; +]); diff --git a/src/app/core/test-data/status.service.spec.data.ts b/src/app/core/test-data/status.service.spec.data.ts index 79b77c275c..0ca5836a36 100644 --- a/src/app/core/test-data/status.service.spec.data.ts +++ b/src/app/core/test-data/status.service.spec.data.ts @@ -1,6 +1,8 @@ +import deepFreeze from 'deep-freeze-strict'; + import { ExtendedStatus } from '../models/extended_status.model'; -export const getApiResponse = [ +export const getApiResponse = deepFreeze([ { st_id: 'st7ak7UoeTDH', st_created_at: '2022-09-23T15:33:52.696Z', @@ -84,9 +86,9 @@ export const getApiResponse = [ us_full_name: null, us_email: null, }, -]; +]); -export const getEstatusApiResponse: ExtendedStatus[] = [ +export const getEstatusApiResponse: ExtendedStatus[] = deepFreeze([ { st_id: 'st7ak7UoeTDH', st_created_at: new Date('2022-09-23T15:33:52.696Z'), @@ -170,9 +172,9 @@ export const getEstatusApiResponse: ExtendedStatus[] = [ us_full_name: null, us_email: null, }, -]; +]); -export const apiCommentsResponse: ExtendedStatus[] = [ +export const apiCommentsResponse: ExtendedStatus[] = deepFreeze([ { st_id: 'stB3NqJuL3eE', st_created_at: new Date('2022-10-28T05:54:01.537Z'), @@ -702,9 +704,9 @@ export const apiCommentsResponse: ExtendedStatus[] = [ isSelfComment: false, isOthersComment: true, }, -]; +]); -export const updateReponseWithFlattenedEStatus: ExtendedStatus[] = [ +export const updateReponseWithFlattenedEStatus: ExtendedStatus[] = deepFreeze([ { st_id: 'stB3NqJuL3eE', st_created_at: new Date('2022-10-28T05:54:01.537Z'), @@ -1366,9 +1368,9 @@ export const updateReponseWithFlattenedEStatus: ExtendedStatus[] = [ icon: 'edit', }, }, -]; +]); -export const estatusData1: ExtendedStatus[] = [ +export const estatusData1: ExtendedStatus[] = deepFreeze([ { st_id: 'st7ak7UoeTDH', st_created_at: new Date('2022-09-23T15:33:52.696Z'), @@ -1437,9 +1439,9 @@ export const estatusData1: ExtendedStatus[] = [ icon: 'food', }, }, -]; +]); -export const expectedEstatusData1: ExtendedStatus[] = [ +export const expectedEstatusData1: ExtendedStatus[] = deepFreeze([ { st_id: 'st7ak7UoeTDH', st_created_at: new Date('2022-09-23T15:33:52.696Z'), @@ -1511,9 +1513,9 @@ export const expectedEstatusData1: ExtendedStatus[] = [ }, has_details: false, }, -]; +]); -export const updatedProjectKeyEstData: ExtendedStatus[] = [ +export const updatedProjectKeyEstData: ExtendedStatus[] = deepFreeze([ { st_id: 'st7ak7UoeTDH', st_created_at: new Date('2022-09-23T15:33:52.696Z'), @@ -1585,9 +1587,9 @@ export const updatedProjectKeyEstData: ExtendedStatus[] = [ }, has_details: false, }, -]; +]); -export const estatusSample = [ +export const estatusSample = deepFreeze([ { st_id: 'st1YBfc0c0t6', st_created_at: new Date('2022-11-07T10:56:01.991Z'), @@ -1704,9 +1706,9 @@ export const estatusSample = [ }, has_details: true, }, -]; +]); -export const eStatusWithProjectName = [ +export const eStatusWithProjectName = deepFreeze([ { st_id: 'sty8xyVwn2sK', st_created_at: new Date('2022-11-07T10:58:24.975Z'), @@ -1730,9 +1732,9 @@ export const eStatusWithProjectName = [ icon: 'radio-circle-outline', }, }, -]; +]); -export const eStatusWithProjectName2 = [ +export const eStatusWithProjectName2 = deepFreeze([ { st_id: 'sty8xyVwn2sK', st_created_at: new Date('2022-11-07T10:58:24.975Z'), @@ -1757,9 +1759,9 @@ export const eStatusWithProjectName2 = [ icon: 'radio-circle-outline', }, }, -]; +]); -export const eStatusWithReimbursible = [ +export const eStatusWithReimbursible = deepFreeze([ { st_id: 'stJ0lgtMHZW9', st_created_at: '2023-04-10T09:13:26.285Z', @@ -1795,9 +1797,9 @@ export const eStatusWithReimbursible = [ }, has_details: true, }, -]; +]); -export const newEstatusData1: ExtendedStatus[] = [ +export const newEstatusData1: ExtendedStatus[] = deepFreeze([ { st_id: 'st7ak7UoeTDH', st_created_at: new Date('2022-09-23T15:33:52.696Z'), @@ -1867,9 +1869,9 @@ export const newEstatusData1: ExtendedStatus[] = [ us_full_name: null, us_email: null, }, -]; +]); -export const expectedNewStatusData: ExtendedStatus[] = [ +export const expectedNewStatusData: ExtendedStatus[] = deepFreeze([ { st_id: 'stIwoMKmTqeM', st_created_at: new Date('2022-09-21T15:33:50.409Z'), @@ -1953,9 +1955,9 @@ export const expectedNewStatusData: ExtendedStatus[] = [ isOthersComment: true, show_dt: false, }, -]; +]); -export const systemComments1: ExtendedStatus[] = [ +export const systemComments1: ExtendedStatus[] = deepFreeze([ { st_id: 'stIwoMKmTqeM', st_created_at: new Date('2022-09-21T15:33:50.409Z'), @@ -2022,9 +2024,9 @@ export const systemComments1: ExtendedStatus[] = [ isOthersComment: true, show_dt: true, }, -]; +]); -export const systemCommentsWithSt: ExtendedStatus[] = [ +export const systemCommentsWithSt: ExtendedStatus[] = deepFreeze([ { st_id: 'stIwoMKmTqeM', st_created_at: new Date('2022-09-21T15:33:50.409Z'), @@ -2100,4 +2102,4 @@ export const systemCommentsWithSt: ExtendedStatus[] = [ icon: 'flag-fill', }, }, -]; +]); diff --git a/src/app/core/test-data/tasks.service.spec.data.ts b/src/app/core/test-data/tasks.service.spec.data.ts index a8b59de734..3c2d4a34e8 100644 --- a/src/app/core/test-data/tasks.service.spec.data.ts +++ b/src/app/core/test-data/tasks.service.spec.data.ts @@ -1,4 +1,6 @@ -export const potentialDuplicatesApiResponse = [ +import deepFreeze from 'deep-freeze-strict'; + +export const potentialDuplicatesApiResponse = deepFreeze([ { transaction_ids: ['tx3I0ccSGlhg', 'txvAmVCGZUZi'], fields: ['amount', 'currency', 'txn_dt'] }, { transaction_ids: ['tx3rq5G9gzgf', 'txS1cDov9iZn'], fields: ['amount', 'currency', 'txn_dt'] }, { transaction_ids: ['tx6KauIKfjdJ', 'txT0ZmCrVOiD'], fields: ['amount', 'currency', 'txn_dt'] }, @@ -18,9 +20,9 @@ export const potentialDuplicatesApiResponse = [ { transaction_ids: ['txjh5iDt7xXO', 'txkJsHIF6a9X'], fields: ['amount', 'currency', 'txn_dt'] }, { transaction_ids: ['txT0ZmCrVOiD', 'txws78AoalC9'], fields: ['amount', 'currency', 'txn_dt'] }, { transaction_ids: ['txT0ZmCrVOiD', 'txzjWIcqYxa9'], fields: ['amount', 'currency', 'txn_dt'] }, -]; +]); -export const extendedOrgUserResponse = { +export const extendedOrgUserResponse = deepFreeze({ ou: { id: 'out3t2X258rd', created_at: new Date('2019-02-04T10:26:36.877Z'), @@ -167,9 +169,9 @@ export const extendedOrgUserResponse = { customer_id: 'dwc8ZDUdZeUHhrI', bank_account_added: true, }, -}; +}); -export const teamReportResponse = [ +export const teamReportResponse = deepFreeze([ { aggregates: [ { @@ -184,9 +186,9 @@ export const teamReportResponse = [ dimensions: [], name: 'scalar_stat', }, -]; +]); -export const sentBackResponse = [ +export const sentBackResponse = deepFreeze([ { aggregates: [ { @@ -201,9 +203,9 @@ export const sentBackResponse = [ dimensions: [], name: 'scalar_stat', }, -]; +]); -export const unsubmittedReportsResponse = [ +export const unsubmittedReportsResponse = deepFreeze([ { aggregates: [ { @@ -218,9 +220,9 @@ export const unsubmittedReportsResponse = [ dimensions: [], name: 'scalar_stat', }, -]; +]); -export const allExtendedReportsResponse = [ +export const allExtendedReportsResponse = deepFreeze([ { _search_document: "'1':1 '2022':3 '44.53':5 'aiyush':9 'aiyush.dhar@fyle.in':10 'c/2022/11/r/2':6 'indiax':8 'inr':4 'oct':2 'se':7", @@ -444,9 +446,9 @@ export const allExtendedReportsResponse = [ us_email: 'aiyush.dhar@fyle.in', us_full_name: 'Aiyush', }, -]; +]); -export const unreportedExpensesResponse = [ +export const unreportedExpensesResponse = deepFreeze([ { aggregates: [ { @@ -461,9 +463,9 @@ export const unreportedExpensesResponse = [ dimensions: [], name: 'scalar_stat', }, -]; +]); -export const incompleteExpensesResponse = [ +export const incompleteExpensesResponse = deepFreeze([ { aggregates: [ { @@ -478,9 +480,9 @@ export const incompleteExpensesResponse = [ dimensions: [], name: 'scalar_stat', }, -]; +]); -export const sentBackAdvancesResponse = { +export const sentBackAdvancesResponse = deepFreeze({ count: 5, total_amount: 123370000, -}; +}); diff --git a/src/app/fyle/add-edit-expense/add-edit-expense-2.spec.ts b/src/app/fyle/add-edit-expense/add-edit-expense-2.spec.ts index 4b156191a4..8d125e2a47 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense-2.spec.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense-2.spec.ts @@ -471,16 +471,17 @@ export function TestCases2(getTestBed) { describe('getEditExpenseObservable(): ', () => { it('should get editable expense observable if the txn is in DRAFT state', (done) => { expensesService.getExpenseById.and.returnValue(of(platformExpenseWithExtractedData)); - transactionService.transformExpense.and.returnValue(transformedExpenseWithExtractedData); + const mockTransformedExpense = cloneDeep(transformedExpenseWithExtractedData); + transactionService.transformExpense.and.returnValue(mockTransformedExpense); categoriesService.getCategoryByName.and.returnValue(of(orgCategoryData)); dateService.getUTCDate.and.returnValue(new Date('2023-01-24T11:30:00.000Z')); component.getEditExpenseObservable().subscribe((res) => { - expect(res).toEqual(transformedExpenseWithExtractedData); + expect(res).toEqual(mockTransformedExpense); expect(expensesService.getExpenseById).toHaveBeenCalledOnceWith(activatedRoute.snapshot.params.id); expect(transactionService.transformExpense).toHaveBeenCalledOnceWith(platformExpenseWithExtractedData); expect(categoriesService.getCategoryByName).toHaveBeenCalledOnceWith( - transformedExpenseWithExtractedData.tx.extracted_data.category + mockTransformedExpense.tx.extracted_data.category ); expect(dateService.getUTCDate).not.toHaveBeenCalled(); expect(component.isIncompleteExpense).toBeTrue(); @@ -490,10 +491,11 @@ export function TestCases2(getTestBed) { it('should return txn if state is not DRAFT', (done) => { expensesService.getExpenseById.and.returnValue(of(platformExpenseData)); - transactionService.transformExpense.and.returnValue(transformedExpenseData); + const mockTransformedExpense = cloneDeep(transformedExpenseData); + transactionService.transformExpense.and.returnValue(mockTransformedExpense); component.getEditExpenseObservable().subscribe((res) => { - expect(res).toEqual(transformedExpenseData); + expect(res).toEqual(mockTransformedExpense); expect(expensesService.getExpenseById).toHaveBeenCalledOnceWith(activatedRoute.snapshot.params.id); expect(transactionService.transformExpense).toHaveBeenCalledOnceWith(platformExpenseData); done(); @@ -502,11 +504,12 @@ export function TestCases2(getTestBed) { it('should return txn when the expense or the extracted data does not contain any category', (done) => { expensesService.getExpenseById.and.returnValue(of(platformExpenseWithExtractedData2)); - transactionService.transformExpense.and.returnValue(transformedExpenseWithExtractedData2); + const mockTransformedExpense = cloneDeep(transformedExpenseWithExtractedData2); + transactionService.transformExpense.and.returnValue(mockTransformedExpense); dateService.getUTCDate.and.returnValue(new Date('2023-01-24T11:30:00.000Z')); component.getEditExpenseObservable().subscribe((res) => { - expect(res).toEqual(transformedExpenseWithExtractedData2); + expect(res).toEqual(mockTransformedExpense); expect(expensesService.getExpenseById).toHaveBeenCalledTimes(1); expect(transactionService.transformExpense).toHaveBeenCalledOnceWith(platformExpenseWithExtractedData2); expect(dateService.getUTCDate).not.toHaveBeenCalled(); @@ -1151,7 +1154,8 @@ export function TestCases2(getTestBed) { describe('getParsedReceipt():', () => { it('should get parsed receipt', fakeAsync(() => { - transactionOutboxService.parseReceipt.and.resolveTo(parsedReceiptData1); + const mockParsedReceiptData = cloneDeep(parsedReceiptData1); + transactionOutboxService.parseReceipt.and.resolveTo(mockParsedReceiptData); currencyService.getHomeCurrency.and.returnValue(of('INR')); currencyService.getExchangeRate.and.returnValue(of(82)); @@ -1171,7 +1175,8 @@ export function TestCases2(getTestBed) { })); it('should get parsed receipt without date', fakeAsync(() => { - transactionOutboxService.parseReceipt.and.resolveTo(parsedReceiptData2); + const mockParsedReceiptData = cloneDeep(parsedReceiptData2); + transactionOutboxService.parseReceipt.and.resolveTo(mockParsedReceiptData); currencyService.getHomeCurrency.and.returnValue(of('INR')); currencyService.getExchangeRate.and.returnValue(of(82)); diff --git a/src/app/fyle/add-edit-expense/add-edit-expense-3.spec.ts b/src/app/fyle/add-edit-expense/add-edit-expense-3.spec.ts index c9b599147f..74ffc29fc4 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense-3.spec.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense-3.spec.ts @@ -289,12 +289,12 @@ export function TestCases3(getTestBed) { expect(component.getParsedReceipt).toHaveBeenCalledOnceWith('url1', 'pdf'); expect(currencyService.getHomeCurrency).toHaveBeenCalledTimes(1); - expect(component.inpageExtractedData).toEqual(null); + expect(component.inpageExtractedData).toBeNull(); expect(component.fg.controls.currencyObj.value).toEqual({ amount: null, currency: 'USD', }); - expect(component.fg.controls.category.value).toEqual(null); + expect(component.fg.controls.category.value).toBeNull(); expect(component.fg.controls.dateOfSpend.value).toEqual(new Date('2023-02-24T12:03:57.680Z')); expect(component.fg.controls.vendor_id.value).toEqual('vendor_name'); }); @@ -328,7 +328,7 @@ export function TestCases3(getTestBed) { currency: 'USD', }); expect(component.fg.controls.dateOfSpend.value).toEqual(new Date('2023-02-24T12:03:57.680Z')); - expect(component.fg.controls.category.value).toEqual(null); + expect(component.fg.controls.category.value).toBeNull(); expect(component.fg.controls.vendor_id.value).toEqual('vendor_name'); }); }); @@ -374,8 +374,8 @@ export function TestCases3(getTestBed) { }); expect(result).toEqual(orgCategoryData); - expect(component.recentCategories).toEqual(undefined); - expect(component.presetCategoryId).toEqual(undefined); + expect(component.recentCategories).toBeUndefined(); + expect(component.presetCategoryId).toBeUndefined(); }); it('return auto fill category if recent categories is not present and expense category is empty', () => { @@ -405,7 +405,8 @@ export function TestCases3(getTestBed) { describe('getExpenseAttachments():', () => { it('should return file observables in edit mode', (done) => { - fileService.findByTransactionId.and.returnValue(of(fileObject4)); + const mockFileObject = cloneDeep(fileObject4); + fileService.findByTransactionId.and.returnValue(of(mockFileObject)); fileService.downloadUrl.and.returnValue(of('url')); spyOn(component, 'getReceiptDetails').and.returnValue({ type: 'jpeg', @@ -416,25 +417,27 @@ export function TestCases3(getTestBed) { expect(res).toEqual(expectedFileData1); expect(fileService.findByTransactionId).toHaveBeenCalledOnceWith('tx1vdITUXIzf'); expect(fileService.downloadUrl).toHaveBeenCalledOnceWith('fiV1gXpyCcbU'); - expect(component.getReceiptDetails).toHaveBeenCalledOnceWith(fileObject4[0]); + expect(component.getReceiptDetails).toHaveBeenCalledOnceWith(mockFileObject[0]); done(); }); }); it('should return new expense file objects in add mode', (done) => { - component.newExpenseDataUrls = fileObject4; + const mockFileObject = cloneDeep(fileObject4); + component.newExpenseDataUrls = mockFileObject; component.getExpenseAttachments('add').subscribe((res) => { - expect(res).toEqual(fileObject4); + expect(res).toEqual(mockFileObject); done(); }); }); it('should return new expense file objects of type pdf in add mode', (done) => { - component.newExpenseDataUrls = [fileObjectAdv1]; + const mockExpenseDataUrls = cloneDeep(fileObjectAdv1); + component.newExpenseDataUrls = [mockExpenseDataUrls]; component.getExpenseAttachments('add').subscribe((res) => { - expect(res).toEqual([fileObjectAdv1]); + expect(res).toEqual([mockExpenseDataUrls]); done(); }); }); @@ -478,8 +481,11 @@ export function TestCases3(getTestBed) { component.inpageExtractedData = extractedData.data; fixture.detectChanges(); + const mockCustomFieldData1 = cloneDeep(expectedCustomField[0]); + const mockCustomFieldData2 = cloneDeep(expectedCustomField[2]); + const mockEtxn = cloneDeep(unflattenedExpData); component - .generateEtxnFromFg(of(unflattenedExpData), of([expectedCustomField[0], expectedCustomField[2]])) + .generateEtxnFromFg(of(mockEtxn), of([mockCustomFieldData1, mockCustomFieldData2])) .subscribe((res) => { expect(res).toEqual(newExpFromFg); expect(component.getExpenseAttachments).toHaveBeenCalledOnceWith(component.mode, unflattenedExpData.tx.id); @@ -551,7 +557,8 @@ export function TestCases3(getTestBed) { }); fixture.detectChanges(); - component.generateEtxnFromFg(of(unflattenedTxnData2), of(customFieldData2), true).subscribe((res) => { + const mockCustomFieldData1 = cloneDeep(customFieldData2); + component.generateEtxnFromFg(of(unflattenedTxnData2), of(mockCustomFieldData1), true).subscribe((res) => { expect(res).toEqual(newExpFromFg2); expect(component.getExpenseAttachments).toHaveBeenCalledOnceWith(component.mode, 'tx3qHxFNgRcZ'); expect(dateService.getUTCDate).toHaveBeenCalledOnceWith(new Date('2023-02-23T16:24:01.335Z')); @@ -619,8 +626,9 @@ export function TestCases3(getTestBed) { component.newExpenseDataUrls = []; fixture.detectChanges(); + const mockCustomFields = cloneDeep(customFieldData1); component - .generateEtxnFromFg(of(cloneDeep(draftUnflattendedTxn)), of(customFieldData1), false) + .generateEtxnFromFg(of(cloneDeep(draftUnflattendedTxn)), of(mockCustomFields), false) .subscribe((res) => { expect(res).toEqual(newExpFromFg3); expect(component.getExpenseAttachments).toHaveBeenCalledOnceWith(component.mode, null); @@ -685,40 +693,37 @@ export function TestCases3(getTestBed) { currency: 'USD', }); - component - .generateEtxnFromFg(of(cloneDeep(draftUnflattendedTxn)), of(customFieldData1), false) - .subscribe((res) => { - expect(res).toEqual(newExpFromFg4); - expect(component.getExpenseAttachments).toHaveBeenCalledOnceWith( - component.mode, - draftUnflattendedTxn.tx.id - ); - expect(component.getSourceAccID).toHaveBeenCalledTimes(1); - expect(component.getBillable).toHaveBeenCalledTimes(1); - expect(component.getSkipRemibursement).toHaveBeenCalledTimes(1); - expect(component.getTxnDate).toHaveBeenCalledTimes(1); - expect(component.getCurrency).toHaveBeenCalledTimes(1); - expect(component.getOriginalCurrency).toHaveBeenCalledTimes(1); - expect(component.getOriginalAmount).toHaveBeenCalledTimes(1); - expect(component.getProjectID).toHaveBeenCalledTimes(1); - expect(component.getTaxAmount).toHaveBeenCalledTimes(1); - expect(component.getTaxGroupID).toHaveBeenCalledTimes(1); - expect(component.getOrgCategoryID).toHaveBeenCalledTimes(1); - expect(component.getFyleCategory).toHaveBeenCalledTimes(1); - expect(component.getDisplayName).toHaveBeenCalledTimes(1); - expect(component.getPurpose).toHaveBeenCalledTimes(1); - expect(component.getFromDt).toHaveBeenCalledTimes(1); - expect(component.getToDt).toHaveBeenCalledTimes(1); - expect(component.getFlightJourneyClass).toHaveBeenCalledTimes(1); - expect(component.getFlightReturnClass).toHaveBeenCalledTimes(1); - expect(component.getTrainTravelClass).toHaveBeenCalledTimes(1); - expect(component.getBusTravelClass).toHaveBeenCalledTimes(1); - expect(component.getDistance).toHaveBeenCalledTimes(1); - expect(component.getDistanceUnit).toHaveBeenCalledTimes(1); - expect(component.getBreakfastProvided).toHaveBeenCalledTimes(1); - expect(component.getAmount).toHaveBeenCalledTimes(1); - done(); - }); + const mockCustomFields = cloneDeep(customFieldData1); + const mockEtxn = cloneDeep(draftUnflattendedTxn); + component.generateEtxnFromFg(of(cloneDeep(mockEtxn)), of(mockCustomFields), false).subscribe((res) => { + expect(res).toEqual(newExpFromFg4); + expect(component.getExpenseAttachments).toHaveBeenCalledOnceWith(component.mode, draftUnflattendedTxn.tx.id); + expect(component.getSourceAccID).toHaveBeenCalledTimes(1); + expect(component.getBillable).toHaveBeenCalledTimes(1); + expect(component.getSkipRemibursement).toHaveBeenCalledTimes(1); + expect(component.getTxnDate).toHaveBeenCalledTimes(1); + expect(component.getCurrency).toHaveBeenCalledTimes(1); + expect(component.getOriginalCurrency).toHaveBeenCalledTimes(1); + expect(component.getOriginalAmount).toHaveBeenCalledTimes(1); + expect(component.getProjectID).toHaveBeenCalledTimes(1); + expect(component.getTaxAmount).toHaveBeenCalledTimes(1); + expect(component.getTaxGroupID).toHaveBeenCalledTimes(1); + expect(component.getOrgCategoryID).toHaveBeenCalledTimes(1); + expect(component.getFyleCategory).toHaveBeenCalledTimes(1); + expect(component.getDisplayName).toHaveBeenCalledTimes(1); + expect(component.getPurpose).toHaveBeenCalledTimes(1); + expect(component.getFromDt).toHaveBeenCalledTimes(1); + expect(component.getToDt).toHaveBeenCalledTimes(1); + expect(component.getFlightJourneyClass).toHaveBeenCalledTimes(1); + expect(component.getFlightReturnClass).toHaveBeenCalledTimes(1); + expect(component.getTrainTravelClass).toHaveBeenCalledTimes(1); + expect(component.getBusTravelClass).toHaveBeenCalledTimes(1); + expect(component.getDistance).toHaveBeenCalledTimes(1); + expect(component.getDistanceUnit).toHaveBeenCalledTimes(1); + expect(component.getBreakfastProvided).toHaveBeenCalledTimes(1); + expect(component.getAmount).toHaveBeenCalledTimes(1); + done(); + }); }); }); @@ -1174,6 +1179,7 @@ export function TestCases3(getTestBed) { beforeEach(() => { categoriesService.getCategoryByName.and.returnValue(of(expectedOrgCategoryByName2)); }); + it('should get new expense observable', (done) => { orgSettingsService.get.and.returnValue(of(orgSettingsData)); authService.getEou.and.resolveTo(apiEouRes); diff --git a/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts b/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts index 3b8c9b4b07..332717cbee 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense-4.spec.ts @@ -100,6 +100,7 @@ import { transformedExpenseWithMatchCCCData2, } from 'src/app/core/mock-data/transformed-expense.data'; import { SpenderReportsService } from 'src/app/core/services/platform/v1/spender/reports.service'; +import { cloneDeep } from 'lodash'; export function TestCases4(getTestBed) { return describe('AddEditExpensePage-4', () => { @@ -438,7 +439,8 @@ export function TestCases4(getTestBed) { describe('addExpense():', () => { it('should add an expense', (done) => { spyOn(component, 'getCustomFields').and.returnValue(of(txnCustomProperties)); - spyOn(component, 'generateEtxnFromFg').and.returnValue(of(expectedUnflattendedTxnData3)); + const mockEtxn = cloneDeep(expectedUnflattendedTxnData3); + spyOn(component, 'generateEtxnFromFg').and.returnValue(of(mockEtxn)); spyOn(component, 'trackAddExpense'); component.isConnected$ = of(true); spyOn(component, 'checkPolicyViolation').and.returnValue(of(expensePolicyDataWoData)); @@ -472,12 +474,11 @@ export function TestCases4(getTestBed) { component.isConnected$ = of(false); spyOn(component, 'trackAddExpense'); component.fg.controls.report.setValue(expectedReportsPaginated[0]); - spyOn(component, 'generateEtxnFromFg').and.returnValue( - of({ - ...unflattenedTxnData, - dataUrls: [{ url: '2023-02-08/orNVthTo2Zyo/receipts/fi6PQ6z4w6ET.000.pdf', type: 'application/pdf' }], - }) - ); + const mockEtxn = cloneDeep({ + ...unflattenedTxnData, + dataUrls: [{ url: '2023-02-08/orNVthTo2Zyo/receipts/fi6PQ6z4w6ET.000.pdf', type: 'application/pdf' }], + }); + spyOn(component, 'generateEtxnFromFg').and.returnValue(of(mockEtxn)); authService.getEou.and.resolveTo(apiEouRes); transactionOutboxService.addEntry.and.resolveTo(); component.selectedCCCTransaction = expectedECccResponse[0].ccce; @@ -491,7 +492,7 @@ export function TestCases4(getTestBed) { expect(component.generateEtxnFromFg).toHaveBeenCalledTimes(2); expect(authService.getEou).toHaveBeenCalledTimes(1); expect(transactionOutboxService.addEntry).toHaveBeenCalledOnceWith( - unflattenedTxnData.tx, + mockEtxn.tx, [{ url: '2023-02-08/orNVthTo2Zyo/receipts/fi6PQ6z4w6ET.000.pdf', type: 'pdf' }], [], 'rprAfNrce73O' @@ -503,15 +504,14 @@ export function TestCases4(getTestBed) { it('should add expense with critical policy violation', (done) => { spyOn(component, 'getCustomFields').and.returnValue(of(txnCustomProperties)); spyOn(component, 'trackAddExpense'); - spyOn(component, 'generateEtxnFromFg').and.returnValue(of(expectedUnflattendedTxnData3)); + const mockEtxn = cloneDeep(expectedUnflattendedTxnData3); + spyOn(component, 'generateEtxnFromFg').and.returnValue(of(mockEtxn)); component.isConnected$ = of(true); spyOn(component, 'checkPolicyViolation').and.returnValue(of(expensePolicyData)); policyService.getCriticalPolicyRules.and.returnValue([ 'The expense will be flagged when the total amount of all expenses in category Others in a month exceeds: INR 3000.', ]); - spyOn(component, 'criticalPolicyViolationErrorHandler').and.returnValue( - of({ etxn: expectedUnflattendedTxnData3, comment: null }) - ); + spyOn(component, 'criticalPolicyViolationErrorHandler').and.returnValue(of({ etxn: mockEtxn, comment: null })); authService.getEou.and.resolveTo(apiEouRes); spyOn(component, 'trackCreateExpense'); transactionOutboxService.addEntry.and.resolveTo(); @@ -530,7 +530,7 @@ export function TestCases4(getTestBed) { policyViolations: [ 'The expense will be flagged when the total amount of all expenses in category Others in a month exceeds: INR 3000.', ], - etxn: expectedUnflattendedTxnData3, + etxn: mockEtxn, }, jasmine.any(Observable) ); @@ -549,7 +549,8 @@ export function TestCases4(getTestBed) { it('should add expense with policy violations', (done) => { spyOn(component, 'getCustomFields').and.returnValue(of(txnCustomProperties)); spyOn(component, 'trackAddExpense'); - spyOn(component, 'generateEtxnFromFg').and.returnValue(of(expectedUnflattendedTxnData4)); + const mockEtxn = cloneDeep(expectedUnflattendedTxnData4); + spyOn(component, 'generateEtxnFromFg').and.returnValue(of(mockEtxn)); component.isConnected$ = of(true); spyOn(component, 'checkPolicyViolation').and.returnValue(of(expensePolicyData)); policyService.getCriticalPolicyRules.and.returnValue([]); @@ -558,7 +559,7 @@ export function TestCases4(getTestBed) { ]); spyOn(component, 'policyViolationErrorHandler').and.returnValue( of({ - etxn: expectedUnflattendedTxnData4, + etxn: mockEtxn, comment: 'continue', }) ); @@ -580,18 +581,13 @@ export function TestCases4(getTestBed) { 'The expense will be flagged when the total amount of all expenses in category Others in a month exceeds: INR 3000.', ], policyAction: expensePolicyData.data.final_desired_state, - etxn: expectedUnflattendedTxnData4, + etxn: mockEtxn, }, jasmine.any(Observable) ); expect(authService.getEou).toHaveBeenCalledOnceWith(); expect(component.trackCreateExpense).toHaveBeenCalledOnceWith(expectedUnflattendedTxnData4, false); - expect(transactionOutboxService.addEntry).toHaveBeenCalledOnceWith( - expectedUnflattendedTxnData4.tx, - [], - ['continue'], - undefined - ); + expect(transactionOutboxService.addEntry).toHaveBeenCalledOnceWith(mockEtxn.tx, [], ['continue'], undefined); done(); }); }); diff --git a/src/app/fyle/add-edit-expense/add-edit-expense-5.spec.ts b/src/app/fyle/add-edit-expense/add-edit-expense-5.spec.ts index 8985b70b1f..43b334785b 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense-5.spec.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense-5.spec.ts @@ -108,6 +108,7 @@ import { txnFieldsData2, txnFieldsFlightData } from 'src/app/core/mock-data/expe import { apiExpenses2, expenseData, splitExpensesData } from 'src/app/core/mock-data/platform/v1/expense.data'; import { ExpensesService } from 'src/app/core/services/platform/v1/spender/expenses.service'; import { matchedCCTransactionData } from 'src/app/core/mock-data/matchedCCTransaction.data'; +import { cloneDeep } from 'lodash'; export function TestCases5(getTestBed) { return describe('AddEditExpensePage-5', () => { @@ -1343,7 +1344,8 @@ export function TestCases5(getTestBed) { spyOn(component, 'getNewExpenseObservable').and.returnValue(of(expectedExpenseObservable)); spyOn(component, 'getEditExpenseObservable').and.returnValue(of(expectedUnflattendedTxnData1)); expensesService.getExpenseById.and.returnValue(of(expenseData)); - fileService.findByTransactionId.and.returnValue(of(expectedFileData1)); + const mockFileObject = cloneDeep(expectedFileData1); + fileService.findByTransactionId.and.returnValue(of(mockFileObject)); fileService.downloadUrl.and.returnValue(of('url')); spyOn(component, 'getReceiptDetails').and.returnValue({ type: 'jpeg', @@ -1465,12 +1467,12 @@ export function TestCases5(getTestBed) { expect(expensesService.getExpenseById).toHaveBeenCalledOnceWith('txyeiYbLDSOy'); component.attachments$.subscribe((res) => { - expect(res).toEqual(expectedFileData1); + expect(res).toEqual(mockFileObject); }); expect(fileService.findByTransactionId).toHaveBeenCalledOnceWith('tx3qHxFNgRcZ'); expect(fileService.downloadUrl).toHaveBeenCalledOnceWith('fiV1gXpyCcbU'); - expect(component.getReceiptDetails).toHaveBeenCalledOnceWith(expectedFileData1[0]); + expect(component.getReceiptDetails).toHaveBeenCalledOnceWith(mockFileObject[0]); component.flightJourneyTravelClassOptions$.subscribe((res) => { expect(res).toBeUndefined(); @@ -1632,7 +1634,8 @@ export function TestCases5(getTestBed) { expensesService.getSplitExpenses.and.returnValue(of(splitExpensesData)); transactionService.transformRawExpense.and.returnValue(splitExpTransformedData[0]); transactionService.transformRawExpense.and.returnValue(splitExpTransformedData[1]); - fileService.findByTransactionId.and.returnValue(of(expectedFileData1)); + const mockFileObject = cloneDeep(expectedFileData1); + fileService.findByTransactionId.and.returnValue(of(mockFileObject)); fileService.downloadUrl.and.returnValue(of('url')); activatedRoute.snapshot.params.activeIndex = JSON.stringify(1); activatedRoute.snapshot.params.txnIds = JSON.stringify(['id_1', 'id_2']); @@ -1749,12 +1752,12 @@ export function TestCases5(getTestBed) { expect(expensesService.getExpenseById).not.toHaveBeenCalled(); component.attachments$.subscribe((res) => { - expect(res).toEqual(expectedFileData1); + expect(res).toEqual(mockFileObject); }); expect(fileService.findByTransactionId).toHaveBeenCalledOnceWith(undefined); expect(fileService.downloadUrl).toHaveBeenCalledOnceWith('fiV1gXpyCcbU'); - expect(component.getReceiptDetails).toHaveBeenCalledOnceWith(expectedFileData1[0]); + expect(component.getReceiptDetails).toHaveBeenCalledOnceWith(mockFileObject[0]); component.flightJourneyTravelClassOptions$.subscribe((res) => { expect(res).toBeUndefined(); diff --git a/src/app/fyle/add-edit-expense/add-edit-expense-6.spec.ts b/src/app/fyle/add-edit-expense/add-edit-expense-6.spec.ts index 3732552bb5..24e6c0e921 100644 --- a/src/app/fyle/add-edit-expense/add-edit-expense-6.spec.ts +++ b/src/app/fyle/add-edit-expense/add-edit-expense-6.spec.ts @@ -81,6 +81,7 @@ import { import { matchedCCTransactionData, matchedCCTransactionData2 } from 'src/app/core/mock-data/matchedCCTransaction.data'; import { ccTransactionData, ccTransactionData1 } from 'src/app/core/mock-data/cc-transaction.data'; import { ccTransactionResponseData } from 'src/app/core/mock-data/corporate-card-transaction-response.data'; +import { cloneDeep } from 'lodash'; export function TestCases6(getTestBed) { describe('AddEditExpensePage-6', () => { @@ -365,7 +366,8 @@ export function TestCases6(getTestBed) { describe('updateFormForExpenseFields():', () => { it('should update form with expense fields values', () => { component.etxn$ = of(unflattenedExpWithCCCExpn); - component.taxGroups$ = of(taxGroupData); + const mockTaxGroupData = cloneDeep(taxGroupData); + component.taxGroups$ = of(mockTaxGroupData); expenseFieldsService.getDefaultTxnFieldValues.and.returnValue(defaultTxnFieldValuesData3); fixture.detectChanges(); @@ -375,7 +377,8 @@ export function TestCases6(getTestBed) { it('should update form with expense fields values with billable fields', () => { component.etxn$ = of(unflattenedExpWithCCCExpn); - component.taxGroups$ = of(taxGroupData); + const mockTaxGroupData = cloneDeep(taxGroupData); + component.taxGroups$ = of(mockTaxGroupData); expenseFieldsService.getDefaultTxnFieldValues.and.returnValue(defaultTxnFieldValuesData3); component.fg.controls.project.setValue(expectedProjectsResponse[0]); component.fg.controls.billable.setValue(null); @@ -391,7 +394,8 @@ export function TestCases6(getTestBed) { describe('setupExpenseFields():', () => { it('should setup expense fields', () => { - spyOn(component, 'generateTxnFieldsMap').and.returnValue(of(txnFieldsData2)); + const mockTxnFields = cloneDeep(txnFieldsData2); + spyOn(component, 'generateTxnFieldsMap').and.returnValue(of(mockTxnFields)); orgSettingsService.get.and.returnValue(of(orgSettingsData)); component.isIndividualProjectsEnabled$ = of(true); component.individualProjectIds$ = of([]); @@ -411,7 +415,8 @@ export function TestCases6(getTestBed) { }); it('should setup expense fields for offline mode and cost centers enabled', () => { - spyOn(component, 'generateTxnFieldsMap').and.returnValue(of(txnFieldsData3)); + const mockTxnFields = cloneDeep(txnFieldsData3); + spyOn(component, 'generateTxnFieldsMap').and.returnValue(of(mockTxnFields)); orgSettingsService.get.and.returnValue(of(orgSettingsData)); component.isIndividualProjectsEnabled$ = of(true); component.individualProjectIds$ = of([]); @@ -428,7 +433,8 @@ export function TestCases6(getTestBed) { }); it('should setup expense fields if cost centers are empty', () => { - spyOn(component, 'generateTxnFieldsMap').and.returnValue(of(txnFieldsData3)); + const mockTxnFields = cloneDeep(txnFieldsData3); + spyOn(component, 'generateTxnFieldsMap').and.returnValue(of(mockTxnFields)); orgSettingsService.get.and.returnValue(of(orgSettingsData)); component.isIndividualProjectsEnabled$ = of(true); component.individualProjectIds$ = of([123]); @@ -499,7 +505,8 @@ export function TestCases6(getTestBed) { it('should handle CCC expenses if expenses have matched_corporate_card_transaction synced', () => { const date = new Date('2018-07-03T13:00:00.000Z'); jasmine.clock().mockDate(date); - component.handleCCCExpenses(transformedExpenseWithMatchCCCData, null); + const mockEtxn = cloneDeep(transformedExpenseWithMatchCCCData); + component.handleCCCExpenses(mockEtxn, null); expect(component.cardNumber).toEqual('7620'); expect(component.matchedCCCTransaction).toEqual(matchedCCTransactionData); }); @@ -507,8 +514,10 @@ export function TestCases6(getTestBed) { it('should handle CCC expenses if expense does not have matched_corporate_card_transaction synced', () => { const date = new Date('2018-07-03T13:00:00.000Z'); jasmine.clock().mockDate(date); - corporateCreditCardExpenseService.transformCCTransaction.and.returnValue(matchedCCTransactionData); - component.handleCCCExpenses(transformedExpenseWithMatchCCCData4, ccTransactionData); + const mockTransformedCCCTxn = cloneDeep(matchedCCTransactionData); + corporateCreditCardExpenseService.transformCCTransaction.and.returnValue(mockTransformedCCCTxn); + const mockEtxn = cloneDeep(transformedExpenseWithMatchCCCData4); + component.handleCCCExpenses(mockEtxn, ccTransactionData); expect(corporateCreditCardExpenseService.transformCCTransaction).toHaveBeenCalledOnceWith(ccTransactionData); expect(component.cardNumber).toEqual('7620'); expect(component.matchedCCCTransaction).toEqual(matchedCCTransactionData); @@ -517,7 +526,8 @@ export function TestCases6(getTestBed) { it('should show card digits and vendor description', () => { const date = new Date('2018-06-06T08:30:00.000Z'); jasmine.clock().mockDate(date); - component.handleCCCExpenses(transformedExpenseWithMatchCCCData3, null); + const mockEtxn = cloneDeep(transformedExpenseWithMatchCCCData3); + component.handleCCCExpenses(mockEtxn, null); expect(component.cardNumber).toEqual('9891'); expect(component.matchedCCCTransaction).toEqual(matchedCCTransactionData2); }); diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage-1.spec.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage-1.spec.ts index 4af092b537..3df2e2eb22 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage-1.spec.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage-1.spec.ts @@ -925,7 +925,7 @@ export function TestCases1(getTestBed) { it('should return an error object when the date is after the upper bound of the valid range', () => { const tomorrow = new Date(); - tomorrow.setDate(tomorrow.getDate() + 2); + tomorrow.setDate(tomorrow.getDate() + 3); const control = new FormControl(tomorrow.toDateString()); const result = component.customDateValidator(control); expect(result).toEqual({ invalidDateSelection: true }); diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts index facb7a6823..af4d2bbf63 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage-3.spec.ts @@ -536,10 +536,11 @@ export function TestCases3(getTestBed) { mileageCategories: [mileageCategories2[1]], }) ); - expenseFieldsService.filterByOrgCategoryId.and.returnValue(of(txnFieldsData)); + const mockTxnFields = cloneDeep(txnFieldsData); + expenseFieldsService.filterByOrgCategoryId.and.returnValue(of(mockTxnFields)); component.getTransactionFields().subscribe((res) => { - expect(res).toEqual(txnFieldsData); + expect(res).toEqual(mockTxnFields); expect(expenseFieldsService.getAllMap).toHaveBeenCalledTimes(1); expect(component.getMileageCategories).toHaveBeenCalledTimes(1); expect(expenseFieldsService.filterByOrgCategoryId).toHaveBeenCalledOnceWith( diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage-4.spec.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage-4.spec.ts index 02b5a25a37..aa789297f4 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage-4.spec.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage-4.spec.ts @@ -276,7 +276,8 @@ export function TestCases4(getTestBed) { custom_inputs: customPropertiesData as CustomInput[], }); spyOn(component, 'checkMileageCategories').and.returnValue(of(orgCategoryData)); - customFieldsService.standardizeCustomFields.and.returnValue(txnCustomPropertiesData); + const mockTxnCustomProperties = cloneDeep(txnCustomPropertiesData); + customFieldsService.standardizeCustomFields.and.returnValue(mockTxnCustomProperties); fixture.detectChanges(); component.getCustomInputs().subscribe((res) => { @@ -293,7 +294,8 @@ export function TestCases4(getTestBed) { it('should get custom inputs if no previous custom inputs are assigned', (done) => { spyOn(component, 'checkMileageCategories').and.returnValue(of(orgCategoryData)); - customFieldsService.standardizeCustomFields.and.returnValue(txnCustomPropertiesData3); + const mockTxnCustomProperties = cloneDeep(txnCustomPropertiesData3); + customFieldsService.standardizeCustomFields.and.returnValue(mockTxnCustomProperties); spyOn(component, 'getFormValues').and.returnValue({ custom_inputs: null, }); @@ -693,9 +695,10 @@ export function TestCases4(getTestBed) { component.commuteDetails = commuteDetailsData; component.fg.patchValue({ commuteDeduction: CommuteDeduction.ONE_WAY }); fixture.detectChanges(); + const mockTxnCustomProperties = cloneDeep(txnCustomProperties4); component - .generateEtxnFromFg(of(unflattenedTxnWithReportID3), of(txnCustomProperties4), of(10)) + .generateEtxnFromFg(of(unflattenedTxnWithReportID3), of(mockTxnCustomProperties), of(10)) .subscribe((res) => { expect(res).toEqual(newMileageExpFromForm); expect(component.getFormValues).toHaveBeenCalledTimes(1); diff --git a/src/app/fyle/add-edit-mileage/add-edit-mileage-5.spec.ts b/src/app/fyle/add-edit-mileage/add-edit-mileage-5.spec.ts index e78f69365f..61acb73b43 100644 --- a/src/app/fyle/add-edit-mileage/add-edit-mileage-5.spec.ts +++ b/src/app/fyle/add-edit-mileage/add-edit-mileage-5.spec.ts @@ -257,7 +257,8 @@ export function TestCases5(getTestBed) { spyOn(component, 'getProjects').and.returnValue(of(expectedProjectsResponse[0])); spyOn(component, 'getReports').and.returnValue(of(expectedReportsPaginated[0])); spyOn(component, 'getSelectedCostCenters').and.returnValue(of(costCentersData[0])); - spyOn(component, 'getMileageByVehicleType').and.returnValue(unfilteredMileageRatesData[0]); + const mockMileageRates = cloneDeep(unfilteredMileageRatesData[0]); + spyOn(component, 'getMileageByVehicleType').and.returnValue(mockMileageRates); } function setupMocks() { @@ -768,7 +769,8 @@ export function TestCases5(getTestBed) { const mockOrgSettings = cloneDeep(orgSettingsRes); mockOrgSettings.commute_deduction_settings = { allowed: true, enabled: true }; orgSettingsService.get.and.returnValue(of(mockOrgSettings)); - employeesService.getCommuteDetails.and.returnValue(of(commuteDetailsResponseData)); + const mockCommuteDetailsResponse = cloneDeep(commuteDetailsResponseData); + employeesService.getCommuteDetails.and.returnValue(of(mockCommuteDetailsResponse)); mileageService.getCommuteDeductionOptions.and.returnValue(commuteDeductionOptionsData1); mileageService.isCommuteDeductionEnabled.and.returnValue(true); spyOn(component, 'updateDistanceOnDeductionChange'); diff --git a/src/app/fyle/merge-expense/merge-expense-3.page.spec.ts b/src/app/fyle/merge-expense/merge-expense-3.page.spec.ts index 8649736deb..0f5a83108d 100644 --- a/src/app/fyle/merge-expense/merge-expense-3.page.spec.ts +++ b/src/app/fyle/merge-expense/merge-expense-3.page.spec.ts @@ -302,7 +302,8 @@ export function TestCases3(getTestBed) { }); it('should return customInput options correctly', () => { - const customInputOptions = component.generateCustomInputOptions(mergeExpenesesCustomInputsData); + const mockMergeExpensesCustomInputsData = cloneDeep(mergeExpenesesCustomInputsData); + const customInputOptions = component.generateCustomInputOptions(mockMergeExpensesCustomInputsData); expect(mergeExpensesService.formatCustomInputOptions).toHaveBeenCalledOnceWith(optionsDataMergeExpenses); expect(customInputOptions).toEqual({ @@ -334,7 +335,7 @@ export function TestCases3(getTestBed) { it('should set disableFormElements to true if isApprovedAndAbove length is greater than zero', () => { component.setAdvanceOrApprovedAndAbove(expensesInfo); - expect(component.disableFormElements).toEqual(true); + expect(component.disableFormElements).toBeTrue(); }); it('should set disableFormElements to false if isApprovedAndAbove length is zero and isAdvancePresent is false', () => { @@ -342,13 +343,13 @@ export function TestCases3(getTestBed) { const mockExpenseInfo = cloneDeep(expensesInfo); mockExpenseInfo.isAdvancePresent = false; component.setAdvanceOrApprovedAndAbove(mockExpenseInfo); - expect(component.disableFormElements).toEqual(false); + expect(component.disableFormElements).toBeFalse(); }); it('should set disableFormElements to true if expensesInfo.isAdvancePresent is true', () => { mergeExpensesService.isApprovedAndAbove.and.returnValue([]); component.setAdvanceOrApprovedAndAbove(expensesInfo); - expect(component.disableFormElements).toEqual(true); + expect(component.disableFormElements).toBeTrue(); }); }); @@ -361,21 +362,21 @@ export function TestCases3(getTestBed) { it('should call mergeExpensesService.isReportedPresent() once and set isReportedExpensePresent to true if isReported length is greater than zero', () => { component.setIsReported(expensesInfo); expect(mergeExpensesService.isReportedPresent).toHaveBeenCalledOnceWith(expenseList2); - expect(component.isReportedExpensePresent).toEqual(true); + expect(component.isReportedExpensePresent).toBeTrue(); }); it('should set isReportedExpensePresent to false if isReported length is zero', () => { mergeExpensesService.isReportedPresent.and.returnValue([]); component.setIsReported(expensesInfo); - expect(component.isReportedExpensePresent).toEqual(false); + expect(component.isReportedExpensePresent).toBeFalse(); }); it('should set disableFormElements and showReceiptSelection to true if isReportedExpensePresent and expensesInfo.isAdvancePresent is true', () => { component.disableFormElements = false; component.showReceiptSelection = false; component.setIsReported(expensesInfo); - expect(component.disableFormElements).toEqual(true); - expect(component.showReceiptSelection).toEqual(true); + expect(component.disableFormElements).toBeTrue(); + expect(component.showReceiptSelection).toBeTrue(); }); it('should not modify disableFormElements and showReceiptSelection if isReportedExpensePresent is false', () => { @@ -383,8 +384,8 @@ export function TestCases3(getTestBed) { component.showReceiptSelection = false; mergeExpensesService.isReportedPresent.and.returnValue([]); component.setIsReported(expensesInfo); - expect(component.disableFormElements).toEqual(false); - expect(component.showReceiptSelection).toEqual(false); + expect(component.disableFormElements).toBeFalse(); + expect(component.showReceiptSelection).toBeFalse(); }); it('should not modify disableFormElements and showReceiptSelection if expensesInfo.isAdvancePresent is false', () => { @@ -393,8 +394,8 @@ export function TestCases3(getTestBed) { const mockExpenseInfo = cloneDeep(expensesInfo); mockExpenseInfo.isAdvancePresent = false; component.setIsReported(mockExpenseInfo); - expect(component.disableFormElements).toEqual(false); - expect(component.showReceiptSelection).toEqual(false); + expect(component.disableFormElements).toBeFalse(); + expect(component.showReceiptSelection).toBeFalse(); }); }); @@ -423,7 +424,7 @@ export function TestCases3(getTestBed) { component.setInitialExpenseToKeepDetails(expensesInfo, true); expect(mergeExpensesService.isReportedOrAbove).toHaveBeenCalledOnceWith(expensesInfo); expect(component.setIsReported).toHaveBeenCalledOnceWith(expensesInfo); - expect(component.disableExpenseToKeep).toEqual(true); + expect(component.disableExpenseToKeep).toBeTrue(); expect(component.expenseToKeepInfoText).toEqual( 'You are required to keep the expense that has already been submitted.' ); @@ -441,8 +442,8 @@ export function TestCases3(getTestBed) { expect(mergeExpensesService.isMoreThanOneAdvancePresent).toHaveBeenCalledOnceWith(expensesInfo, true); expect(component.setIsReported).not.toHaveBeenCalled(); - expect(component.disableExpenseToKeep).toEqual(false); - expect(component.showReceiptSelection).toEqual(true); + expect(component.disableExpenseToKeep).toBeFalse(); + expect(component.showReceiptSelection).toBeTrue(); expect(component.expenseToKeepInfoText).toEqual( 'You cannot make changes to an expense paid from ‘advance’. Edit each expense separately if you wish to make any changes.' ); @@ -460,8 +461,8 @@ export function TestCases3(getTestBed) { expect(mergeExpensesService.isAdvancePresent).toHaveBeenCalledOnceWith(expensesInfo); expect(component.setIsReported).not.toHaveBeenCalled(); - expect(component.disableExpenseToKeep).toEqual(true); - expect(component.showReceiptSelection).toEqual(false); + expect(component.disableExpenseToKeep).toBeTrue(); + expect(component.showReceiptSelection).toBeFalse(); expect(component.expenseToKeepInfoText).toEqual( 'You are required to keep the expense paid from ‘advance’. Edit each expense separately if you wish to make any changes.' ); diff --git a/src/app/fyle/my-create-report/my-create-report.page.spec.ts b/src/app/fyle/my-create-report/my-create-report.page.spec.ts index 90d3999c9b..e965d77d56 100644 --- a/src/app/fyle/my-create-report/my-create-report.page.spec.ts +++ b/src/app/fyle/my-create-report/my-create-report.page.spec.ts @@ -375,9 +375,10 @@ describe('MyCreateReportPage', () => { it('toggleTransaction(): should toggle selected transaction to unselected', () => { spyOn(component, 'getReportTitle'); - component.toggleTransaction(selectedExpense1); + const mockSelectedExpense = cloneDeep(selectedExpense1); + component.toggleTransaction(mockSelectedExpense); - expect(selectedExpense1.isSelected).toBeFalse(); + expect(mockSelectedExpense.isSelected).toBeFalse(); expect(component.getReportTitle).toHaveBeenCalledTimes(1); }); diff --git a/src/app/fyle/my-profile/employee-details-card/employee-details-card.component.spec.ts b/src/app/fyle/my-profile/employee-details-card/employee-details-card.component.spec.ts index 450ebd62a8..55d6269fb4 100644 --- a/src/app/fyle/my-profile/employee-details-card/employee-details-card.component.spec.ts +++ b/src/app/fyle/my-profile/employee-details-card/employee-details-card.component.spec.ts @@ -6,6 +6,7 @@ import { apiEouRes } from 'src/app/core/mock-data/extended-org-user.data'; import { getTextContent } from 'src/app/core/dom-helpers'; import { getElementBySelector } from 'src/app/core/dom-helpers'; import { click } from 'src/app/core/dom-helpers'; +import { cloneDeep } from 'lodash'; describe('EmployeeDetailsCardComponent', () => { let component: EmployeeDetailsCardComponent; @@ -20,7 +21,8 @@ describe('EmployeeDetailsCardComponent', () => { fixture = TestBed.createComponent(EmployeeDetailsCardComponent); component = fixture.componentInstance; - component.eou = apiEouRes; + const mockApiEouRes = cloneDeep(apiEouRes); + component.eou = mockApiEouRes; fixture.detectChanges(); })); diff --git a/src/app/fyle/my-reports/my-reports.page.spec.ts b/src/app/fyle/my-reports/my-reports.page.spec.ts index 89afdd819f..558b18df87 100644 --- a/src/app/fyle/my-reports/my-reports.page.spec.ts +++ b/src/app/fyle/my-reports/my-reports.page.spec.ts @@ -1237,7 +1237,8 @@ describe('MyReportsPage', () => { }; const expectedAndQuery = `(rp_created_at.gte.${thisMonthRange.from.toISOString()},rp_created_at.lt.${thisMonthRange.to.toISOString()})`; dateService.getThisMonthRange.and.returnValue(thisMonthRange); - component.filters = filter8; + const mockFilter = cloneDeep(filter8); + component.filters = mockFilter; component.generateDateParams(newQueryParams); @@ -1254,7 +1255,8 @@ describe('MyReportsPage', () => { }; const expectedAndQuery = `(rp_created_at.gte.${thisWeekRange.from.toISOString()},rp_created_at.lt.${thisWeekRange.to.toISOString()})`; dateService.getThisWeekRange.and.returnValue(thisWeekRange); - component.filters = filter9; + const mockFilter = cloneDeep(filter9); + component.filters = mockFilter; component.generateDateParams(newQueryParams); @@ -1271,7 +1273,8 @@ describe('MyReportsPage', () => { }; const expectedAndQuery = `(rp_created_at.gte.${lastMonthRange.from.toISOString()},rp_created_at.lt.${lastMonthRange.to.toISOString()})`; dateService.getLastMonthRange.and.returnValue(lastMonthRange); - component.filters = filter10; + const mockFilter = cloneDeep(filter10); + component.filters = mockFilter; component.generateDateParams(newQueryParams); @@ -1282,7 +1285,8 @@ describe('MyReportsPage', () => { it('should not generate date params when date filter is not set', () => { spyOn(component, 'generateCustomDateParams'); const newQueryParams: { or: string[]; and?: string } = { or: [] }; - component.filters = filter11; + const mockFilter = cloneDeep(filter11); + component.filters = mockFilter; component.generateDateParams(newQueryParams); @@ -1292,7 +1296,8 @@ describe('MyReportsPage', () => { it('should convert customDateStart and customDateEnd string to date', () => { spyOn(component, 'generateCustomDateParams'); - component.filters = filter12; + const mockFilter = cloneDeep(filter12); + component.filters = mockFilter; const newQueryParams: { or: string[]; and?: string } = { or: [] }; component.generateDateParams(newQueryParams); @@ -1448,7 +1453,7 @@ describe('MyReportsPage', () => { 'present', 'onWillDismiss', ]); - popoverController.create.and.returnValue(Promise.resolve(cannotDeleteReportPopOverSpy)); + popoverController.create.and.resolveTo(cannotDeleteReportPopOverSpy); const mockErpt = cloneDeep({ ...apiExtendedReportRes[0], rp_state: 'APPROVED' }); component.onDeleteReportClick(mockErpt); @@ -1460,7 +1465,7 @@ describe('MyReportsPage', () => { it('should call the deleteReport and do a refresh if rp_state consist any of DRAFT, APPROVER_PENDING, APPROVER_INQUIRY', fakeAsync(() => { const deleteReportPopoverSpy = jasmine.createSpyObj('deleteReportPopover', ['present', 'onDidDismiss']); deleteReportPopoverSpy.onDidDismiss.and.resolveTo({ data: { status: 'success' } }); - popoverController.create.and.returnValue(Promise.resolve(deleteReportPopoverSpy)); + popoverController.create.and.resolveTo(deleteReportPopoverSpy); spyOn(component, 'doRefresh'); spyOn(component, 'getDeleteReportPopoverParams').and.returnValue(deletePopoverParamsRes); reportService.delete.and.returnValue(of(null)); @@ -1526,7 +1531,7 @@ describe('MyReportsPage', () => { expect(component.simpleSearchText).toEqual(''); expect(inputElement.value).toEqual(''); expect(dispatchEventSpy).toHaveBeenCalledOnceWith(new Event('keyup')); - expect(component.isSearchBarFocused).toEqual(true); + expect(component.isSearchBarFocused).toBeTrue(); }); it('should clear the search text, input value, dispatch keyup event, and toggle search bar focus when called from onSimpleSearchCancel', () => { @@ -1542,7 +1547,7 @@ describe('MyReportsPage', () => { expect(component.simpleSearchText).toEqual(''); expect(inputElement.value).toEqual(''); expect(dispatchEventSpy).toHaveBeenCalledOnceWith(new Event('keyup')); - expect(component.isSearchBarFocused).toEqual(false); + expect(component.isSearchBarFocused).toBeFalse(); }); }); @@ -1562,7 +1567,7 @@ describe('MyReportsPage', () => { inputElement.dispatchEvent(new Event('focus')); - expect(component.isSearchBarFocused).toEqual(true); + expect(component.isSearchBarFocused).toBeTrue(); }); it('onFilterPillsClearAll(): should call clearFilters', () => { @@ -1937,6 +1942,7 @@ describe('MyReportsPage', () => { beforeEach(() => { spyOn(component, 'convertSelectedSortFitlersToFilters'); }); + it('should convert selected filters to corresponding Filters object', () => { const selectedFilters = selectedFilters3; @@ -2408,7 +2414,7 @@ describe('MyReportsPage', () => { ]); spyOn(component, 'generateSelectedFilters').and.returnValue([{ name: 'state', value: 'PENDING' }]); filterPopoverSpy.onWillDismiss.and.resolveTo({ data: selectedFilters1 }); - modalController.create.and.returnValue(Promise.resolve(filterPopoverSpy)); + modalController.create.and.resolveTo(filterPopoverSpy); component.openFilters('State'); tick(200); diff --git a/src/app/fyle/my-view-report/my-view-report.page.spec.ts b/src/app/fyle/my-view-report/my-view-report.page.spec.ts index 6b1120699b..5483771a80 100644 --- a/src/app/fyle/my-view-report/my-view-report.page.spec.ts +++ b/src/app/fyle/my-view-report/my-view-report.page.spec.ts @@ -308,7 +308,8 @@ describe('MyViewReportPage', () => { loaderService.showLoader.and.resolveTo(); reportService.getReport.and.returnValue(of(erpt)); authService.getEou.and.resolveTo(apiEouRes); - statusService.find.and.returnValue(of(newEstatusData1)); + const mockStatusData = cloneDeep(newEstatusData1); + statusService.find.and.returnValue(of(mockStatusData)); statusService.createStatusMap.and.returnValue(systemCommentsWithSt); reportService.getApproversByReportId.and.returnValue(of(approversData1)); expensesService.getReportExpenses.and.returnValue(of(expenseResponseData2)); @@ -401,7 +402,8 @@ describe('MyViewReportPage', () => { loaderService.showLoader.and.resolveTo(); reportService.getReport.and.returnValue(of(null)); authService.getEou.and.resolveTo(apiEouRes); - statusService.find.and.returnValue(of(newEstatusData1)); + const mockStatusData = cloneDeep(newEstatusData1); + statusService.find.and.returnValue(of(mockStatusData)); statusService.createStatusMap.and.returnValue(systemCommentsWithSt); reportService.getApproversByReportId.and.returnValue(of(approversData1)); expensesService.getReportExpenses.and.returnValue(of(expenseResponseData2)); @@ -486,13 +488,14 @@ describe('MyViewReportPage', () => { }); it('updateReportName(): should update report name', () => { - component.erpt$ = of(newReportParam); + const mockErpt = cloneDeep(newReportParam); + component.erpt$ = of(mockErpt); fixture.detectChanges(); reportService.updateReportPurpose.and.returnValue(of(platformReportData)); spyOn(component.loadReportDetails$, 'next'); component.updateReportName('#3: Jul 2023 - Office expense'); - expect(reportService.updateReportPurpose).toHaveBeenCalledOnceWith(newReportParam); + expect(reportService.updateReportPurpose).toHaveBeenCalledOnceWith(mockErpt); expect(component.loadReportDetails$.next).toHaveBeenCalledTimes(1); }); @@ -507,7 +510,7 @@ describe('MyViewReportPage', () => { const editReportNamePopoverSpy = jasmine.createSpyObj('editReportNamePopover', ['present', 'onWillDismiss']); editReportNamePopoverSpy.onWillDismiss.and.resolveTo({ data: { reportName: 'new name' } }); - popoverController.create.and.returnValue(Promise.resolve(editReportNamePopoverSpy)); + popoverController.create.and.resolveTo(editReportNamePopoverSpy); const editReportButton = getElementBySelector(fixture, '.view-reports--card-header__icon') as HTMLElement; click(editReportButton); @@ -533,7 +536,7 @@ describe('MyViewReportPage', () => { const editReportNamePopoverSpy = jasmine.createSpyObj('editReportNamePopover', ['present', 'onWillDismiss']); editReportNamePopoverSpy.onWillDismiss.and.resolveTo(); - popoverController.create.and.returnValue(Promise.resolve(editReportNamePopoverSpy)); + popoverController.create.and.resolveTo(editReportNamePopoverSpy); const editReportButton = getElementBySelector(fixture, '.view-reports--card-header__icon') as HTMLElement; click(editReportButton); @@ -590,7 +593,7 @@ describe('MyViewReportPage', () => { const deleteReportPopoverSpy = jasmine.createSpyObj('deleteReportPopover', ['present', 'onDidDismiss']); deleteReportPopoverSpy.onDidDismiss.and.resolveTo({ data: { status: 'success' } }); - popoverController.create.and.returnValue(Promise.resolve(deleteReportPopoverSpy)); + popoverController.create.and.resolveTo(deleteReportPopoverSpy); component.deleteReportPopup(expectedAllReports[0]); tick(2000); @@ -700,6 +703,7 @@ describe('MyViewReportPage', () => { }, ]); }); + it('should go to edit expense page if canEdit is true', () => { component.canEdit$ = of(true); component.erpt$ = of(expectedAllReports[0]); @@ -828,7 +832,7 @@ describe('MyViewReportPage', () => { email: 'aj@fyle.com', }, }); - modalController.create.and.returnValue(Promise.resolve(shareReportModalSpy)); + modalController.create.and.resolveTo(shareReportModalSpy); reportService.downloadSummaryPdfUrl.and.returnValue(of(null)); matSnackBar.openFromComponent.and.callThrough(); modalProperties.getModalDefaultProperties.and.returnValue(shareReportModalProperties); @@ -863,7 +867,7 @@ describe('MyViewReportPage', () => { const viewInfoModalSpy = jasmine.createSpyObj('viewInfoModal', ['onWillDismiss', 'present']); viewInfoModalSpy.onWillDismiss.and.resolveTo(); - modalController.create.and.returnValue(Promise.resolve(viewInfoModalSpy)); + modalController.create.and.resolveTo(viewInfoModalSpy); modalProperties.getModalDefaultProperties.and.returnValue(fyModalProperties); await component.openViewReportInfoModal(); @@ -964,7 +968,7 @@ describe('MyViewReportPage', () => { }, }); - modalController.create.and.returnValue(Promise.resolve(addExpensesToReportModalSpy)); + modalController.create.and.resolveTo(addExpensesToReportModalSpy); modalProperties.getModalDefaultProperties.and.returnValue(fyModalProperties); spyOn(component, 'addExpensesToReport').and.returnValue(null); @@ -997,7 +1001,7 @@ describe('MyViewReportPage', () => { ]); addExpensesToReportModalSpy.onWillDismiss.and.resolveTo(null); - modalController.create.and.returnValue(Promise.resolve(addExpensesToReportModalSpy)); + modalController.create.and.resolveTo(addExpensesToReportModalSpy); modalProperties.getModalDefaultProperties.and.returnValue(fyModalProperties); spyOn(component, 'addExpensesToReport').and.returnValue(null); diff --git a/src/app/fyle/notifications/notifications.page.spec.ts b/src/app/fyle/notifications/notifications.page.spec.ts index 8a3f6810d9..5170b97d74 100644 --- a/src/app/fyle/notifications/notifications.page.spec.ts +++ b/src/app/fyle/notifications/notifications.page.spec.ts @@ -182,7 +182,8 @@ describe('NotificationsPage', () => { it('removeAdminUnsbscribedEvents(): should remove admin unsubscribe events', fakeAsync(() => { component.orgSettings$ = of(orgSettingsWithUnsubscribeEvent); component.orgSettings = orgSettingsWithUnsubscribeEvent; - component.notificationEvents = cloneDeep(notificationEventsData2); + const mockNotificationEvents = cloneDeep(notificationEventsData2); + component.notificationEvents = cloneDeep(mockNotificationEvents); component.removeAdminUnsbscribedEvents(); tick(500); @@ -191,17 +192,19 @@ describe('NotificationsPage', () => { })); it('updateAdvanceRequestFeatures(): should update advance request features', () => { - component.notificationEvents = notificationEventsData; + const mockNotificationEvents = cloneDeep(notificationEventsData); + component.notificationEvents = mockNotificationEvents; component.orgSettings$ = of(orgSettingsData); component.updateAdvanceRequestFeatures(); - expect(Object.keys(notificationEventsData.features).includes('advances')).toBeFalse(); + expect(Object.keys(mockNotificationEvents.features).includes('advances')).toBeFalse(); }); describe('updateDelegateeNotifyPreference():', () => { it('should set settings to notify delegatee', () => { - component.orgUserSettings = orgUserSettingsData; + const mockOrgUserSettings = cloneDeep(orgUserSettingsData); + component.orgUserSettings = mockOrgUserSettings; component.updateDelegateeNotifyPreference({ value: 'Notify my delegate', @@ -212,7 +215,8 @@ describe('NotificationsPage', () => { }); it('should set settings to notify delegatee and user', () => { - component.orgUserSettings = orgUserSettingsData; + const mockOrgUserSettings = cloneDeep(orgUserSettingsData); + component.orgUserSettings = mockOrgUserSettings; component.updateDelegateeNotifyPreference({ value: 'Notify me and my delegate', @@ -223,7 +227,8 @@ describe('NotificationsPage', () => { }); it('should set settings to notify user', () => { - component.orgUserSettings = orgUserSettingsData; + const mockOrgUserSettings = cloneDeep(orgUserSettingsData); + component.orgUserSettings = mockOrgUserSettings; component.updateDelegateeNotifyPreference({ value: 'Notify me only', diff --git a/src/app/fyle/split-expense/split-expense.page.spec.ts b/src/app/fyle/split-expense/split-expense.page.spec.ts index 7ca3c71530..97067e7893 100644 --- a/src/app/fyle/split-expense/split-expense.page.spec.ts +++ b/src/app/fyle/split-expense/split-expense.page.spec.ts @@ -109,7 +109,7 @@ import { splitExpenseDataWithCostCenter2, splitExpenseDataWithProject, splitExpenseDataWithProject2, -} from 'src/app/core/mock-data/split-expense-data'; +} from 'src/app/core/mock-data/split-expense.data'; import { LaunchDarklyService } from 'src/app/core/services/launch-darkly.service'; import { ProjectsService } from 'src/app/core/services/projects.service'; import { orgUserSettingsData } from 'src/app/core/mock-data/org-user-settings.data'; @@ -605,12 +605,14 @@ describe('SplitExpensePage', () => { describe('uploadNewFiles(): ', () => { it('should upload new files when the type is an image', (done) => { + const mockFileObjectAdv = cloneDeep(fileObjectData5); const mockFileObject = { - ...fileObjectData5, + ...mockFileObjectAdv, name: '000.jpeg', }; - const files = fileObjectAdv; - const dataUrl = fileObjectAdv[0].url; + const mockFile = cloneDeep(fileObjectAdv); + const files = mockFile; + const dataUrl = mockFile[0].url; const attachmentType = 'image'; transactionsOutboxService.fileUpload.and.resolveTo(mockFileObject); @@ -622,12 +624,13 @@ describe('SplitExpensePage', () => { }); it('should upload new files when the type is a png', (done) => { + const mockFileObjectAdv = cloneDeep(fileObjectAdv); const mockFile = { - ...fileObjectAdv[0], + ...mockFileObjectAdv[0], type: 'png', }; const files = [mockFile]; - const dataUrl = fileObjectAdv[0].url; + const dataUrl = mockFileObjectAdv[0].url; const attachmentType = 'image'; transactionsOutboxService.fileUpload.and.resolveTo(fileObjectData5); @@ -639,12 +642,13 @@ describe('SplitExpensePage', () => { }); it('should upload new files when the type is a pdf', (done) => { - const files = [fileObjectAdv1]; + const files = [cloneDeep(fileObjectAdv1)]; + const mockFileObjectAdv = cloneDeep(fileObjectData5); const mockFileObject = { - ...fileObjectData5, + ...mockFileObjectAdv, name: '000.pdf', }; - const dataUrl = fileObjectAdv1.url; + const dataUrl = files[0].url; const attachmentType = 'pdf'; transactionsOutboxService.fileUpload.and.resolveTo(mockFileObject); component.uploadNewFiles(files).subscribe((result) => { @@ -1499,8 +1503,6 @@ describe('SplitExpensePage', () => { const txnDateRes = component.setTransactionDate(mockSplitExpenseForm, '-05:00:00'); expect(txnDateRes).toEqual(mockUTCDate); - const today = new Date(); - expect(dateService.getUTCDate).toHaveBeenCalledOnceWith(today); expect(timezoneService.convertToUtc).toHaveBeenCalledOnceWith(mockDate, '-05:00:00'); }); }); @@ -2073,12 +2075,10 @@ describe('SplitExpensePage', () => { component.unspecifiedCategory = unspecifiedCategory; component.expenseFields = expenseFieldResponse; const splitEtxns = cloneDeep(txnList); - spyOn(component, 'showSplitExpensePolicyViolationsAndMissingFields').and.returnValue( - Promise.resolve({ - action: 'continue', - comments: { '0': 'test comment' }, - }) - ); + spyOn(component, 'showSplitExpensePolicyViolationsAndMissingFields').and.resolveTo({ + action: 'continue', + comments: { '0': 'test comment' }, + }); policyService.checkIfViolationsExist.and.returnValue(true); splitExpenseService.checkIfMissingFieldsExist.and.returnValue(true); splitExpenseService.handlePolicyAndMissingFieldsCheck.and.returnValue( diff --git a/src/app/fyle/team-reports/team-reports-1.page.spec.ts b/src/app/fyle/team-reports/team-reports-1.page.spec.ts index 60b551bf90..69f3d241e9 100644 --- a/src/app/fyle/team-reports/team-reports-1.page.spec.ts +++ b/src/app/fyle/team-reports/team-reports-1.page.spec.ts @@ -104,7 +104,8 @@ export function TestCases1(getTestBed) { reportService.getTeamReports.and.returnValue(of(paginatedPipeValue)); reportService.getTeamReportsCount.and.returnValue(of(20)); mockAddNewFiltersToParams = spyOn(component, 'addNewFiltersToParams'); - mockAddNewFiltersToParams.and.returnValue(tasksQueryParamsWithFiltersData); + const mockTasksQuery = cloneDeep(tasksQueryParamsWithFiltersData); + mockAddNewFiltersToParams.and.returnValue(mockTasksQuery); spyOn(component, 'generateFilterPills').and.returnValue(creditTxnFilterPill); spyOn(component, 'clearFilters'); }); diff --git a/src/app/fyle/view-team-report/view-team-report.page.spec.ts b/src/app/fyle/view-team-report/view-team-report.page.spec.ts index 454df1552d..0772b9eb9f 100644 --- a/src/app/fyle/view-team-report/view-team-report.page.spec.ts +++ b/src/app/fyle/view-team-report/view-team-report.page.spec.ts @@ -240,9 +240,9 @@ describe('ViewTeamReportPageV2', () => { }); it('loadReports(): should load reports', (done) => { - loaderService.showLoader.and.returnValue(Promise.resolve()); + loaderService.showLoader.and.resolveTo(); reportService.getReport.and.returnValue(of(expectedAllReports[0])); - loaderService.hideLoader.and.returnValue(Promise.resolve()); + loaderService.hideLoader.and.resolveTo(); component .loadReports() @@ -304,17 +304,19 @@ describe('ViewTeamReportPageV2', () => { spyOn(component, 'getApprovalSettings').and.returnValue(true); spyOn(component, 'getReportClosureSettings').and.returnValue(true); spyOn(component, 'isUserActiveInCurrentSeqApprovalQueue').and.returnValue(null); - loaderService.showLoader.and.returnValue(Promise.resolve()); + loaderService.showLoader.and.resolveTo(); spyOn(component, 'loadReports').and.returnValue(of(expectedAllReports[0])); - loaderService.hideLoader.and.returnValue(Promise.resolve()); - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - statusService.find.and.returnValue(of(newEstatusData1)); + loaderService.hideLoader.and.resolveTo(); + authService.getEou.and.resolveTo(apiEouRes); + const mockStatus = cloneDeep(newEstatusData1); + statusService.find.and.returnValue(of(mockStatus)); orgSettingsService.get.and.returnValue(of(orgSettingsData)); statusService.createStatusMap.and.returnValue(systemCommentsWithSt); reportService.getTeamReport.and.returnValue(of(expectedAllReports[0])); + const mockPdfExportData = cloneDeep(pdfExportData1); reportService.getExports.and.returnValue( of({ - results: pdfExportData1, + results: mockPdfExportData, }) ); reportService.getApproversByReportId.and.returnValue(of(approversData1)); @@ -415,17 +417,19 @@ describe('ViewTeamReportPageV2', () => { spyOn(component, 'getApprovalSettings').and.returnValue(false); spyOn(component, 'getReportClosureSettings').and.returnValue(true); spyOn(component, 'isUserActiveInCurrentSeqApprovalQueue').and.returnValue(null); - loaderService.showLoader.and.returnValue(Promise.resolve()); + loaderService.showLoader.and.resolveTo(); spyOn(component, 'loadReports').and.returnValue(of(expectedAllReports[0])); - loaderService.hideLoader.and.returnValue(Promise.resolve()); - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - statusService.find.and.returnValue(of(newEstatusData1)); + loaderService.hideLoader.and.resolveTo(); + authService.getEou.and.resolveTo(apiEouRes); + const mockStatus = cloneDeep(newEstatusData1); + statusService.find.and.returnValue(of(mockStatus)); orgSettingsService.get.and.returnValue(of(orgSettingsData)); statusService.createStatusMap.and.returnValue(systemCommentsWithSt); reportService.getTeamReport.and.returnValue(of(expectedAllReports[0])); + const mockPdfExportData = cloneDeep(pdfExportData2); reportService.getExports.and.returnValue( of({ - results: pdfExportData2, + results: mockPdfExportData, }) ); reportService.getApproversByReportId.and.returnValue(of(approversData1)); @@ -570,10 +574,10 @@ describe('ViewTeamReportPageV2', () => { }); it('deleteReport(): should delete report', async () => { - popupService.showPopup.and.returnValue(Promise.resolve('primary')); - loaderService.showLoader.and.returnValue(Promise.resolve()); + popupService.showPopup.and.resolveTo('primary'); + loaderService.showLoader.and.resolveTo(); reportService.delete.and.returnValue(of(undefined)); - loaderService.hideLoader.and.returnValue(Promise.resolve()); + loaderService.hideLoader.and.resolveTo(); await component.deleteReport(); @@ -601,15 +605,13 @@ describe('ViewTeamReportPageV2', () => { it('should open the modal and approve the report', async () => { humanizeCurrency.transform.and.callThrough(); const popoverSpy = jasmine.createSpyObj('popover', ['present', 'onWillDismiss']); - popoverSpy.onWillDismiss.and.returnValue( - Promise.resolve({ - data: { - action: 'approve', - }, - }) - ); + popoverSpy.onWillDismiss.and.resolveTo({ + data: { + action: 'approve', + }, + }); - popoverController.create.and.returnValue(Promise.resolve(popoverSpy)); + popoverController.create.and.resolveTo(popoverSpy); reportService.approve.and.returnValue(of(undefined)); refinerService.startSurvey.and.returnValue(null); @@ -745,14 +747,12 @@ describe('ViewTeamReportPageV2', () => { it('shareReport(): should open share report modal', async () => { const popoverSpy = jasmine.createSpyObj('popover', ['present', 'onWillDismiss']); - popoverSpy.onWillDismiss.and.returnValue( - Promise.resolve({ - data: { - email: 'ajn@fyle.in', - }, - }) - ); - popoverController.create.and.returnValue(Promise.resolve(popoverSpy)); + popoverSpy.onWillDismiss.and.resolveTo({ + data: { + email: 'ajn@fyle.in', + }, + }); + popoverController.create.and.resolveTo(popoverSpy); reportService.downloadSummaryPdfUrl.and.returnValue(of({ report_url: 'encodedcontent' })); @@ -780,15 +780,13 @@ describe('ViewTeamReportPageV2', () => { duration: 3000, }; const popoverSpy = jasmine.createSpyObj('popover', ['present', 'onWillDismiss']); - popoverSpy.onWillDismiss.and.returnValue( - Promise.resolve({ - data: { - comment: 'comment', - }, - }) - ); + popoverSpy.onWillDismiss.and.resolveTo({ + data: { + comment: 'comment', + }, + }); - popoverController.create.and.returnValue(Promise.resolve(popoverSpy)); + popoverController.create.and.resolveTo(popoverSpy); reportService.inquire.and.returnValue(of(undefined)); snackbarProperties.setSnackbarProperties.and.returnValue(properties); @@ -823,7 +821,7 @@ describe('ViewTeamReportPageV2', () => { it('openViewReportInfoModal(): should open report info modal', async () => { const viewInfoModalSpy = jasmine.createSpyObj('viewInfoModal', ['onWillDismiss', 'present']); - viewInfoModalSpy.onWillDismiss.and.returnValue(Promise.resolve()); + viewInfoModalSpy.onWillDismiss.and.resolveTo(); const properties = { cssClass: 'fy-modal', @@ -836,7 +834,7 @@ describe('ViewTeamReportPageV2', () => { handle: false, }; - modalController.create.and.returnValue(Promise.resolve(viewInfoModalSpy)); + modalController.create.and.resolveTo(viewInfoModalSpy); modalProperties.getModalDefaultProperties.and.returnValue(properties); await component.openViewReportInfoModal(); @@ -981,13 +979,14 @@ describe('ViewTeamReportPageV2', () => { }); it('updateReportName(): should update report name', () => { - component.erpt$ = of(newReportParam); + const mockErpt = cloneDeep(newReportParam); + component.erpt$ = of(mockErpt); fixture.detectChanges(); reportService.approverUpdateReportPurpose.and.returnValue(of(platformReportData)); spyOn(component.loadReportDetails$, 'next'); component.updateReportName('#3: Jul 2023 - Office expense'); - expect(reportService.approverUpdateReportPurpose).toHaveBeenCalledOnceWith(newReportParam); + expect(reportService.approverUpdateReportPurpose).toHaveBeenCalledOnceWith(mockErpt); expect(component.loadReportDetails$.next).toHaveBeenCalledTimes(1); }); @@ -1000,7 +999,7 @@ describe('ViewTeamReportPageV2', () => { it('should edit report name', fakeAsync(() => { const editReportNamePopoverSpy = jasmine.createSpyObj('editReportNamePopover', ['present', 'onWillDismiss']); editReportNamePopoverSpy.onWillDismiss.and.resolveTo({ data: { reportName: 'new name' } }); - popoverController.create.and.returnValue(Promise.resolve(editReportNamePopoverSpy)); + popoverController.create.and.resolveTo(editReportNamePopoverSpy); component.editReportName(); tick(100); @@ -1018,7 +1017,7 @@ describe('ViewTeamReportPageV2', () => { it('should not edit report name if data does not contain name', fakeAsync(() => { const editReportNamePopoverSpy = jasmine.createSpyObj('editReportNamePopover', ['present', 'onWillDismiss']); editReportNamePopoverSpy.onWillDismiss.and.resolveTo(); - popoverController.create.and.returnValue(Promise.resolve(editReportNamePopoverSpy)); + popoverController.create.and.resolveTo(editReportNamePopoverSpy); component.editReportName(); tick(100); diff --git a/src/app/post-verification/setup-account/setup-account.page.spec.ts b/src/app/post-verification/setup-account/setup-account.page.spec.ts index 71e83a29bc..7f4b8b8fe2 100644 --- a/src/app/post-verification/setup-account/setup-account.page.spec.ts +++ b/src/app/post-verification/setup-account/setup-account.page.spec.ts @@ -96,7 +96,7 @@ describe('SetupAccountPage', () => { networkService.connectivityWatcher.and.returnValue(new EventEmitter()); networkService.isOnline.and.returnValue(of(true)); - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); orgService.getCurrentOrg.and.returnValue(of(orgData1[0])); orgSettingsService.get.and.returnValue(of(orgSettingsRes)); orgService.setCurrencyBasedOnIp.and.returnValue(of(orgData1[0])); @@ -115,14 +115,14 @@ describe('SetupAccountPage', () => { component.setupNetworkWatcher(); component.isConnected$.pipe(take(1)).subscribe((connectionStatus) => { - expect(connectionStatus).toEqual(true); + expect(connectionStatus).toBeTrue(); }); })); it('openCurrenySelectionModal(): should open the currency select modal', fakeAsync(() => { const modalSpy = jasmine.createSpyObj('Modal', ['present', 'onWillDismiss']); - modalController.create.and.returnValue(Promise.resolve(modalSpy)); - modalSpy.onWillDismiss.and.returnValue(Promise.resolve({ data: { currency: { shortCode: 'USD' } } })); + modalController.create.and.resolveTo(modalSpy); + modalSpy.onWillDismiss.and.resolveTo({ data: { currency: { shortCode: 'USD' } } }); component.openCurrenySelectionModal(); fixture.detectChanges(); @@ -136,7 +136,8 @@ describe('SetupAccountPage', () => { it('postUser(): should update the password of the user', fakeAsync(() => { orgUserService.postUser.and.returnValue(of(postUserResponse)); - component.eou$ = of(currentEouRes); + const mockEou = cloneDeep(currentEouRes); + component.eou$ = of(mockEou); component.fg.controls.password.setValue('qwerty@123456'); const updatedEou = { id: 'usvKA4X8Ugcr', @@ -149,7 +150,7 @@ describe('SetupAccountPage', () => { }; component.postUser().subscribe(() => { expect(orgUserService.postUser).toHaveBeenCalledOnceWith(updatedEou); - expect(currentEouRes.us).toEqual(updatedEou); + expect(mockEou.us).toEqual(updatedEou); }); })); @@ -173,20 +174,22 @@ describe('SetupAccountPage', () => { describe('saveGuessedMileage():', () => { it('should set the desired mileage value if the org currency is USD', fakeAsync(() => { - orgSettingsService.get.and.returnValue(of(orgSettingsRes)); + const mockOrgSettings = cloneDeep(orgSettingsRes); + orgSettingsService.get.and.returnValue(of(mockOrgSettings)); component.org$ = of(orgData1[0]); orgSettingsService.post.and.returnValue(of(orgSettingsPostData)); component.saveGuessedMileage().subscribe(() => { - expect(orgSettingsRes.mileage.four_wheeler).toBe(0.58); - expect(orgSettingsRes.mileage.unit).toBe('MILES'); - expect(orgSettingsRes.mileage.enabled).toBe(true); - expect(orgSettingsRes.mileage.two_wheeler).toBe(0.58); + expect(mockOrgSettings.mileage.four_wheeler).toBe(0.58); + expect(mockOrgSettings.mileage.unit).toBe('MILES'); + expect(mockOrgSettings.mileage.enabled).toBeTrue(); + expect(mockOrgSettings.mileage.two_wheeler).toBe(0.58); }); - expect(orgSettingsService.post).toHaveBeenCalledOnceWith(orgSettingsRes); + expect(orgSettingsService.post).toHaveBeenCalledOnceWith(mockOrgSettings); })); it('should set the desired mileage value if the org currency is not USD', fakeAsync(() => { - orgSettingsService.get.and.returnValue(of(orgSettingsRes)); + const mockOrgSettings = cloneDeep(orgSettingsRes); + orgSettingsService.get.and.returnValue(of(mockOrgSettings)); const orgData12 = { ...orgData1[0], currency: 'INR', @@ -195,13 +198,13 @@ describe('SetupAccountPage', () => { orgSettingsService.post.and.returnValue(of(orgSettingsPostData)); component.saveGuessedMileage().subscribe(() => { fixture.detectChanges(); - expect(orgSettingsRes.mileage.four_wheeler).toBe(8.0); - expect(orgSettingsRes.mileage.unit).toBe('KM'); - expect(orgSettingsRes.mileage.enabled).toBe(true); - expect(orgSettingsRes.mileage.two_wheeler).toBe(6.0); + expect(mockOrgSettings.mileage.four_wheeler).toBe(8.0); + expect(mockOrgSettings.mileage.unit).toBe('KM'); + expect(mockOrgSettings.mileage.enabled).toBeTrue(); + expect(mockOrgSettings.mileage.two_wheeler).toBe(6.0); }); tick(500); - expect(orgSettingsService.post).toHaveBeenCalledOnceWith(orgSettingsRes); + expect(orgSettingsService.post).toHaveBeenCalledOnceWith(mockOrgSettings); })); }); @@ -211,8 +214,8 @@ describe('SetupAccountPage', () => { spyOn(component, 'postUser').and.returnValue(of(postUserResponse)); spyOn(component, 'postOrg').and.returnValue(of(orgData1[0])); spyOn(component, 'saveGuessedMileage').and.returnValue(of(orgSettingsRes)); - loaderService.showLoader.and.returnValue(Promise.resolve()); - loaderService.hideLoader.and.returnValue(Promise.resolve()); + loaderService.showLoader.and.resolveTo(); + loaderService.hideLoader.and.resolveTo(); authService.refreshEou.and.returnValue(of(eouRes3)); component.fg.setValue({ companyName: 'Acme Inc.', @@ -223,7 +226,7 @@ describe('SetupAccountPage', () => { fixture.detectChanges(); tick(500); expect(component.fg.markAllAsTouched).toHaveBeenCalledTimes(1); - expect(component.fg.valid).toBe(true); + expect(component.fg.valid).toBeTrue(); expect(loaderService.showLoader).toHaveBeenCalledTimes(1); expect(component.postUser).toHaveBeenCalledTimes(1); expect(component.postOrg).toHaveBeenCalledTimes(1); @@ -244,13 +247,13 @@ describe('SetupAccountPage', () => { }); const toastSpy = jasmine.createSpyObj('HTMLIonToastElement', ['present']); - toastSpy.present.and.returnValue(Promise.resolve()); - toastController.create.and.returnValue(Promise.resolve(toastSpy)); + toastSpy.present.and.resolveTo(); + toastController.create.and.resolveTo(toastSpy); component.saveData(); fixture.detectChanges(); tick(500); expect(component.fg.markAllAsTouched).toHaveBeenCalledTimes(1); - expect(component.fg.valid).toBe(false); + expect(component.fg.valid).toBeFalse(); expect(toastController.create).toHaveBeenCalledOnceWith({ message: 'Please fill all required fields to proceed', color: 'danger', diff --git a/src/app/shared/components/comments-history/audit-history/audit-history.component.spec.ts b/src/app/shared/components/comments-history/audit-history/audit-history.component.spec.ts index 793bc009c2..666d0d97ac 100644 --- a/src/app/shared/components/comments-history/audit-history/audit-history.component.spec.ts +++ b/src/app/shared/components/comments-history/audit-history/audit-history.component.spec.ts @@ -15,6 +15,7 @@ import { } from 'src/app/core/test-data/status.service.spec.data'; import { SnakeCaseToSpaceCase } from 'src/app/shared/pipes/snake-case-to-space-case.pipe'; import { getAllElementsBySelector, getElementBySelector, getTextContent } from 'src/app/core/dom-helpers'; +import { cloneDeep } from 'lodash'; describe('AuditHistoryComponent', () => { let component: AuditHistoryComponent; @@ -37,7 +38,8 @@ describe('AuditHistoryComponent', () => { component = fixture.componentInstance; expenseFieldsService = TestBed.inject(ExpenseFieldsService) as jasmine.SpyObj; expenseFieldsService.getAllEnabled.and.returnValue(of(transformedResponse2)); - component.estatuses = estatusSample; + const mockEstatuses = cloneDeep(estatusSample); + component.estatuses = mockEstatuses; spyOn(component, 'hasDetails').and.callThrough(); spyOn(component, 'getAndUpdateProjectName').and.callThrough(); spyOn(component, 'setReimbursable').and.callThrough(); @@ -66,7 +68,7 @@ describe('AuditHistoryComponent', () => { }); it('updateProjectNameKey(): should update project name', () => { - component.estatuses = eStatusWithProjectName; + component.estatuses = cloneDeep(eStatusWithProjectName); fixture.detectChanges(); component.updateProjectNameKey(); @@ -75,7 +77,7 @@ describe('AuditHistoryComponent', () => { }); it('updateProjectNameKey(): should update project name if it already exists', () => { - component.estatuses = eStatusWithProjectName2; + component.estatuses = cloneDeep(eStatusWithProjectName2); fixture.detectChanges(); component.updateProjectNameKey(); @@ -96,7 +98,7 @@ describe('AuditHistoryComponent', () => { }); it('setReimbursable(): should set re-imbursable', () => { - component.estatuses = eStatusWithReimbursible; + component.estatuses = cloneDeep(eStatusWithReimbursible); fixture.detectChanges(); component.setReimbursable(); diff --git a/src/app/shared/components/comments-history/view-comment/view-comment.component.spec.ts b/src/app/shared/components/comments-history/view-comment/view-comment.component.spec.ts index 83c95ff2af..50362b72ab 100644 --- a/src/app/shared/components/comments-history/view-comment/view-comment.component.spec.ts +++ b/src/app/shared/components/comments-history/view-comment/view-comment.component.spec.ts @@ -20,6 +20,7 @@ import { getEstatusApiResponse, updateReponseWithFlattenedEStatus, } from 'src/app/core/test-data/status.service.spec.data'; +import { cloneDeep } from 'lodash'; describe('ViewCommentComponent', () => { let component: ViewCommentComponent; @@ -60,17 +61,18 @@ describe('ViewCommentComponent', () => { ], }).compileComponents(); - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); - statusService.find.and.returnValue(of(apiCommentsResponse)); - statusService.createStatusMap.and.returnValue(updateReponseWithFlattenedEStatus); + authService.getEou.and.resolveTo(apiEouRes); + const mockCommentResponse = cloneDeep(apiCommentsResponse); + statusService.find.and.returnValue(of(mockCommentResponse)); + const mockStatusMap = cloneDeep(updateReponseWithFlattenedEStatus); + statusService.createStatusMap.and.returnValue(mockStatusMap); fixture = TestBed.createComponent(ViewCommentComponent); component = fixture.componentInstance; - component.estatuses$ = of(apiCommentsResponse); + component.estatuses$ = of(mockCommentResponse); component.objectType = 'transactions'; component.objectId = 'tx1oTNwgRdRq'; component.newComment = 'This is a new comment'; - fixture.detectChanges(); })); it('should create', () => { @@ -82,6 +84,7 @@ describe('ViewCommentComponent', () => { const data = { comment: newComment }; component.newComment = newComment; statusService.post.and.returnValue(of(null)); + fixture.detectChanges(); const focusSpy = spyOn(component.commentInput.nativeElement, 'focus'); component.addComment(); @@ -95,8 +98,8 @@ describe('ViewCommentComponent', () => { describe('closeCommentModal():', () => { it('should close the modal if the comment is discarded', fakeAsync(() => { const popOverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onWillDismiss']); - popoverController.create.and.returnValue(Promise.resolve(popOverSpy)); - popOverSpy.onWillDismiss.and.returnValue(Promise.resolve({ data: { action: 'discard' } })); + popoverController.create.and.resolveTo(popOverSpy); + popOverSpy.onWillDismiss.and.resolveTo({ data: { action: 'discard' } }); component.closeCommentModal(); tick(500); expect(popoverController.create).toHaveBeenCalledOnceWith({ @@ -124,7 +127,7 @@ describe('ViewCommentComponent', () => { component.newComment = null; component.isCommentAdded = true; component.closeCommentModal(); - modalController.dismiss.and.returnValue(Promise.resolve({ data: { updated: true } } as any)); + modalController.dismiss.and.resolveTo({ data: { updated: true } } as any); expect(modalController.dismiss).toHaveBeenCalled(); expect(trackingService.addComment).toHaveBeenCalledTimes(1); }); @@ -133,7 +136,7 @@ describe('ViewCommentComponent', () => { component.newComment = null; component.isCommentAdded = false; component.closeCommentModal(); - modalController.dismiss.and.returnValue(Promise.resolve(Promise.resolve({ data: { updated: false } } as any))); + modalController.dismiss.and.resolveTo({ data: { updated: false } } as any); expect(modalController.dismiss).toHaveBeenCalled(); expect(trackingService.viewComment).toHaveBeenCalledTimes(1); }); @@ -213,8 +216,9 @@ describe('ViewCommentComponent', () => { st_org_user_id: 'POLICY', })); + spyOn(component, 'setContentScrollToBottom'); const totalCommentsCount = 33; - authService.getEou.and.returnValue(Promise.resolve(apiEouRes)); + authService.getEou.and.resolveTo(apiEouRes); statusService.find.and.returnValue(of(updatedApiCommentsResponse)); statusService.createStatusMap.and.returnValue(updateReponseWithFlattenedEStatus); component.ngOnInit(); @@ -236,6 +240,7 @@ describe('ViewCommentComponent', () => { })); it('should set type correctly for a given objectType', fakeAsync(() => { + spyOn(component, 'setContentScrollToBottom'); component.objectType = 'Expenses'; component.ngOnInit(); tick(500); diff --git a/src/app/shared/components/comments-history/view-comment/view-comment.component.ts b/src/app/shared/components/comments-history/view-comment/view-comment.component.ts index 7a43d405f2..44d45ba278 100644 --- a/src/app/shared/components/comments-history/view-comment/view-comment.component.ts +++ b/src/app/shared/components/comments-history/view-comment/view-comment.component.ts @@ -60,6 +60,10 @@ export class ViewCommentComponent implements OnInit { public platform: Platform ) {} + setContentScrollToBottom(): void { + this.content.scrollToBottom(500); + } + addComment() { if (this.newComment) { const data = { @@ -170,7 +174,7 @@ export class ViewCommentComponent implements OnInit { map((res) => res.sort((a, b) => a.st_created_at.valueOf() - b.st_created_at.valueOf())), finalize(() => { setTimeout(() => { - this.content.scrollToBottom(500); + this.setContentScrollToBottom(); }, 500); }) ) diff --git a/src/app/shared/components/expenses-card-v2/expenses-card.component.spec.ts b/src/app/shared/components/expenses-card-v2/expenses-card.component.spec.ts index 554478303e..668f73f16c 100644 --- a/src/app/shared/components/expenses-card-v2/expenses-card.component.spec.ts +++ b/src/app/shared/components/expenses-card-v2/expenses-card.component.spec.ts @@ -275,7 +275,7 @@ describe('ExpensesCardComponent', () => { }; component.getReceipt(); fixture.detectChanges(); - expect(component.isReceiptPresent).toBe(true); + expect(component.isReceiptPresent).toBeTrue(); }); }); @@ -629,10 +629,11 @@ describe('ExpensesCardComponent', () => { }); it('matchReceiptWithEtxn(): match the receipt with the transactions', () => { - component.matchReceiptWithEtxn(fileObjectData); + const mockFileObject = cloneDeep(fileObjectData); + component.matchReceiptWithEtxn(mockFileObject); expect(component.expense.file_ids).toBeDefined(); - expect(component.expense.file_ids).toContain(fileObjectData.id); - expect(fileObjectData.transaction_id).toBe(component.expense.id); + expect(component.expense.file_ids).toContain(mockFileObject.id); + expect(mockFileObject.transaction_id).toBe(component.expense.id); }); describe('canAddAttchment():', () => { @@ -679,7 +680,7 @@ describe('ExpensesCardComponent', () => { }; fileService.getAttachmentType.and.returnValue(attachmentType); - transactionsOutboxService.fileUpload.and.returnValue(Promise.resolve(fileObj)); + transactionsOutboxService.fileUpload.and.resolveTo(fileObj); fileService.post.and.returnValue(of(fileObjectData)); spyOn(component, 'matchReceiptWithEtxn').and.callThrough(); @@ -700,7 +701,7 @@ describe('ExpensesCardComponent', () => { it('should add attachment when file is selected', fakeAsync(() => { const dataUrl = 'data:image/jpeg;base64,/9j/4AAQSkZJRg...'; const mockFile = new File(['file contents'], 'test.png', { type: 'image/png' }); - fileService.readFile.and.returnValue(Promise.resolve(dataUrl)); + fileService.readFile.and.resolveTo(dataUrl); const mockNativeElement = { files: [mockFile], }; @@ -735,7 +736,7 @@ describe('ExpensesCardComponent', () => { it('showSizeLimitExceededPopover', fakeAsync(() => { const popOverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present']); - popoverController.create.and.returnValue(Promise.resolve(popOverSpy)); + popoverController.create.and.resolveTo(popOverSpy); component.showSizeLimitExceededPopover(); tick(500); @@ -794,8 +795,8 @@ describe('ExpensesCardComponent', () => { }; spyOn(component, 'canAddAttachment').and.returnValue(true); const popOverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onWillDismiss']); - popoverController.create.and.returnValue(Promise.resolve(popOverSpy)); - popOverSpy.onWillDismiss.and.returnValue(Promise.resolve(receiptDetails)); + popoverController.create.and.resolveTo(popOverSpy); + popOverSpy.onWillDismiss.and.resolveTo(receiptDetails); component.addAttachments(event as any); fixture.detectChanges(); @@ -833,11 +834,11 @@ describe('ExpensesCardComponent', () => { spyOn(component, 'attachReceipt'); spyOn(component, 'canAddAttachment').and.returnValue(true); const popOverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onWillDismiss']); - popoverController.create.and.returnValue(Promise.resolve(popOverSpy)); - popOverSpy.onWillDismiss.and.returnValue(Promise.resolve(dataRes)); + popoverController.create.and.resolveTo(popOverSpy); + popOverSpy.onWillDismiss.and.resolveTo(dataRes); const captureReceiptModalSpy = jasmine.createSpyObj('HTMLIonModalElement', ['present', 'onWillDismiss']); - modalController.create.and.returnValue(Promise.resolve(captureReceiptModalSpy)); - captureReceiptModalSpy.onWillDismiss.and.returnValue(Promise.resolve(dataRes)); + modalController.create.and.resolveTo(captureReceiptModalSpy); + captureReceiptModalSpy.onWillDismiss.and.resolveTo(dataRes); fileService.getImageTypeFromDataUrl.and.returnValue('png'); component.addAttachments(event as any); @@ -878,7 +879,7 @@ describe('ExpensesCardComponent', () => { component.setupNetworkWatcher(); component.isConnected$.pipe(take(1)).subscribe((connectionStatus) => { - expect(connectionStatus).toEqual(true); + expect(connectionStatus).toBeTrue(); }); })); diff --git a/src/app/shared/components/expenses-card/expenses-card.component.spec.ts b/src/app/shared/components/expenses-card/expenses-card.component.spec.ts index 65dbc23f1e..4c890152c8 100644 --- a/src/app/shared/components/expenses-card/expenses-card.component.spec.ts +++ b/src/app/shared/components/expenses-card/expenses-card.component.spec.ts @@ -602,10 +602,11 @@ describe('ExpensesCardComponent', () => { }); it('matchReceiptWithEtxn(): match the receipt with the transactions', () => { - component.matchReceiptWithEtxn(fileObjectData); + const mockFileObj = cloneDeep(fileObjectData); + component.matchReceiptWithEtxn(mockFileObj); expect(component.expense.tx_file_ids).toBeDefined(); - expect(component.expense.tx_file_ids).toContain(fileObjectData.id); - expect(fileObjectData.transaction_id).toBe(component.expense.tx_id); + expect(component.expense.tx_file_ids).toContain(mockFileObj.id); + expect(mockFileObj.transaction_id).toBe(component.expense.tx_id); }); describe('canAddAttchment():', () => { @@ -652,7 +653,7 @@ describe('ExpensesCardComponent', () => { }; fileService.getAttachmentType.and.returnValue(attachmentType); - transactionsOutboxService.fileUpload.and.returnValue(Promise.resolve(fileObj)); + transactionsOutboxService.fileUpload.and.resolveTo(fileObj); fileService.post.and.returnValue(of(fileObjectData)); spyOn(component, 'matchReceiptWithEtxn').and.callThrough(); @@ -672,7 +673,7 @@ describe('ExpensesCardComponent', () => { it('onFileUpload(): should add attachment when file is selected', fakeAsync(() => { const dataUrl = 'data:image/jpeg;base64,/9j/4AAQSkZJRg...'; const mockFile = new File(['file contents'], 'test.png', { type: 'image/png' }); - fileService.readFile.and.returnValue(Promise.resolve(dataUrl)); + fileService.readFile.and.resolveTo(dataUrl); const mockNativeElement = { files: [mockFile], }; @@ -731,8 +732,8 @@ describe('ExpensesCardComponent', () => { }; spyOn(component, 'canAddAttachment').and.returnValue(true); const popOverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onWillDismiss']); - popoverController.create.and.returnValue(Promise.resolve(popOverSpy)); - popOverSpy.onWillDismiss.and.returnValue(Promise.resolve(receiptDetails)); + popoverController.create.and.resolveTo(popOverSpy); + popOverSpy.onWillDismiss.and.resolveTo(receiptDetails); component.addAttachments(event as any); fixture.detectChanges(); @@ -770,11 +771,11 @@ describe('ExpensesCardComponent', () => { spyOn(component, 'attachReceipt'); spyOn(component, 'canAddAttachment').and.returnValue(true); const popOverSpy = jasmine.createSpyObj('HTMLIonPopoverElement', ['present', 'onWillDismiss']); - popoverController.create.and.returnValue(Promise.resolve(popOverSpy)); - popOverSpy.onWillDismiss.and.returnValue(Promise.resolve(dataRes)); + popoverController.create.and.resolveTo(popOverSpy); + popOverSpy.onWillDismiss.and.resolveTo(dataRes); const captureReceiptModalSpy = jasmine.createSpyObj('HTMLIonModalElement', ['present', 'onWillDismiss']); - modalController.create.and.returnValue(Promise.resolve(captureReceiptModalSpy)); - captureReceiptModalSpy.onWillDismiss.and.returnValue(Promise.resolve(dataRes)); + modalController.create.and.resolveTo(captureReceiptModalSpy); + captureReceiptModalSpy.onWillDismiss.and.resolveTo(dataRes); fileService.getImageTypeFromDataUrl.and.returnValue('png'); component.addAttachments(event as any); @@ -815,7 +816,7 @@ describe('ExpensesCardComponent', () => { component.setupNetworkWatcher(); component.isConnected$.pipe(take(1)).subscribe((connectionStatus) => { - expect(connectionStatus).toEqual(true); + expect(connectionStatus).toBeTrue(); }); })); diff --git a/src/app/shared/components/fy-approver/add-approvers-popover/approver-dialog/approver-dialog.component.spec.ts b/src/app/shared/components/fy-approver/add-approvers-popover/approver-dialog/approver-dialog.component.spec.ts index 874627d7d6..3494038d7d 100644 --- a/src/app/shared/components/fy-approver/add-approvers-popover/approver-dialog/approver-dialog.component.spec.ts +++ b/src/app/shared/components/fy-approver/add-approvers-popover/approver-dialog/approver-dialog.component.spec.ts @@ -12,6 +12,7 @@ import { of } from 'rxjs'; import { employeesParamsRes } from 'src/app/core/test-data/org-user.service.spec.data'; import { MatCheckboxModule } from '@angular/material/checkbox'; import { click, getAllElementsBySelector, getElementBySelector, getTextContent } from 'src/app/core/dom-helpers'; +import { cloneDeep } from 'lodash'; describe('ApproverDialogComponent', () => { let component: ApproverDialogComponent; @@ -91,13 +92,14 @@ describe('ApproverDialogComponent', () => { orgUserService = TestBed.inject(OrgUserService) as jasmine.SpyObj; loaderService = TestBed.inject(LoaderService) as jasmine.SpyObj; - component.initialApproverList = approvers; + component.initialApproverList = cloneDeep(approvers); component.approverEmailsList = ['jay.b@fyle.in', 'ajain@fyle.in']; - orgUserService.getEmployeesBySearch.and.returnValue(of(employeesParamsRes.data)); - loaderService.showLoader.and.returnValue(Promise.resolve(null)); - loaderService.hideLoader.and.returnValue(Promise.resolve(null)); + const employeesData = cloneDeep(employeesParamsRes.data); + orgUserService.getEmployeesBySearch.and.returnValue(of(employeesData)); + loaderService.showLoader.and.resolveTo(null); + loaderService.hideLoader.and.resolveTo(null); fixture.detectChanges(); })); @@ -162,7 +164,7 @@ describe('ApproverDialogComponent', () => { expect(component.getSelectedApproversDict).toHaveBeenCalledTimes(1); expect(component.selectedApproversList.length).toEqual(3); - expect(component.areApproversAdded).toEqual(false); + expect(component.areApproversAdded).toBeFalse(); }); it('should remove an unchecked approver', () => { @@ -191,7 +193,7 @@ describe('ApproverDialogComponent', () => { expect(component.getSelectedApproversDict).toHaveBeenCalledTimes(1); expect(component.selectedApproversList.length).toEqual(0); - expect(component.areApproversAdded).toEqual(true); + expect(component.areApproversAdded).toBeTrue(); }); }); @@ -211,8 +213,8 @@ describe('ApproverDialogComponent', () => { describe('getDefaultUsersList():', () => { it(' should get default user list', fakeAsync(() => { orgUserService.getEmployeesBySearch.and.returnValue(of(employeesParamsRes.data)); - loaderService.showLoader.and.returnValue(Promise.resolve(null)); - loaderService.hideLoader.and.returnValue(Promise.resolve(null)); + loaderService.showLoader.and.resolveTo(null); + loaderService.hideLoader.and.resolveTo(null); const params = { order: 'us_full_name.asc,us_email.asc,ou_id', @@ -229,8 +231,8 @@ describe('ApproverDialogComponent', () => { it('if approver email list is empty', () => { component.approverEmailsList = []; orgUserService.getEmployeesBySearch.and.returnValue(of(employeesParamsRes.data)); - loaderService.showLoader.and.returnValue(Promise.resolve(null)); - loaderService.hideLoader.and.returnValue(Promise.resolve(null)); + loaderService.showLoader.and.resolveTo(null); + loaderService.hideLoader.and.resolveTo(null); fixture.detectChanges(); const params = { @@ -247,7 +249,8 @@ describe('ApproverDialogComponent', () => { }); it('getSearchedUsersList(): get users list from search text', (done) => { - orgUserService.getEmployeesBySearch.and.returnValue(of(employeesParamsRes.data)); + const employeesData = cloneDeep(employeesParamsRes.data); + orgUserService.getEmployeesBySearch.and.returnValue(of(employeesData)); component.getSearchedUsersList('text').subscribe((res) => { expect(res).toEqual([ diff --git a/src/app/shared/components/fy-userlist/fy-userlist-modal/fy-userlist-modal.component.spec.ts b/src/app/shared/components/fy-userlist/fy-userlist-modal/fy-userlist-modal.component.spec.ts index 65ef7f4c97..147cac8a64 100644 --- a/src/app/shared/components/fy-userlist/fy-userlist-modal/fy-userlist-modal.component.spec.ts +++ b/src/app/shared/components/fy-userlist/fy-userlist-modal/fy-userlist-modal.component.spec.ts @@ -21,6 +21,7 @@ import { MatCheckboxModule } from '@angular/material/checkbox'; import { getElementBySelector } from 'src/app/core/dom-helpers'; import { Employee } from 'src/app/core/models/spender/employee.model'; import { By } from '@angular/platform-browser'; +import { cloneDeep } from 'lodash'; describe('FyUserlistModalComponent', () => { let component: FyUserlistModalComponent; @@ -59,18 +60,19 @@ describe('FyUserlistModalComponent', () => { orgUserService = TestBed.inject(OrgUserService) as jasmine.SpyObj; loaderService = TestBed.inject(LoaderService) as jasmine.SpyObj; - orgUserService.getEmployeesBySearch.and.returnValue(of(employeesParamsRes.data)); + const employeesData = cloneDeep(employeesRes.data); + orgUserService.getEmployeesBySearch.and.returnValue(of(employeesData)); fixture = TestBed.createComponent(FyUserlistModalComponent); component = fixture.componentInstance; component.value = 'test value'; - component.currentSelections = [ + component.currentSelections = cloneDeep([ 'ajain+12+12+1@fyle.in', 'ajain+12121212@fyle.in', 'aaaaaaa@aaaabbbb.com', 'aaaaasdjskjd@sdsd.com', 'kawaljeet.ravi22@gmail.com', 'abcdefg@somemail.com', - ]; + ]); fixture.detectChanges(); })); @@ -191,7 +193,8 @@ describe('FyUserlistModalComponent', () => { 'in.(ajain+12+12+1@fyle.in,ajain+12121212@fyle.in,aaaaaaa@aaaabbbb.com,aaaaasdjskjd@sdsd.com,kawaljeet.ravi22@gmail.com,abcdefg@somemail.com)', }; - orgUserService.getEmployeesBySearch.and.returnValue(of(employeesParamsRes.data)); + const employeesData = cloneDeep(employeesParamsRes.data); + orgUserService.getEmployeesBySearch.and.returnValue(of(employeesData)); component.getDefaultUsersList().subscribe((res) => { fixture.detectChanges(); expect(res).toEqual(searchedUserListRes); @@ -213,12 +216,13 @@ describe('FyUserlistModalComponent', () => { }); it('getSearchedUsersList(): should get the searched user list', fakeAsync(() => { - const params: any = { + const params = { limit: 20, order: 'us_full_name.asc,us_email.asc,ou_id', or: '(us_email.ilike.*ajain+12+12+1@fyle.in*,us_full_name.ilike.*ajain+12+12+1@fyle.in*)', }; - orgUserService.getEmployeesBySearch.and.returnValue(of(employeesParamsRes.data)); + const employeesData = cloneDeep(employeesParamsRes.data); + orgUserService.getEmployeesBySearch.and.returnValue(of(employeesData)); component.getSearchedUsersList('ajain+12+12+1@fyle.in').subscribe((res) => { fixture.detectChanges(); expect(res).toEqual(searchedUserListRes); @@ -295,24 +299,27 @@ describe('FyUserlistModalComponent', () => { describe('getUsersList():', () => { it('should return searched user list if searchText is provided', fakeAsync(() => { const searchText = 'ajain'; - const getSearchedUsersListSpy = spyOn(component, 'getSearchedUsersList').and.returnValue(of(searchedUserListRes)); + const mockUsersList = cloneDeep(searchedUserListRes); + const getSearchedUsersListSpy = spyOn(component, 'getSearchedUsersList').and.returnValue(of(mockUsersList)); const result$ = component.getUsersList(searchText); fixture.detectChanges(); expect(component.isLoading).toBeTrue(); expect(getSearchedUsersListSpy).toHaveBeenCalledOnceWith(searchText); result$.subscribe((res) => { - expect(res).toEqual(searchedUserListRes); + expect(res).toEqual(mockUsersList); }); tick(500); })); it('should return default users list if searchText is not provided', fakeAsync(() => { - const getDefaultUserListSpy = spyOn(component, 'getDefaultUsersList').and.returnValue(of(searchedUserListRes)); + const mockUsersList = cloneDeep(searchedUserListRes); + spyOn(component, 'getSearchedUsersList').and.returnValue(of([])); + const getDefaultUserListSpy = spyOn(component, 'getDefaultUsersList').and.returnValue(of(mockUsersList)); const result$ = component.getUsersList(''); fixture.detectChanges(); result$.subscribe((res) => { expect(component.isLoading).toBeTrue(); - expect(res).toEqual(searchedUserListRes); + expect(res).toEqual(mockUsersList); expect(getDefaultUserListSpy).toHaveBeenCalledTimes(1); }); tick(500); diff --git a/src/app/shared/components/route-selector/route-selector.component.spec.ts b/src/app/shared/components/route-selector/route-selector.component.spec.ts index 851a46d397..c76bc2f508 100644 --- a/src/app/shared/components/route-selector/route-selector.component.spec.ts +++ b/src/app/shared/components/route-selector/route-selector.component.spec.ts @@ -14,6 +14,7 @@ import { MatIconTestingModule } from '@angular/material/icon/testing'; import { MatIconModule } from '@angular/material/icon'; import { click, getElementBySelector, getTextContent } from 'src/app/core/dom-helpers'; import { By } from '@angular/platform-browser'; +import { cloneDeep } from 'lodash'; describe('RouteSelectorComponent', () => { let component: RouteSelectorComponent; @@ -44,7 +45,8 @@ describe('RouteSelectorComponent', () => { component = fixture.componentInstance; fb = TestBed.inject(FormBuilder) as jasmine.SpyObj; modalController = TestBed.inject(ModalController) as jasmine.SpyObj; - component.mileageConfig = orgSettingsRes.mileage; + const mockOrgSettings = cloneDeep(orgSettingsRes); + component.mileageConfig = mockOrgSettings.mileage; component.formInitialized = true; component.onChangeSub = of(null).subscribe(); component.form = fb.group({ @@ -92,7 +94,7 @@ describe('RouteSelectorComponent', () => { }); expect(component.mileageLocations.length).toEqual(mileageLocationData1.length); expect(component.form.controls.distance.value).toEqual(20.0); - expect(component.form.controls.roundTrip.value).toEqual(true); + expect(component.form.controls.roundTrip.value).toBeTrue(); }); it('writeValue(): should write value to the form group', () => { @@ -261,7 +263,8 @@ describe('RouteSelectorComponent', () => { describe('onTxnFieldsChange():', () => { beforeEach(() => { spyOn(component, 'ngOnChanges'); - component.txnFields = expenseFieldsMapResponse3; + const mockExpenseFieldsMapResponse = cloneDeep(expenseFieldsMapResponse3); + component.txnFields = mockExpenseFieldsMapResponse; }); it('should update form validators', () => { diff --git a/src/app/shared/components/sidemenu/sidemenu-content/sidemenu-content.component.spec.ts b/src/app/shared/components/sidemenu/sidemenu-content/sidemenu-content.component.spec.ts index c92db1adcb..08ff944861 100644 --- a/src/app/shared/components/sidemenu/sidemenu-content/sidemenu-content.component.spec.ts +++ b/src/app/shared/components/sidemenu/sidemenu-content/sidemenu-content.component.spec.ts @@ -14,6 +14,7 @@ import { sidemenuItemData4, } from 'src/app/core/mock-data/sidemenu-item.data'; import { globalCacheBusterNotifier } from 'ts-cacheable'; +import { cloneDeep } from 'lodash'; describe('SidemenuContentComponent', () => { let component: SidemenuContentComponent; @@ -68,23 +69,25 @@ describe('SidemenuContentComponent', () => { describe('goToRoute():', () => { it('should call trackingService.menuItemClicked with correct argument', () => { - component.goToRoute(sidemenuItemData1); + const mockSideMenuItemData = cloneDeep(sidemenuItemData1); + component.goToRoute(mockSideMenuItemData); fixture.detectChanges(); - expect(trackingService.menuItemClicked).toHaveBeenCalledOnceWith({ option: sidemenuItemData1.title }); + expect(trackingService.menuItemClicked).toHaveBeenCalledOnceWith({ option: mockSideMenuItemData.title }); }); it('should toggle isDropdownOpen property when sidemenu item has dropdown options', () => { - component.goToRoute(sidemenuItemData2); + const mockSideMenuItemData = cloneDeep(sidemenuItemData2); + component.goToRoute(mockSideMenuItemData); fixture.detectChanges(); - expect(sidemenuItemData2.isDropdownOpen).toBe(true); // initial click should open dropdown - component.goToRoute(sidemenuItemData2); + expect(mockSideMenuItemData.isDropdownOpen).toBeTrue(); // initial click should open dropdown + component.goToRoute(mockSideMenuItemData); fixture.detectChanges(); - expect(sidemenuItemData2.isDropdownOpen).toBe(false); // second click should close dropdown + expect(mockSideMenuItemData.isDropdownOpen).toBeFalse(); // second click should close dropdown }); it('should close the menucontroller when sidemenu item does not have dropdown options', () => { component.goToRoute(sidemenuItemData1); - expect(sidemenuItemData2.isDropdownOpen).toBe(false); + expect(sidemenuItemData2.isDropdownOpen).toBeFalse(); expect(menuController.close).toHaveBeenCalledTimes(1); }); diff --git a/src/app/shared/components/virtual-select/virtual-select-modal/virtual-select-modal.component.spec.ts b/src/app/shared/components/virtual-select/virtual-select-modal/virtual-select-modal.component.spec.ts index a529b49459..d5f808a238 100644 --- a/src/app/shared/components/virtual-select/virtual-select-modal/virtual-select-modal.component.spec.ts +++ b/src/app/shared/components/virtual-select/virtual-select-modal/virtual-select-modal.component.spec.ts @@ -197,7 +197,7 @@ describe('VirtualSelectModalComponent', () => { it('onElementSelect(): should call recentlocalstorage service and dismiss the modal', () => { component.cacheName = 'cache1'; - const option = virtualSelectOptionData4[1]; + const option = cloneDeep(virtualSelectOptionData4[1]); component.onElementSelect(option); expect(recentLocalStorageItemsService.post).toHaveBeenCalledOnceWith('cache1', option, 'label'); expect(modalController.dismiss).toHaveBeenCalledOnceWith(option);