const journalSchema = require('./data/eds-c-hero-journal.schema.json');
const journalExample = require('./data/eds-c-hero-journal.example.json');
const { createVariantTests } = require('./eds-c-hero.test');

describe('Hero Journal', () => {
    const tests = createVariantTests('Journal', journalSchema, journalExample, 'eds-c-hero-journal');

    tests.schemaValidation();
    tests.accessibilityTest();

    tests.renderTest('.eds-c-hero__partnership', (example) => example.partnership);
    tests.renderTest('.eds-c-hero__partnership-list', (example) => example.partnership);
    tests.renderTest('.eds-c-hero__journal-cover', (example) => example.cover);
    tests.renderTest('.l-grid.eds-c-hero__journal');

    tests.customTest('renders partnership logos when provided', (rendered, example) => {
        if (example.partnership) {
            const partnershipItems = document.querySelectorAll('.eds-c-hero__partnership-list-item');
            expect(partnershipItems.length).toBeGreaterThan(0);
        }
    });

    tests.customTest('renders societies when provided', (rendered, example) => {
        if (example.partnership && example.partnership.societies) {
            const societyWrapper = document.querySelector('.eds-c-hero__partnership-list-item-img-wrapper');
            expect(societyWrapper).toBeTruthy();
        }
    });
});