Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.4 kB
3
Indexable
Never
// const conn = require('../../../src/models/connection');

// const getLastId = async () => {
//   const [lastId] = await conn.execute(
//     'SELECT sale_id FROM sales_products ORDER BY sale_id DESC LIMIT 1',
//   );
//   return lastId;
// };

const SIMPLE_SALE_MOCK = [
  {
    id: 1,
    date: '2025-01-18 04:33:44',
  },
  {
    id: 2,
    date: '2025-01-18 02:23:44',
  },
];

const ADD_SALE_MOCK = {
  id: 10,
  itemsSold: [
    { productId: 2, quantity: 5 },
    { productId: 3, quantity: 10 },
  ],
};

const SALES_MOCK = [
  {
    id: 1,
    date: '2024-01-18 01:11:44',
    saleId: 1,
    productId: 1,
    quantity: 5,
  },
  {
    id: 2,
    date: '2024-01-18 01:11:44',
    saleId: 1,
    productId: 2,
    quantity: 10,
  },
  {
    id: 3,
    date: '2024-01-18 01:11:44',
    saleId: 2,
    productId: 3,
    quantity: 15,
  },
];

const SINGLE_MOCK = [
  {
    id: 1,
    productId: 1,
    quantity: 5,
  },
];

const SINGLE_SALE_MOCK = {
  id: 1,
  date: '2024-01-18 01:11:44',
  saleId: 1,
  productId: 1,
  quantity: 5,
};

const SERVICES_SALE_NOTFOUND_MOCK = {
  message: 'Sale not found',
};

const SALES_MOCK_FOR_SERVICES = {
  status: 200,
  data: SALES_MOCK,
};

const SALES_MOCK_FOR_SERVICES_NOT_FOUND = {
  status: 200,
  data: SALES_MOCK_FOR_SERVICES,
};

const SALES_MOCK_NOTFOUND = { 
  status: 404,
  data: 'Product not found', 
};

const NEW_SINGLE_SALE_INPUT_MOCK = [
  {
    productId: 1,
    quantity: 9,
  },
];
const NEW_MULTI_SALE_INPUT_MOCK = [
  {
    productId: 1,
    quantity: 9,
  },
  {
    productId: 3,
    quantity: 16,
  },
];

const NEW_SINGLE_SALE_OUTPUT_MOCK = 180;

const NEW_MULTI_SALE_OUTPUT_MOCK = {
  id: 180,
};

const NEW_NEW_SINGLE_SALE_OUTPUT_MOCK = [
  {
    productId: 1,
    quantity: 9,
  },
];

const NEW_NEW_MULTI_SALE_OUTPUT_MOCK = [
  {
    productId: 1,
    quantity: 9,
  },
  {
    productId: 3,
    quantity: 16,
  },
];

const ADDED_PRODUCT_UPDATE_MOCK = {
  saleId: 1,
  productId: 2,
  quantity: 10,
};

module.exports = {
  SALES_MOCK,
  ADD_SALE_MOCK,
  SIMPLE_SALE_MOCK,
  SINGLE_MOCK,
  SINGLE_SALE_MOCK,
  SERVICES_SALE_NOTFOUND_MOCK,
  SALES_MOCK_NOTFOUND,
  SALES_MOCK_FOR_SERVICES,
  SALES_MOCK_FOR_SERVICES_NOT_FOUND,
  NEW_SINGLE_SALE_INPUT_MOCK,
  NEW_MULTI_SALE_INPUT_MOCK,
  NEW_SINGLE_SALE_OUTPUT_MOCK,
  NEW_MULTI_SALE_OUTPUT_MOCK,
  NEW_NEW_SINGLE_SALE_OUTPUT_MOCK,
  NEW_NEW_MULTI_SALE_OUTPUT_MOCK,
  ADDED_PRODUCT_UPDATE_MOCK,
};
Leave a Comment