mirror of
https://github.com/withastro/astro.git
synced 2025-01-06 22:10:10 -05:00
4df1347156
* chore: use monorepo * chore: scaffold astro-scripts * chore: move tests inside packages/astro * chore: refactor tests, add scripts * chore: move parser to own module * chore: move runtime to packages/astro * fix: move parser to own package * test: fix prettier-plugin-astro tests * fix: tests * chore: update package-lock * chore: add changesets * fix: cleanup examples * fix: starter example * chore: update changeset config * chore: update changeset config * chore: setup changeset release workflow * chore: bump lockfiles * chore: prism => astro-prism * fix: tsc --emitDeclarationOnly * chore: final cleanup, switch to yarn * chore: add lerna * chore: update workflows to yarn * chore: update workflows * chore: remove lint workflow * chore: add astro-dev script * chore: add symlinked README
44 lines
1.3 KiB
JavaScript
44 lines
1.3 KiB
JavaScript
import { suite } from 'uvu';
|
|
import * as assert from 'uvu/assert';
|
|
import { format } from './test-utils.js';
|
|
import { promises as fs } from 'fs';
|
|
import { fileURLToPath } from 'url'
|
|
const Prettier = suite('Prettier formatting');
|
|
|
|
const readFile = (path) => fs.readFile(fileURLToPath(new URL(`./fixtures${path}`, import.meta.url))).then(res => res.toString())
|
|
|
|
/**
|
|
* Utility to get `[src, out]` files
|
|
* @param name {string}
|
|
* @param ctx {any}
|
|
*/
|
|
const getFiles = async (name) => {
|
|
const [src, out] = await Promise.all([readFile(`/in/${name}.astro`), readFile(`/out/${name}.astro`)]);
|
|
return [src, out];
|
|
};
|
|
|
|
Prettier('can format a basic Astro file', async () => {
|
|
const [src, out] = await getFiles('basic');
|
|
assert.not.equal(src, out);
|
|
|
|
const formatted = format(src);
|
|
assert.equal(formatted, out);
|
|
});
|
|
|
|
Prettier('can format an Astro file with frontmatter', async () => {
|
|
const [src, out] = await getFiles('frontmatter');
|
|
assert.not.equal(src, out);
|
|
|
|
const formatted = format(src);
|
|
assert.equal(formatted, out);
|
|
});
|
|
|
|
Prettier('can format an Astro file with embedded JSX expressions', async () => {
|
|
const [src, out] = await getFiles('embedded-expr');
|
|
assert.not.equal(src, out);
|
|
|
|
const formatted = format(src);
|
|
assert.equal(formatted, out);
|
|
});
|
|
|
|
Prettier.run();
|