Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Calvin-LL committed Sep 27, 2022
1 parent 7b85f62 commit 75655a3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
32 changes: 32 additions & 0 deletions packages/astro/test/astro-object-style.test.js
Original file line number Diff line number Diff line change
@@ -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);
});
});
8 changes: 8 additions & 0 deletions packages/astro/test/fixtures/astro-object-style/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@test/astro-class-list",
"version": "0.0.0",
"private": true,
"dependencies": {
"astro": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<span {...Astro.props} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
import Component from '../components/Span.astro'
---
<Component style="background-color:green" />

<Component style={"background-color:red"} />

<Component style={{backgroundColor:"blue"}} />

<Component style={{backgroundImage:'url("a")'}} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<span style="background-color:green" />

<span style={"background-color:red"} />

<span style={{backgroundColor:"blue"}} />

<span style={{backgroundImage:'url("a")'}} />

0 comments on commit 75655a3

Please sign in to comment.