import { describe, it, expect } from 'vitest' import * as Style from '../../src/style/index.js' describe('Style', () => { describe('.Set', () => { describe('getContextDefinition', () => { it('should find definition for classname', () => { expect(Style.Set.getContextDefinition([], ['-test'])?.name).to.eql(undefined) expect(Style.Set.getContextDefinition([], ['-section'])?.name).to.eql('section') expect(Style.Set.getContextDefinition([], ['-section--test'])?.name).to.eql('section') expect(Style.Set.getContextDefinition([], ['-inline--badge'])?.name).to.eql('badge') expect(Style.Set.getContextDefinition([], ['-inline--z'])?.name).to.eql('inline') expect(Style.Set.getContextDefinition([], ['-inline-z'])?.name).to.eql(undefined) expect( Style.Set.getContextDefinition( [ { type: 'collection', details: { id: 'z', slug: 'z', title: 'Zizzies' }, props: { type: 'inline' } } ], ['-inline--z'] )?.name ).to.eql('z') expect( Style.Set.getContextDefinition( [ { type: 'collection', details: { id: 'z', slug: 'z', title: 'Zizzies' }, props: { type: 'inline' } }, { type: 'collection', details: { id: 'z-x', slug: 'z-x', title: 'Zizzies XXsses' }, props: { type: 'inline' } } ], ['-inline--z-x'] )?.name ).to.eql('z-x') }) it('should disguise elements', () => { expect(Style.Set.getContextDefinition([], ['-component'])?.name).to.eql('media') expect(Style.Set.getContextDefinition([], ['-embed'])?.name).to.eql('media') expect(Style.Set.getContextDefinition([], ['-list-item'])?.name).to.eql('paragraph') }) it('should disguise elements', () => { expect(Style.Set.getContextDefinition([], ['-component'])?.name).to.eql('media') }) }) it('should disguise elements', () => { expect(Style.Set.getContextDefinition([], ['-component'])?.name).to.eql('media') }) it('should disguise elements', () => { expect(Style.Set.getContextDefinition([], ['-component--form'], false)?.name).to.eql('form') expect(Style.Set.getContextDefinition([], ['-component--form', '-block--media'], false)?.name).to.eql('form') expect(Style.Set.getContextDefinition([], ['-component--form', '-block--media--test'], false)?.name).to.eql( 'form' ) }) }) })