feat(seo): generate slugs for brands, categories and products, add GET /sitemap and the Postman collection (#5)
This commit is contained in:
@@ -38,6 +38,7 @@ describe('ProductHiboutikService', () => {
|
||||
// The transaction client handed to the repositories inside $transaction
|
||||
const tx = { transaction: true };
|
||||
const prisma = { $transaction: jest.fn() };
|
||||
const slugService = { assignMissingSlugs: jest.fn() };
|
||||
|
||||
beforeAll(() => {
|
||||
jest.spyOn(Logger.prototype, 'log').mockImplementation(() => undefined);
|
||||
@@ -76,6 +77,7 @@ describe('ProductHiboutikService', () => {
|
||||
new ProductConverter(),
|
||||
stockHiboutikRepository as never,
|
||||
prisma as never,
|
||||
slugService as never,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -194,4 +196,16 @@ describe('ProductHiboutikService', () => {
|
||||
await expect(prisma.$transaction.mock.results[0].value).rejects.toThrow('boom');
|
||||
await expect(prisma.$transaction.mock.results[1].value).resolves.toBeUndefined();
|
||||
});
|
||||
it('generates the slugs of new products once they are saved', async () => {
|
||||
productHiboutikRepository.getProducts.mockResolvedValue([hiboutikProduct(1)]);
|
||||
slugService.assignMissingSlugs.mockImplementation(() => {
|
||||
calls.push('slugs');
|
||||
return Promise.resolve();
|
||||
});
|
||||
|
||||
await service.syncProducts();
|
||||
|
||||
expect(slugService.assignMissingSlugs).toHaveBeenCalledWith('PRODUCT');
|
||||
expect(calls[calls.length - 1]).toBe('slugs');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user