diff --git a/packages/astro/test/astro-object-style.test.js b/packages/astro/test/astro-object-style.test.js new file mode 100644 index 000000000000..adcc43bd9ca5 --- /dev/null +++ b/packages/astro/test/astro-object-style.test.js @@ -0,0 +1,32 @@ +import { expect } from 'chai'; +import * as cheerio from 'cheerio'; +import { loadFixture } from './test-utils.js'; + +describe('Object style', async () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ root: './fixtures/astro-object-style/' }); + await fixture.build(); + }); + + it('Passes style attributes as expected to elements', async () => { + const html = await fixture.readFile('/index.html'); + const $ = cheerio.load(html); + + expect($('[style="background-color:green"]')).to.have.lengthOf(1); + expect($('[style="background-color:red"]')).to.have.lengthOf(1); + expect($('[style="background-color:blue"]')).to.have.lengthOf(1); + expect($(`[style='background-image:url("a")']`)).to.have.lengthOf(1); + }); + + it('Passes style attributes as expected to components', async () => { + const html = await fixture.readFile('/component/index.html'); + const $ = cheerio.load(html); + + expect($('[style="background-color:green"]')).to.have.lengthOf(1); + expect($('[style="background-color:red"]')).to.have.lengthOf(1); + expect($('[style="background-color:blue"]')).to.have.lengthOf(1); + expect($(`[style='background-image:url("a")']`)).to.have.lengthOf(1); + }); +}); diff --git a/packages/astro/test/fixtures/astro-object-style/package.json b/packages/astro/test/fixtures/astro-object-style/package.json new file mode 100644 index 000000000000..187af34d712b --- /dev/null +++ b/packages/astro/test/fixtures/astro-object-style/package.json @@ -0,0 +1,8 @@ +{ + "name": "@test/astro-class-list", + "version": "0.0.0", + "private": true, + "dependencies": { + "astro": "workspace:*" + } +} diff --git a/packages/astro/test/fixtures/astro-object-style/src/components/Span.astro b/packages/astro/test/fixtures/astro-object-style/src/components/Span.astro new file mode 100644 index 000000000000..bfadf035c518 --- /dev/null +++ b/packages/astro/test/fixtures/astro-object-style/src/components/Span.astro @@ -0,0 +1 @@ + diff --git a/packages/astro/test/fixtures/astro-object-style/src/pages/component.astro b/packages/astro/test/fixtures/astro-object-style/src/pages/component.astro new file mode 100644 index 000000000000..549990347183 --- /dev/null +++ b/packages/astro/test/fixtures/astro-object-style/src/pages/component.astro @@ -0,0 +1,10 @@ +--- +import Component from '../components/Span.astro' +--- + + + + + + + diff --git a/packages/astro/test/fixtures/astro-object-style/src/pages/index.astro b/packages/astro/test/fixtures/astro-object-style/src/pages/index.astro new file mode 100644 index 000000000000..9ab066a5c2fe --- /dev/null +++ b/packages/astro/test/fixtures/astro-object-style/src/pages/index.astro @@ -0,0 +1,7 @@ + + + + + + +