mirror of
https://github.com/immich-app/immich.git
synced 2026-04-29 04:20:38 -04:00
37 lines
1.3 KiB
TypeScript
37 lines
1.3 KiB
TypeScript
import { ApiService, render } from 'src/services/api.service';
|
|
|
|
describe(ApiService.name, () => {
|
|
describe('render', () => {
|
|
it('should correctly render open graph tags', () => {
|
|
const output = render('<!-- metadata:tags -->', {
|
|
title: 'title',
|
|
description: 'description',
|
|
imageUrl: 'https://demo.immich.app/api/assets/123',
|
|
});
|
|
expect(output).toContain('<meta property="og:title" content="title" />');
|
|
expect(output).toContain('<meta property="og:description" content="description" />');
|
|
expect(output).toContain('<meta property="og:image" content="https://demo.immich.app/api/assets/123" />');
|
|
});
|
|
|
|
it('should escape html tags', () => {
|
|
expect(
|
|
render('<!-- metadata:tags -->', {
|
|
title: "<script>console.log('hello')</script>Test",
|
|
description: 'description',
|
|
}),
|
|
).toContain(
|
|
'<meta property="og:title" content="<script>console.log('hello')</script>Test" />',
|
|
);
|
|
});
|
|
|
|
it('should escape quotes', () => {
|
|
expect(
|
|
render('<!-- metadata:tags -->', {
|
|
title: `0;url=https://example.com" http-equiv="refresh`,
|
|
description: 'description',
|
|
}),
|
|
).toContain('<meta property="og:title" content="0;url=https://example.com" http-equiv="refresh" />');
|
|
});
|
|
});
|
|
});
|