import { type GenerateCodeOptions, generateCode, getEmbedPreviewLayoutMarker, } from '@/settings/utils/generate-embed-code'; describe('generateCode', function () { let genOptions: GenerateCodeOptions; beforeEach(function () { genOptions = { preview: false, config: { blogUrl: 'https://example.com', signupForm: { url: 'https://example.com', version: 'v3', }, }, settings: { accentColor: '#000000', locale: 'af', }, labels: [], backgroundColor: '#000000', layout: 'minimal', }; }); it('generates a basic embed script', function () { expect(generateCode(genOptions)).toBe( '
', ); }); it('generates a basic embed script with labels', function () { genOptions.labels = [{ name: 'label1' }, { name: 'label2' }]; expect(generateCode(genOptions)).toBe( '', ); }); it('generated an embed with an icon that has no size segment', function () { genOptions.settings.icon = 'https://example.com/content/images/2023/09/snoopy.png'; genOptions.layout = 'all-in-one'; expect(generateCode(genOptions)).toBe( '', ); }); it('generated an embed with an icon that already has a size segment', function () { genOptions.settings.icon = 'https://example.com/content/images/size/w256h256/2023/09/snoopy.png'; genOptions.layout = 'all-in-one'; expect(generateCode(genOptions)).toBe( '', ); }); it('renders a full preview', function () { genOptions.preview = true; genOptions.layout = 'all-in-one'; expect(generateCode(genOptions)).toBe( '', ); }); it('renders a preview with a minimal layout', function () { genOptions.preview = true; genOptions.layout = 'minimal'; expect(generateCode(genOptions)).toBe( '', ); }); it('uses the shared preview layout marker for both layouts', function () { expect(getEmbedPreviewLayoutMarker('all-in-one')).toBe('data-preview-layout="all-in-one"'); expect(getEmbedPreviewLayoutMarker('minimal')).toBe('data-preview-layout="minimal"'); }); it('generates text color based on background color - light background, black text', function () { genOptions.backgroundColor = '#ffffff'; genOptions.layout = 'all-in-one'; expect(generateCode(genOptions)).toBe( '', ); }); it('generates text color based on background color - black background, light text', function () { genOptions.backgroundColor = '#000000'; genOptions.layout = 'all-in-one'; expect(generateCode(genOptions)).toBe( '', ); }); });