mock-events.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. import { AdjustmentType } from '@vendure/common/lib/generated-shop-types';
  2. import {
  3. AccountRegistrationEvent,
  4. CurrencyCode,
  5. Customer,
  6. IdentifierChangeRequestEvent,
  7. NativeAuthenticationMethod,
  8. Order,
  9. OrderLine,
  10. OrderStateTransitionEvent,
  11. PasswordResetEvent,
  12. ProductVariant,
  13. ShippingLine,
  14. User,
  15. } from '@vendure/core';
  16. export const mockOrderStateTransitionEvent = new OrderStateTransitionEvent(
  17. 'ArrangingPayment',
  18. 'PaymentSettled',
  19. {} as any,
  20. new Order({
  21. id: '6',
  22. currencyCode: CurrencyCode.USD,
  23. createdAt: '2018-10-31T11:18:29.261Z',
  24. updatedAt: '2018-10-31T15:24:17.000Z',
  25. orderPlacedAt: '2018-10-31T13:54:17.000Z',
  26. code: 'T3EPGJKTVZPBD6Z9',
  27. state: 'ArrangingPayment',
  28. active: true,
  29. customer: new Customer({
  30. id: '3',
  31. firstName: 'Test',
  32. lastName: 'Customer',
  33. emailAddress: 'test@test.com',
  34. }),
  35. lines: [
  36. new OrderLine({
  37. id: '5',
  38. featuredAsset: {
  39. preview: '/mailbox/placeholder-image',
  40. },
  41. productVariant: new ProductVariant({
  42. id: '2',
  43. name: 'Curvy Monitor 24 inch',
  44. sku: 'C24F390',
  45. }),
  46. quantity: 1,
  47. listPrice: 14374,
  48. listPriceIncludesTax: true,
  49. adjustments: [
  50. {
  51. adjustmentSource: 'Promotion:1',
  52. type: AdjustmentType.PROMOTION,
  53. amount: -1000 as any,
  54. description: '$10 off computer equipment',
  55. },
  56. ],
  57. taxLines: [],
  58. }),
  59. new OrderLine({
  60. id: '6',
  61. featuredAsset: {
  62. preview: '/mailbox/placeholder-image',
  63. },
  64. productVariant: new ProductVariant({
  65. id: '4',
  66. name: 'Hard Drive 1TB',
  67. sku: 'IHD455T1',
  68. }),
  69. quantity: 1,
  70. listPrice: 3799,
  71. listPriceIncludesTax: true,
  72. adjustments: [],
  73. taxLines: [],
  74. }),
  75. ],
  76. subTotal: 15144,
  77. subTotalWithTax: 18173,
  78. shipping: 1000,
  79. shippingLines: [
  80. new ShippingLine({
  81. listPrice: 1000,
  82. listPriceIncludesTax: true,
  83. taxLines: [{ taxRate: 20, description: 'shipping tax' }],
  84. shippingMethod: {
  85. code: 'express-flat-rate',
  86. name: 'Express Shipping',
  87. description: 'Express Shipping',
  88. id: '2',
  89. },
  90. }),
  91. ],
  92. surcharges: [],
  93. shippingAddress: {
  94. fullName: 'Test Customer',
  95. company: '',
  96. streetLine1: '6000 Pagac Land',
  97. streetLine2: '',
  98. city: 'Port Kirsten',
  99. province: 'Avon',
  100. postalCode: 'ZU32 9CP',
  101. country: 'Cabo Verde',
  102. phoneNumber: '',
  103. },
  104. payments: [],
  105. }),
  106. );
  107. export const mockAccountRegistrationEvent = new AccountRegistrationEvent(
  108. {} as any,
  109. new User({
  110. verified: false,
  111. authenticationMethods: [
  112. new NativeAuthenticationMethod({
  113. identifier: 'test@test.com',
  114. verificationToken: 'MjAxOC0xMS0xM1QxNToxNToxNC42ODda_US2U6UK1WZC7NDAX',
  115. }),
  116. ],
  117. identifier: 'test@test.com',
  118. }),
  119. );
  120. export const mockPasswordResetEvent = new PasswordResetEvent(
  121. {} as any,
  122. new User({
  123. identifier: 'test@test.com',
  124. authenticationMethods: [
  125. new NativeAuthenticationMethod({
  126. passwordResetToken: 'MjAxOS0wNC0xNVQxMzozMDozOC43MjFa_MA2FR6HRZBW7JWD6',
  127. }),
  128. ],
  129. }),
  130. );
  131. export const mockEmailAddressChangeEvent = new IdentifierChangeRequestEvent(
  132. {} as any,
  133. new User({
  134. identifier: 'old-address@test.com',
  135. authenticationMethods: [
  136. new NativeAuthenticationMethod({
  137. pendingIdentifier: 'new-address@test.com',
  138. identifierChangeToken: 'MjAxOS0wNC0xNVQxMzozMDozOC43MjFa_MA2FR6HRZBW7JWD6',
  139. }),
  140. ],
  141. }),
  142. );