-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
877 additions
and
1,943 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
/** | ||
* UNCOMMENT: add support for automatic <img> and srcset in build | ||
import { expect } from 'chai'; | ||
import { loadFixture } from './test-utils'; | ||
let fixture; | ||
beforeAll(async () => { | ||
before(async () => { | ||
fixture = await loadFixture({ projectRoot: './fixtures/astro-assets/' }); | ||
await fixture.build(); | ||
}); | ||
// TODO: add automatic asset bundling | ||
describe('Assets', () => { | ||
test('built the base image', async () => { | ||
it('built the base image', async () => { | ||
await fixture.readFile('/images/twitter.png'); | ||
}); | ||
test('built the 2x image', async () => { | ||
it('built the 2x image', async () => { | ||
await fixture.readFile('/images/twitter@2x.png'); | ||
}); | ||
test('built the 3x image', async () => { | ||
it('built the 3x image', async () => { | ||
await fixture.readFile('/images/twitter@3x.png'); | ||
}); | ||
}); | ||
*/ | ||
|
||
test.skip('is skipped', () => {}); | ||
it.skip('is skipped', () => {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,96 +1,97 @@ | ||
import { expect } from 'chai'; | ||
import cheerio from 'cheerio'; | ||
import { loadFixture } from './test-utils.js'; | ||
|
||
let fixture; | ||
let previewServer; | ||
|
||
beforeAll(async () => { | ||
before(async () => { | ||
fixture = await loadFixture({ projectRoot: './fixtures/astro-basic/' }); | ||
await fixture.build(); | ||
previewServer = await fixture.preview(); | ||
}); | ||
|
||
describe('Astro basics', () => { | ||
describe('build', () => { | ||
test('Can load page', async () => { | ||
it('Can load page', async () => { | ||
const html = await fixture.readFile(`/index.html`); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('h1').text()).toBe('Hello world!'); | ||
expect($('h1').text()).to.equal('Hello world!'); | ||
}); | ||
|
||
test('Correctly serializes boolean attributes', async () => { | ||
it('Correctly serializes boolean attributes', async () => { | ||
const html = await fixture.readFile('/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('h1').attr('data-something')).toBe(''); | ||
expect($('h2').attr('not-data-ok')).toBe(''); | ||
expect($('h1').attr('data-something')).to.equal(''); | ||
expect($('h2').attr('not-data-ok')).to.equal(''); | ||
}); | ||
|
||
test('Selector with an empty body', async () => { | ||
it('Selector with an empty body', async () => { | ||
const html = await fixture.readFile('/empty-class/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('.author')).toHaveLength(1); | ||
expect($('.author')).to.have.lengthOf(1); | ||
}); | ||
|
||
test('Allows forward-slashes in mustache tags (#407)', async () => { | ||
it('Allows forward-slashes in mustache tags (#407)', async () => { | ||
const html = await fixture.readFile('/forward-slash/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('a[href="/post/one"]')).toHaveLength(1); | ||
expect($('a[href="/post/two"]')).toHaveLength(1); | ||
expect($('a[href="/post/three"]')).toHaveLength(1); | ||
expect($('a[href="/post/one"]')).to.have.lengthOf(1); | ||
expect($('a[href="/post/two"]')).to.have.lengthOf(1); | ||
expect($('a[href="/post/three"]')).to.have.lengthOf(1); | ||
}); | ||
|
||
test('Allows spread attributes (#521)', async () => { | ||
it('Allows spread attributes (#521)', async () => { | ||
const html = await fixture.readFile('/spread/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('#spread-leading')).toHaveLength(1); | ||
expect($('#spread-leading').attr('a')).toBe('0'); | ||
expect($('#spread-leading').attr('b')).toBe('1'); | ||
expect($('#spread-leading').attr('c')).toBe('2'); | ||
expect($('#spread-leading')).to.have.lengthOf(1); | ||
expect($('#spread-leading').attr('a')).to.equal('0'); | ||
expect($('#spread-leading').attr('b')).to.equal('1'); | ||
expect($('#spread-leading').attr('c')).to.equal('2'); | ||
|
||
expect($('#spread-trailing')).toHaveLength(1); | ||
expect($('#spread-trailing').attr('a')).toBe('0'); | ||
expect($('#spread-trailing').attr('b')).toBe('1'); | ||
expect($('#spread-trailing').attr('c')).toBe('2'); | ||
expect($('#spread-trailing')).to.have.lengthOf(1); | ||
expect($('#spread-trailing').attr('a')).to.equal('0'); | ||
expect($('#spread-trailing').attr('b')).to.equal('1'); | ||
expect($('#spread-trailing').attr('c')).to.equal('2'); | ||
}); | ||
|
||
test('Allows spread attributes with TypeScript (#521)', async () => { | ||
it('Allows spread attributes with TypeScript (#521)', async () => { | ||
const html = await fixture.readFile('/spread/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
expect($('#spread-ts')).toHaveLength(1); | ||
expect($('#spread-ts').attr('a')).toBe('0'); | ||
expect($('#spread-ts').attr('b')).toBe('1'); | ||
expect($('#spread-ts').attr('c')).toBe('2'); | ||
expect($('#spread-ts')).to.have.lengthOf(1); | ||
expect($('#spread-ts').attr('a')).to.equal('0'); | ||
expect($('#spread-ts').attr('b')).to.equal('1'); | ||
expect($('#spread-ts').attr('c')).to.equal('2'); | ||
}); | ||
|
||
test('Allows using the Fragment element to be used', async () => { | ||
it('Allows using the Fragment element to be used', async () => { | ||
const html = await fixture.readFile('/fragment/index.html'); | ||
const $ = cheerio.load(html); | ||
|
||
// will be 1 if element rendered correctly | ||
expect($('#one')).toHaveLength(1); | ||
expect($('#one')).to.have.lengthOf(1); | ||
}); | ||
}); | ||
|
||
describe('preview', () => { | ||
test('returns 200 for valid URLs', async () => { | ||
it('returns 200 for valid URLs', async () => { | ||
const result = await fixture.fetch('/'); | ||
expect(result.status).toBe(200); | ||
expect(result.status).to.equal(200); | ||
}); | ||
|
||
test('returns 404 for invalid URLs', async () => { | ||
it('returns 404 for invalid URLs', async () => { | ||
const result = await fixture.fetch('/bad-url'); | ||
expect(result.status).toBe(404); | ||
expect(result.status).to.equal(404); | ||
}); | ||
}); | ||
}); | ||
|
||
// important: close preview server (free up port and connection) | ||
afterAll(async () => { | ||
after(async () => { | ||
if (previewServer) await previewServer.stop(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.