feat: build juozas auto site
This commit is contained in:
10
tests/contact.test.ts
Normal file
10
tests/contact.test.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { whatsappUrl } from '../src/lib/contact';
|
||||
|
||||
describe('contact links', () => {
|
||||
it('builds a Lithuanian WhatsApp inquiry link for a car', () => {
|
||||
expect(whatsappUrl('37061234567', 'BMW', '320d')).toBe(
|
||||
'https://wa.me/37061234567?text=Sveiki%2C%20domina%20BMW%20320d',
|
||||
);
|
||||
});
|
||||
});
|
||||
32
tests/format.test.ts
Normal file
32
tests/format.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { excerpt, formatEngineSize, formatMileage, formatPower, formatPrice, slugifyCar } from '../src/lib/format';
|
||||
|
||||
describe('Lithuanian listing formatters', () => {
|
||||
it('formats prices with spaces and a non-breaking euro separator', () => {
|
||||
expect(formatPrice(12500)).toBe('12 500\u00a0€');
|
||||
});
|
||||
|
||||
it('formats mileage with grouped spaces', () => {
|
||||
expect(formatMileage(145000)).toBe('145 000 km');
|
||||
});
|
||||
|
||||
it('formats power in kW and AG', () => {
|
||||
expect(formatPower(140)).toBe('140 kW (190 AG)');
|
||||
});
|
||||
|
||||
it('formats engine size with a Lithuanian decimal separator', () => {
|
||||
expect(formatEngineSize(2.5)).toBe('2,5 l');
|
||||
});
|
||||
|
||||
it('creates ascii car slugs from Lithuanian city names', () => {
|
||||
expect(slugifyCar({ make: 'Škoda', model: 'Octavia RS', year: 2020, city: 'Šiauliai' })).toBe(
|
||||
'skoda-octavia-rs-2020-siauliai',
|
||||
);
|
||||
});
|
||||
|
||||
it('creates plain text excerpts capped at 155 characters', () => {
|
||||
const text = '**Patikrintas automobilis.** '.repeat(12);
|
||||
expect(excerpt(text)).toHaveLength(155);
|
||||
expect(excerpt(text)).not.toContain('*');
|
||||
});
|
||||
});
|
||||
51
tests/jsonld.test.ts
Normal file
51
tests/jsonld.test.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { vehicleJsonLd } from '../src/lib/jsonLd';
|
||||
|
||||
describe('Vehicle JSON-LD', () => {
|
||||
it('maps listing fields to Vehicle schema', () => {
|
||||
const schema = vehicleJsonLd({
|
||||
canonicalUrl: 'https://auto.juozas.lt/automobiliai/bmw-320d-2018-vilnius',
|
||||
imageUrl: 'https://auto.juozas.lt/_astro/01.jpg',
|
||||
car: {
|
||||
make: 'BMW',
|
||||
model: '320d',
|
||||
year: 2018,
|
||||
price: 12500,
|
||||
mileage: 145000,
|
||||
fuel: 'dyzelinas',
|
||||
transmission: 'automatinė',
|
||||
bodyType: 'sedanas',
|
||||
color: 'Pilka',
|
||||
sold: false,
|
||||
vin: 'WBA8C91010A000000',
|
||||
},
|
||||
});
|
||||
|
||||
expect(schema['@type']).toBe('Vehicle');
|
||||
expect(schema.vehicleModelDate).toBe(2018);
|
||||
expect(schema.mileageFromOdometer.value).toBe(145000);
|
||||
expect(schema.offers.price).toBe(12500);
|
||||
expect(schema.offers.priceCurrency).toBe('EUR');
|
||||
});
|
||||
|
||||
it('marks sold listings as sold out', () => {
|
||||
const schema = vehicleJsonLd({
|
||||
canonicalUrl: 'https://auto.juozas.lt/automobiliai/bmw-320d-2018-vilnius',
|
||||
imageUrl: 'https://auto.juozas.lt/_astro/01.jpg',
|
||||
car: {
|
||||
make: 'BMW',
|
||||
model: '320d',
|
||||
year: 2018,
|
||||
price: 12500,
|
||||
mileage: 145000,
|
||||
fuel: 'dyzelinas',
|
||||
transmission: 'automatinė',
|
||||
bodyType: 'sedanas',
|
||||
color: 'Pilka',
|
||||
sold: true,
|
||||
},
|
||||
});
|
||||
|
||||
expect(schema.offers.availability).toBe('https://schema.org/SoldOut');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user