Skip to content

Commit

Permalink
feat: added deepFreeze to not pollute global mock data - Part 9
Browse files Browse the repository at this point in the history
  • Loading branch information
suyashpatil78 committed Apr 30, 2024
1 parent 109280f commit f5e0051
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 208 deletions.
58 changes: 30 additions & 28 deletions src/app/core/mock-data/parsed-receipt.data.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -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',
Expand All @@ -175,4 +177,4 @@ export const instaFyleData5 = {
vendor_name: 'vendor',
},
exchangeRate: null,
};
});
10 changes: 6 additions & 4 deletions src/app/core/mock-data/pdf-export.data.ts
Original file line number Diff line number Diff line change
@@ -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: '[email protected]',
Expand Down Expand Up @@ -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: '[email protected]',
Expand Down Expand Up @@ -134,4 +136,4 @@ export const pdfExportData2: PdfExport[] = [
column_mappings: null,
batch_size: null,
},
];
]);
10 changes: 6 additions & 4 deletions src/app/core/mock-data/per-diem-custom-inputs.data.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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 }) => ({
Expand All @@ -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,
Expand Down Expand Up @@ -132,4 +134,4 @@ export const perDiemCustomInputsData2: PerDiemCustomInputs[] = [
value: '',
}),
},
];
]);
42 changes: 22 additions & 20 deletions src/app/core/mock-data/per-diem-form-value.data.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<PerDiemFormValue> = {
export const perDiemFormValuesData1: Partial<PerDiemFormValue> = deepFreeze({
paymentMode: multiplePaymentModesData[0],
sub_category: undefined,
per_diem_rate: null,
Expand All @@ -22,14 +24,14 @@ export const perDiemFormValuesData1: Partial<PerDiemFormValue> = {
custom_inputs: [],
project_dependent_fields: [],
cost_center_dependent_fields: [],
};
});

export const perDiemFormValuesData2: Partial<PerDiemFormValue> = {
export const perDiemFormValuesData2: Partial<PerDiemFormValue> = deepFreeze({
...perDiemFormValuesData1,
project: null,
};
});

export const perDiemFormValuesData3: Partial<PerDiemFormValue> = {
export const perDiemFormValuesData3: Partial<PerDiemFormValue> = deepFreeze({
...perDiemFormValuesData1,
per_diem_rate: {
active: true,
Expand All @@ -43,31 +45,31 @@ export const perDiemFormValuesData3: Partial<PerDiemFormValue> = {
full_name: 'BulkTest2 (50 USD per day)',
readableRate: '$50.00 per day',
},
};
});

export const perDiemFormValuesData4: Partial<PerDiemFormValue> = {
export const perDiemFormValuesData4: Partial<PerDiemFormValue> = deepFreeze({
...perDiemFormValuesData1,
report: expectedReportsPaginated[0],
};
});

export const perDiemFormValuesData5: Partial<PerDiemFormValue> = {
export const perDiemFormValuesData5: Partial<PerDiemFormValue> = deepFreeze({
...perDiemFormValuesData1,
report: expectedReportsPaginated[0],
};
});

export const perDiemFormValuesData6: Partial<PerDiemFormValue> = {
export const perDiemFormValuesData6: Partial<PerDiemFormValue> = deepFreeze({
...perDiemFormValuesData1,
costCenter: expectedCCdata3[0].value,
};
});

export const perDiemFormValuesData7: Partial<PerDiemFormValue> = {
export const perDiemFormValuesData7: Partial<PerDiemFormValue> = 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],
Expand Down Expand Up @@ -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,
Expand All @@ -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: [
{
Expand Down Expand Up @@ -143,4 +145,4 @@ export const perDiemFormValuesData10: PerDiemFormValue = {
displayValue: null,
},
],
};
});
10 changes: 6 additions & 4 deletions src/app/core/mock-data/per-diem-rates.data.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand All @@ -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',
};
});
10 changes: 6 additions & 4 deletions src/app/core/mock-data/personal-card-txns.data.ts
Original file line number Diff line number Diff line change
@@ -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<PersonalCardTxn> = {
export const apiPersonalCardTxnsRes: ApiV2Response<PersonalCardTxn> = deepFreeze({
count: 1,
data: [
{
Expand Down Expand Up @@ -33,9 +35,9 @@ export const apiPersonalCardTxnsRes: ApiV2Response<PersonalCardTxn> = {
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',
Expand Down Expand Up @@ -76,4 +78,4 @@ export const matchedPersonalCardTxn: PersonalCardTxn = {
vendor_name: 'Office & Shipping',
},
],
};
});
Loading

0 comments on commit f5e0051

Please sign in to comment.