From f9f4ce5fb2534cc394a6b23d690b09064b2881ab Mon Sep 17 00:00:00 2001 From: nflnkr Date: Mon, 6 Mar 2023 16:21:48 +0300 Subject: [PATCH] add new test data --- src/stores/mocks/discounts.ts | 55 --------------------------- src/stores/mocks/exampleCartValues.ts | 38 ++++++++++++++---- src/stores/mocks/promocodes.ts | 19 --------- src/stores/mocks/tariffs.ts | 31 +++++++++++++++ src/stores/mocks/user.ts | 8 ++++ 5 files changed, 69 insertions(+), 82 deletions(-) delete mode 100644 src/stores/mocks/discounts.ts delete mode 100644 src/stores/mocks/promocodes.ts create mode 100644 src/stores/mocks/tariffs.ts create mode 100644 src/stores/mocks/user.ts diff --git a/src/stores/mocks/discounts.ts b/src/stores/mocks/discounts.ts deleted file mode 100644 index 1884ac9..0000000 --- a/src/stores/mocks/discounts.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Discount } from "../../model/cart"; - -/** - * @deprecated - */ -export const testDiscounts: Discount[] = [ - { - id: 1, - name: "Скидка 1", - endless: false, - from: "", - dueTo: "", - privileges: [ - { good: "Шаблонизатор документов", discount: 0.3 }, - { good: "Опросник", discount: 0.2 }, - ], - active: false, - incomeMore: 1, - basketMore: 10, - toTime: 20, - toCapacity: 30, - }, - { - id: 2, - name: "Скидка 2", - endless: false, - from: "", - dueTo: "", - privileges: [ - { good: "Сокращатель ссылок", discount: 0.3 }, - { good: "Опросник", discount: 0.2 }, - ], - active: true, - incomeMore: 1, - basketMore: 10, - toTime: 20, - toCapacity: 30, - }, - { - id: 3, - name: "Скидка 3", - endless: false, - from: "", - dueTo: "", - privileges: [ - { good: "Шаблонизатор документов", discount: 0.3 }, - { good: "Опросник", discount: 0.2 }, - ], - active: false, - incomeMore: 1, - basketMore: 10, - toTime: 20, - toCapacity: 30, - }, -]; \ No newline at end of file diff --git a/src/stores/mocks/exampleCartValues.ts b/src/stores/mocks/exampleCartValues.ts index 405a5fa..1c4903b 100644 --- a/src/stores/mocks/exampleCartValues.ts +++ b/src/stores/mocks/exampleCartValues.ts @@ -1,5 +1,5 @@ -import { Cart } from "../../model/cart"; -import { Tariffs } from "../../model/tariff"; +import { AnyDiscount } from "@root/model/cart"; +import { Privilege } from "@root/model/tariff"; import { User } from "../../model/user"; export type TestCase = { @@ -18,8 +18,8 @@ export type TestCase = { }; type ExampleCartValues = { - privileges: Tariffs.Privilege[]; - discounts: Cart.AnyDiscount[]; + privileges: Privilege[]; + discounts: AnyDiscount[]; testCases: TestCase[]; }; @@ -517,7 +517,7 @@ export const exampleCartValues: ExampleCartValues = { } }, { - "_id": "id24", + "_id": "id24.1", "name": "Стата Сокращатель 1", "description": "Скидка на дни сбора расширенной статистики от 30 дней", "conditionType": "privilege", @@ -538,7 +538,7 @@ export const exampleCartValues: ExampleCartValues = { } }, { - "_id": "id24", + "_id": "id24.2", "name": "Стата Сокращатель 2", "description": "Скидка на дни сбора расширенной статистики от 90 дней", "conditionType": "privilege", @@ -703,7 +703,7 @@ export const exampleCartValues: ExampleCartValues = { "conditionType": "user", "layer": 1, "condition": { - "coupon": "AB\\CD", // на мой вкус, стоит при активации промокода создавать скидку, привязанную к юзеру по айдишнику, и удалять после использования. т.е. кондишн не по coupon, а по + "coupon": "ABCD", // на мой вкус, стоит при активации промокода создавать скидку, привязанную к юзеру по айдишнику, и удалять после использования. т.е. кондишн не по coupon, а по "user": "buddy" }, "target": { @@ -1097,6 +1097,28 @@ export const exampleCartValues: ExampleCartValues = { "id32" ] // юзер подтвердил свой статус НКО, поэтому, не смотря на то что он достиг по лояльности уровня скидки id2, она не применилась, а применилась id32 } - } + }, + { + "input": { + "UserInformation": { + "ID": "buddy", + "Type": "", + "PurchasesAmount": 0 + }, + "Products": [ + { + "ID": "p7", + "Amount": 4000, + "Price": 12000 + }, + ] + }, + "expect": { + "price": 12000 * 0.985, + "envolvedDiscounts": [ + "id4" + ] + } + }, ] }; \ No newline at end of file diff --git a/src/stores/mocks/promocodes.ts b/src/stores/mocks/promocodes.ts deleted file mode 100644 index 72890e3..0000000 --- a/src/stores/mocks/promocodes.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { Promocode } from "../../model/cart"; - -/** - * @deprecated - */ -export const testPromocodes: Promocode[] = [ - { - id: 1, name: "Промокод 1", endless: false, from: "", dueTo: "", privileges: [ - { good: "Шаблонизатор документов", discount: 0.15 }, - { good: "Опросник", discount: 0.3 } - ] - }, - { - id: 1, name: "Промокод 2", endless: false, from: "", dueTo: "", privileges: [ - { good: "Шаблонизатор документов", discount: 0.4 }, - { good: "Опросник", discount: 0.6 } - ] - } -]; \ No newline at end of file diff --git a/src/stores/mocks/tariffs.ts b/src/stores/mocks/tariffs.ts new file mode 100644 index 0000000..ac65232 --- /dev/null +++ b/src/stores/mocks/tariffs.ts @@ -0,0 +1,31 @@ +import { Tariff } from "@root/model/tariff"; +import { exampleCartValues } from "./exampleCartValues"; + + +export const exampleTariffs: Tariff[] = [ + { + id: "tariffId1", + name: "Tariff 1", + privilege: exampleCartValues.privileges[0], + amount: 1000, + }, + { + id: "tariffId2", + name: "Tariff 2", + privilege: exampleCartValues.privileges[1], + amount: 2000, + customPricePerUnit: 3, + }, + { + id: "tariffId3", + name: "Tariff 3", + privilege: exampleCartValues.privileges[2], + amount: 3000, + }, + { + id: "tariffId4", + name: "Tariff 4", + privilege: exampleCartValues.privileges[5], + amount: 4000, + }, +] \ No newline at end of file diff --git a/src/stores/mocks/user.ts b/src/stores/mocks/user.ts new file mode 100644 index 0000000..d8d75a9 --- /dev/null +++ b/src/stores/mocks/user.ts @@ -0,0 +1,8 @@ +import { User } from "@root/model/user"; + + +export const testUser: User = { + "ID": "buddy", + "Type": "", + "PurchasesAmount": 0, +}; \ No newline at end of file