@managesome/eposmatic-toolkit 0.2.692 → 0.2.693
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/helpers/types/halfhalf.d.ts +23 -0
- package/lib/helpers/types/halfhalf.js +2 -0
- package/lib/helpers/types/index.d.ts +2 -0
- package/lib/helpers/types/index.js +2 -0
- package/lib/helpers/types/specials.d.ts +27 -0
- package/lib/helpers/types/specials.js +2 -0
- package/lib/helpers/utils/index.d.ts +2 -0
- package/lib/helpers/utils/index.js +2 -0
- package/lib/helpers/utils/simplified-halfhalf.d.ts +4 -0
- package/lib/helpers/utils/simplified-halfhalf.js +28 -0
- package/lib/helpers/utils/simplified-specials.d.ts +4 -0
- package/lib/helpers/utils/simplified-specials.js +32 -0
- package/lib/tests/simplified-halfhalf.test.d.ts +1 -0
- package/lib/tests/simplified-halfhalf.test.js +79 -0
- package/lib/tests/simplified-specials.test.d.ts +1 -0
- package/lib/tests/simplified-specials.test.js +85 -0
- package/package.json +1 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { PLATFORMS_ENUM } from '../../constants';
|
|
2
|
+
import { IMinifiedItemSpecialHour, IMinifiedPrice } from './catalog';
|
|
3
|
+
/**
|
|
4
|
+
* Simplified wire representation of a halfhalf setup (mirrors ISimplifiedItem).
|
|
5
|
+
*
|
|
6
|
+
* - Prices are minified (IMinifiedPrice: number | IPrice | null | undefined).
|
|
7
|
+
* - sold_out is a per-tenant boolean (replaces string[]).
|
|
8
|
+
* - Simplified halfhalf items expose only menu-list data: no segments, no
|
|
9
|
+
* constituent items, and no ref rules.
|
|
10
|
+
*/
|
|
11
|
+
export interface ISimplifiedHalfHalfSetup {
|
|
12
|
+
sold_out?: boolean;
|
|
13
|
+
is_discount_percentage?: boolean;
|
|
14
|
+
discount_amount?: IMinifiedPrice;
|
|
15
|
+
item_special_hours?: IMinifiedItemSpecialHour[];
|
|
16
|
+
_id: string;
|
|
17
|
+
category_id: string;
|
|
18
|
+
name: string;
|
|
19
|
+
included_platforms: PLATFORMS_ENUM[];
|
|
20
|
+
description: string;
|
|
21
|
+
active: boolean;
|
|
22
|
+
image_url: string;
|
|
23
|
+
}
|
|
@@ -7,6 +7,7 @@ export * from './dialer';
|
|
|
7
7
|
export * from './email-templates';
|
|
8
8
|
export * from './fbr-generate-invoice';
|
|
9
9
|
export * from './google-maps';
|
|
10
|
+
export * from './halfhalf';
|
|
10
11
|
export * from './hubrise_catalog';
|
|
11
12
|
export * from './hubrise_customers';
|
|
12
13
|
export * from './hubrise_deliveries';
|
|
@@ -21,6 +22,7 @@ export * from './pra-generate-invoice';
|
|
|
21
22
|
export * from './report-webview';
|
|
22
23
|
export * from './reports';
|
|
23
24
|
export * from './smartpay-apis';
|
|
25
|
+
export * from './specials';
|
|
24
26
|
export * from './split_bill';
|
|
25
27
|
export * from './srb-generate-invoice';
|
|
26
28
|
export * from './switchpay';
|
|
@@ -23,6 +23,7 @@ __exportStar(require("./dialer"), exports);
|
|
|
23
23
|
__exportStar(require("./email-templates"), exports);
|
|
24
24
|
__exportStar(require("./fbr-generate-invoice"), exports);
|
|
25
25
|
__exportStar(require("./google-maps"), exports);
|
|
26
|
+
__exportStar(require("./halfhalf"), exports);
|
|
26
27
|
__exportStar(require("./hubrise_catalog"), exports);
|
|
27
28
|
__exportStar(require("./hubrise_customers"), exports);
|
|
28
29
|
__exportStar(require("./hubrise_deliveries"), exports);
|
|
@@ -37,6 +38,7 @@ __exportStar(require("./pra-generate-invoice"), exports);
|
|
|
37
38
|
__exportStar(require("./report-webview"), exports);
|
|
38
39
|
__exportStar(require("./reports"), exports);
|
|
39
40
|
__exportStar(require("./smartpay-apis"), exports);
|
|
41
|
+
__exportStar(require("./specials"), exports);
|
|
40
42
|
__exportStar(require("./split_bill"), exports);
|
|
41
43
|
__exportStar(require("./srb-generate-invoice"), exports);
|
|
42
44
|
__exportStar(require("./switchpay"), exports);
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PLATFORMS_ENUM } from '../../constants';
|
|
2
|
+
import { IMinifiedItemSpecialHour, IMinifiedPrice } from './catalog';
|
|
3
|
+
/**
|
|
4
|
+
* Simplified wire representation of a special (mirrors ISimplifiedItem).
|
|
5
|
+
*
|
|
6
|
+
* - Prices are minified (IMinifiedPrice: number | IPrice | null | undefined).
|
|
7
|
+
* - sold_out is a per-tenant boolean (replaces string[]).
|
|
8
|
+
* - Simplified specials expose only menu-list data: no modifier/selection
|
|
9
|
+
* structure (modifier_specials is dropped for the simplified flow).
|
|
10
|
+
*/
|
|
11
|
+
export interface ISimplifiedSpecial {
|
|
12
|
+
sold_out?: boolean;
|
|
13
|
+
display_price?: number | null;
|
|
14
|
+
show_starting_from?: boolean;
|
|
15
|
+
is_discount_percentage?: boolean;
|
|
16
|
+
price?: IMinifiedPrice;
|
|
17
|
+
discount_amount?: IMinifiedPrice;
|
|
18
|
+
item_special_hours?: IMinifiedItemSpecialHour[];
|
|
19
|
+
_id: string;
|
|
20
|
+
category_id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
included_platforms: PLATFORMS_ENUM[];
|
|
23
|
+
description: string;
|
|
24
|
+
active: boolean;
|
|
25
|
+
sort_id: number;
|
|
26
|
+
image_url: string;
|
|
27
|
+
}
|
|
@@ -55,6 +55,8 @@ export * from './sales-comparitive-report-helpers';
|
|
|
55
55
|
export * from './sales-overview-report-helpers';
|
|
56
56
|
export * from './sales-summary-report-helpers';
|
|
57
57
|
export * from './simplified-catalog';
|
|
58
|
+
export * from './simplified-halfhalf';
|
|
59
|
+
export * from './simplified-specials';
|
|
58
60
|
export * from './simplified-tenant';
|
|
59
61
|
export * from './specials-helpers';
|
|
60
62
|
export * from './tenant-calendar-helpers';
|
|
@@ -71,6 +71,8 @@ __exportStar(require("./sales-comparitive-report-helpers"), exports);
|
|
|
71
71
|
__exportStar(require("./sales-overview-report-helpers"), exports);
|
|
72
72
|
__exportStar(require("./sales-summary-report-helpers"), exports);
|
|
73
73
|
__exportStar(require("./simplified-catalog"), exports);
|
|
74
|
+
__exportStar(require("./simplified-halfhalf"), exports);
|
|
75
|
+
__exportStar(require("./simplified-specials"), exports);
|
|
74
76
|
__exportStar(require("./simplified-tenant"), exports);
|
|
75
77
|
__exportStar(require("./specials-helpers"), exports);
|
|
76
78
|
__exportStar(require("./tenant-calendar-helpers"), exports);
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IHalfHalfSetup } from '../../schemas';
|
|
2
|
+
import { ISimplifiedHalfHalfSetup } from '../types';
|
|
3
|
+
export declare function convertHalfHalfSetupToSimplifiedHalfHalfSetup(halfhalfSetup: IHalfHalfSetup, tenantId: string): ISimplifiedHalfHalfSetup;
|
|
4
|
+
export declare function convertHalfHalfSetupsToSimplifiedHalfHalfSetups(halfhalfSetups: IHalfHalfSetup[], tenantId: string): ISimplifiedHalfHalfSetup[];
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertHalfHalfSetupToSimplifiedHalfHalfSetup = convertHalfHalfSetupToSimplifiedHalfHalfSetup;
|
|
4
|
+
exports.convertHalfHalfSetupsToSimplifiedHalfHalfSetups = convertHalfHalfSetupsToSimplifiedHalfHalfSetups;
|
|
5
|
+
const minified_catalog_1 = require("./minified-catalog");
|
|
6
|
+
function convertHalfHalfSetupToSimplifiedHalfHalfSetup(halfhalfSetup, tenantId) {
|
|
7
|
+
return {
|
|
8
|
+
sold_out: halfhalfSetup.sold_out.includes(tenantId) || undefined,
|
|
9
|
+
is_discount_percentage: halfhalfSetup.is_discount_percentage || undefined,
|
|
10
|
+
discount_amount: (0, minified_catalog_1.convertOriginalPlatformNumToMinifiedPlatformNum)(halfhalfSetup.discount_amount),
|
|
11
|
+
item_special_hours: (0, minified_catalog_1.convertOriginalSpecialHoursToMinifiedSpecialHours)(halfhalfSetup.item_special_hours),
|
|
12
|
+
_id: halfhalfSetup._id,
|
|
13
|
+
category_id: halfhalfSetup.category_id,
|
|
14
|
+
name: halfhalfSetup.name,
|
|
15
|
+
description: halfhalfSetup.description,
|
|
16
|
+
active: halfhalfSetup.active,
|
|
17
|
+
image_url: halfhalfSetup.image_url,
|
|
18
|
+
included_platforms: halfhalfSetup.included_platforms,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function convertHalfHalfSetupsToSimplifiedHalfHalfSetups(halfhalfSetups, tenantId) {
|
|
22
|
+
const newHalfHalfSetups = [];
|
|
23
|
+
for (let i = 0; i < halfhalfSetups.length; i++) {
|
|
24
|
+
const halfhalfSetup = halfhalfSetups[i];
|
|
25
|
+
newHalfHalfSetups.push(convertHalfHalfSetupToSimplifiedHalfHalfSetup(halfhalfSetup, tenantId));
|
|
26
|
+
}
|
|
27
|
+
return newHalfHalfSetups;
|
|
28
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { ISpecial } from '../../schemas';
|
|
2
|
+
import { ISimplifiedSpecial } from '../types';
|
|
3
|
+
export declare function convertSpecialToSimplifiedSpecial(special: ISpecial, tenantId: string): ISimplifiedSpecial;
|
|
4
|
+
export declare function convertSpecialsToSimplifiedSpecials(specials: ISpecial[], tenantId: string): ISimplifiedSpecial[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertSpecialToSimplifiedSpecial = convertSpecialToSimplifiedSpecial;
|
|
4
|
+
exports.convertSpecialsToSimplifiedSpecials = convertSpecialsToSimplifiedSpecials;
|
|
5
|
+
const minified_catalog_1 = require("./minified-catalog");
|
|
6
|
+
function convertSpecialToSimplifiedSpecial(special, tenantId) {
|
|
7
|
+
return {
|
|
8
|
+
sold_out: special.sold_out.includes(tenantId) || undefined,
|
|
9
|
+
display_price: special.display_price ?? undefined,
|
|
10
|
+
show_starting_from: special.show_starting_from || undefined,
|
|
11
|
+
is_discount_percentage: special.is_discount_percentage || undefined,
|
|
12
|
+
price: (0, minified_catalog_1.convertOriginalPlatformNumToMinifiedPlatformNum)(special.price),
|
|
13
|
+
discount_amount: (0, minified_catalog_1.convertOriginalPlatformNumToMinifiedPlatformNum)(special.discount_amount),
|
|
14
|
+
item_special_hours: (0, minified_catalog_1.convertOriginalSpecialHoursToMinifiedSpecialHours)(special.item_special_hours),
|
|
15
|
+
_id: special._id,
|
|
16
|
+
category_id: special.category_id,
|
|
17
|
+
name: special.name,
|
|
18
|
+
description: special.description,
|
|
19
|
+
active: special.active,
|
|
20
|
+
sort_id: special.sort_id,
|
|
21
|
+
image_url: special.image_url,
|
|
22
|
+
included_platforms: special.included_platforms,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function convertSpecialsToSimplifiedSpecials(specials, tenantId) {
|
|
26
|
+
const newSpecials = [];
|
|
27
|
+
for (let i = 0; i < specials.length; i++) {
|
|
28
|
+
const special = specials[i];
|
|
29
|
+
newSpecials.push(convertSpecialToSimplifiedSpecial(special, tenantId));
|
|
30
|
+
}
|
|
31
|
+
return newSpecials;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const simplified_halfhalf_1 = require("../helpers/utils/simplified-halfhalf");
|
|
5
|
+
const TENANT_ID = 'tenant-1';
|
|
6
|
+
function makeHalfHalfSetup(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
_id: 'halfhalf-1',
|
|
9
|
+
brand_id: 'brand-1',
|
|
10
|
+
tenants: ['tenant-1', 'tenant-2'],
|
|
11
|
+
category_id: 'category-1',
|
|
12
|
+
included_platforms: [constants_1.PLATFORMS_ENUM.POS_WALK_IN],
|
|
13
|
+
segments: [
|
|
14
|
+
{ _id: 'segment-1', name: 'Half 1', sort_id: 1 },
|
|
15
|
+
{ _id: 'segment-2', name: 'Half 2', sort_id: 2 },
|
|
16
|
+
],
|
|
17
|
+
image_url: 'https://example.com/halfhalf.jpg',
|
|
18
|
+
name: 'Half & Half',
|
|
19
|
+
description: 'Two halves combo',
|
|
20
|
+
active: true,
|
|
21
|
+
sold_out: ['tenant-2'],
|
|
22
|
+
upsell_price: { BASE_PRICE: 1000 },
|
|
23
|
+
discount_amount: null,
|
|
24
|
+
is_discount_percentage: false,
|
|
25
|
+
choose_expensive_segment_price: true,
|
|
26
|
+
item_special_hours: null,
|
|
27
|
+
items: [{ item_id: 'item-1', sort_id: 1, upsell_price: { BASE_PRICE: 500 } }],
|
|
28
|
+
excluded_refs: ['item-2'],
|
|
29
|
+
exclusive_refs: [],
|
|
30
|
+
createdAt: new Date('2024-01-01'),
|
|
31
|
+
updatedAt: new Date('2024-01-02'),
|
|
32
|
+
...overrides,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
describe('convertHalfHalfSetupToSimplifiedHalfHalfSetup', () => {
|
|
36
|
+
it('drops full-only fields and resolves sold_out per tenant', () => {
|
|
37
|
+
const simplified = (0, simplified_halfhalf_1.convertHalfHalfSetupToSimplifiedHalfHalfSetup)(makeHalfHalfSetup(), TENANT_ID);
|
|
38
|
+
expect(simplified._id).toBe('halfhalf-1');
|
|
39
|
+
expect(simplified.category_id).toBe('category-1');
|
|
40
|
+
expect(simplified.name).toBe('Half & Half');
|
|
41
|
+
expect(simplified.description).toBe('Two halves combo');
|
|
42
|
+
expect(simplified.active).toBe(true);
|
|
43
|
+
expect(simplified.image_url).toBe('https://example.com/halfhalf.jpg');
|
|
44
|
+
expect(simplified.included_platforms).toEqual([constants_1.PLATFORMS_ENUM.POS_WALK_IN]);
|
|
45
|
+
// full-only fields are dropped
|
|
46
|
+
expect(simplified).not.toHaveProperty('brand_id');
|
|
47
|
+
expect(simplified).not.toHaveProperty('tenants');
|
|
48
|
+
expect(simplified).not.toHaveProperty('createdAt');
|
|
49
|
+
expect(simplified).not.toHaveProperty('updatedAt');
|
|
50
|
+
// sold_out resolved to boolean for the requested tenant (omitted when not sold out)
|
|
51
|
+
expect(simplified.sold_out).toBeUndefined();
|
|
52
|
+
});
|
|
53
|
+
it('does not expose segments, items, ref rules or upsell fields', () => {
|
|
54
|
+
const simplified = (0, simplified_halfhalf_1.convertHalfHalfSetupToSimplifiedHalfHalfSetup)(makeHalfHalfSetup(), TENANT_ID);
|
|
55
|
+
expect(simplified).not.toHaveProperty('segments');
|
|
56
|
+
expect(simplified).not.toHaveProperty('items');
|
|
57
|
+
expect(simplified).not.toHaveProperty('excluded_refs');
|
|
58
|
+
expect(simplified).not.toHaveProperty('exclusive_refs');
|
|
59
|
+
expect(simplified).not.toHaveProperty('choose_expensive_segment_price');
|
|
60
|
+
expect(simplified).not.toHaveProperty('upsell_price');
|
|
61
|
+
});
|
|
62
|
+
it('minifies setup prices', () => {
|
|
63
|
+
const simplified = (0, simplified_halfhalf_1.convertHalfHalfSetupToSimplifiedHalfHalfSetup)(makeHalfHalfSetup({
|
|
64
|
+
discount_amount: { BASE_PRICE: 300 },
|
|
65
|
+
}), TENANT_ID);
|
|
66
|
+
expect(simplified.discount_amount).toBe(300);
|
|
67
|
+
});
|
|
68
|
+
it('handles a halfhalf sold out for the tenant', () => {
|
|
69
|
+
const simplified = (0, simplified_halfhalf_1.convertHalfHalfSetupToSimplifiedHalfHalfSetup)(makeHalfHalfSetup({ sold_out: ['tenant-1'] }), TENANT_ID);
|
|
70
|
+
expect(simplified.sold_out).toBe(true);
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
describe('convertHalfHalfSetupsToSimplifiedHalfHalfSetups', () => {
|
|
74
|
+
it('maps every halfhalf setup', () => {
|
|
75
|
+
const simplifiedList = (0, simplified_halfhalf_1.convertHalfHalfSetupsToSimplifiedHalfHalfSetups)([makeHalfHalfSetup({ _id: 'hh-1' }), makeHalfHalfSetup({ _id: 'hh-2' })], TENANT_ID);
|
|
76
|
+
expect(simplifiedList).toHaveLength(2);
|
|
77
|
+
expect(simplifiedList.map((h) => h._id)).toEqual(['hh-1', 'hh-2']);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const constants_1 = require("../constants");
|
|
4
|
+
const simplified_specials_1 = require("../helpers/utils/simplified-specials");
|
|
5
|
+
const TENANT_ID = 'tenant-1';
|
|
6
|
+
function makeSpecial(overrides = {}) {
|
|
7
|
+
return {
|
|
8
|
+
_id: 'special-1',
|
|
9
|
+
brand_id: 'brand-1',
|
|
10
|
+
tenants: ['tenant-1', 'tenant-2'],
|
|
11
|
+
category_id: 'category-1',
|
|
12
|
+
included_platforms: [constants_1.PLATFORMS_ENUM.POS_WALK_IN],
|
|
13
|
+
image_url: 'https://example.com/special.jpg',
|
|
14
|
+
name: 'Pizza Deal',
|
|
15
|
+
description: 'Special combo',
|
|
16
|
+
active: true,
|
|
17
|
+
sold_out: ['tenant-2'],
|
|
18
|
+
sort_id: 1,
|
|
19
|
+
price: { BASE_PRICE: 1500 },
|
|
20
|
+
discount_amount: null,
|
|
21
|
+
is_discount_percentage: false,
|
|
22
|
+
display_price: 1200,
|
|
23
|
+
show_starting_from: true,
|
|
24
|
+
item_special_hours: null,
|
|
25
|
+
modifier_specials: [
|
|
26
|
+
{
|
|
27
|
+
_id: 'ms-1',
|
|
28
|
+
name: 'Choose 1',
|
|
29
|
+
sort_id: 1,
|
|
30
|
+
quantity: 1,
|
|
31
|
+
num_free_items: 0,
|
|
32
|
+
excluded_refs: [],
|
|
33
|
+
exclusive_refs: [],
|
|
34
|
+
omit_items_schedule: false,
|
|
35
|
+
items: [{ item_id: 'item-1', sort_id: 1, upsell_price: null }],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
createdAt: new Date('2024-01-01'),
|
|
39
|
+
updatedAt: new Date('2024-01-02'),
|
|
40
|
+
...overrides,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
describe('convertSpecialToSimplifiedSpecial', () => {
|
|
44
|
+
it('drops full-only fields and resolves sold_out per tenant', () => {
|
|
45
|
+
const simplified = (0, simplified_specials_1.convertSpecialToSimplifiedSpecial)(makeSpecial(), TENANT_ID);
|
|
46
|
+
expect(simplified._id).toBe('special-1');
|
|
47
|
+
expect(simplified.category_id).toBe('category-1');
|
|
48
|
+
expect(simplified.name).toBe('Pizza Deal');
|
|
49
|
+
expect(simplified.description).toBe('Special combo');
|
|
50
|
+
expect(simplified.active).toBe(true);
|
|
51
|
+
expect(simplified.sort_id).toBe(1);
|
|
52
|
+
expect(simplified.image_url).toBe('https://example.com/special.jpg');
|
|
53
|
+
expect(simplified.included_platforms).toEqual([constants_1.PLATFORMS_ENUM.POS_WALK_IN]);
|
|
54
|
+
// full-only fields are dropped
|
|
55
|
+
expect(simplified).not.toHaveProperty('brand_id');
|
|
56
|
+
expect(simplified).not.toHaveProperty('tenants');
|
|
57
|
+
expect(simplified).not.toHaveProperty('createdAt');
|
|
58
|
+
expect(simplified).not.toHaveProperty('updatedAt');
|
|
59
|
+
// sold_out resolved to boolean for the requested tenant (omitted when not sold out)
|
|
60
|
+
expect(simplified.sold_out).toBeUndefined();
|
|
61
|
+
});
|
|
62
|
+
it('does not expose modifier_specials', () => {
|
|
63
|
+
const simplified = (0, simplified_specials_1.convertSpecialToSimplifiedSpecial)(makeSpecial(), TENANT_ID);
|
|
64
|
+
expect(simplified).not.toHaveProperty('modifier_specials');
|
|
65
|
+
});
|
|
66
|
+
it('minifies price and discount_amount', () => {
|
|
67
|
+
const simplified = (0, simplified_specials_1.convertSpecialToSimplifiedSpecial)(makeSpecial({
|
|
68
|
+
price: { BASE_PRICE: 1500, [constants_1.PLATFORMS_ENUM.POS_WALK_IN]: 1500 },
|
|
69
|
+
discount_amount: { BASE_PRICE: 300 },
|
|
70
|
+
}), TENANT_ID);
|
|
71
|
+
expect(simplified.price).toBe(1500);
|
|
72
|
+
expect(simplified.discount_amount).toBe(300);
|
|
73
|
+
});
|
|
74
|
+
it('handles a special sold out for the tenant', () => {
|
|
75
|
+
const simplified = (0, simplified_specials_1.convertSpecialToSimplifiedSpecial)(makeSpecial({ sold_out: ['tenant-1'] }), TENANT_ID);
|
|
76
|
+
expect(simplified.sold_out).toBe(true);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe('convertSpecialsToSimplifiedSpecials', () => {
|
|
80
|
+
it('maps every special', () => {
|
|
81
|
+
const simplifiedList = (0, simplified_specials_1.convertSpecialsToSimplifiedSpecials)([makeSpecial({ _id: 'special-1' }), makeSpecial({ _id: 'special-2' })], TENANT_ID);
|
|
82
|
+
expect(simplifiedList).toHaveLength(2);
|
|
83
|
+
expect(simplifiedList.map((s) => s._id)).toEqual(['special-1', 'special-2']);
|
|
84
|
+
});
|
|
85
|
+
});
|