Skip to content

Commit

Permalink
Tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HorusGoul committed Mar 29, 2024
1 parent 232f5ac commit 6a369c6
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 121 deletions.
13 changes: 1 addition & 12 deletions apps/qwik-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,9 @@ describe("build output", () => {
});
});

test("built assets should contain a stylex stylesheet", async () => {
const files = await fs.readdir(publicAssetsDir);
const stylexFile = files.some(
(file) => file.includes("stylex") && file.endsWith(".css")
);

assert.ok(stylexFile, "an stylex file should exist in the build output");
});

test("stylex stylesheet contains the expected styles", async () => {
const files = await fs.readdir(publicAssetsDir);
const stylexFile = files.find(
(file) => file.includes("stylex") && file.endsWith(".css")
);
const stylexFile = files.find((file) => file.endsWith(".css"));
const stylexCss = await fs.readFile(
path.join(publicAssetsDir, stylexFile!),
"utf-8"
Expand Down
12 changes: 8 additions & 4 deletions apps/react-strict-dom-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("build output", () => {
test("built assets should contain a stylex stylesheet", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.some(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);

assert.ok(stylexFile, "an stylex file should exist in the build output");
Expand All @@ -58,8 +58,12 @@ describe("build output", () => {
path.join(tempDir, "index.html"),
"utf-8"
);
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.some(
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexLink = indexHtml.includes(
`<link rel="stylesheet" href="/assets/stylex.`
`<link rel="stylesheet" href="/assets/${stylexFile}`
);

assert.ok(
Expand All @@ -71,7 +75,7 @@ describe("build output", () => {
test("stylex stylesheet contains the expected styles", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.find(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexCss = await fs.readFile(
path.join(tempDir, "assets", stylexFile),
Expand All @@ -88,7 +92,7 @@ describe("build output", () => {
test("stylex stylesheet contains styles from @stylexjs/open-props package", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.find(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexCss = await fs.readFile(
path.join(tempDir, "assets", stylexFile),
Expand Down
27 changes: 0 additions & 27 deletions apps/remix-css-url-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,6 @@ describe("build output", () => {
assert.ok(!stylexFile, "stylex file should not be in the build output");
});

test("stylex file should not be in the server build output", async () => {
const files = await fs
.readdir(path.join(tempDir, "build", "server", "assets"))
// Catching if the directory doesn't exist
.catch(() => []);
const stylexFile = files.some(
(file) => file.includes("stylex.") && file.endsWith(".css")
);

assert.ok(!stylexFile, "stylex file should not be in the build output");
});

test("server-build-HASH.css file should not be in the server build output", async () => {
const files = await fs
.readdir(path.join(tempDir, "build", "server", "assets"))
// Catching if the directory doesn't exist
.catch(() => []);
const stylexFile = files.some(
(file) => file.includes("server-build-") && file.endsWith(".css")
);

assert.ok(
!stylexFile,
"server-build-HASH.css file should not be in the build output"
);
});

describe("remix serve", () => {
let child: cp.ChildProcessWithoutNullStreams;
let address: string;
Expand Down
36 changes: 0 additions & 36 deletions apps/remix-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,42 +109,6 @@ describe("build output", () => {
);
});

test("stylex file should not be in the public build output", async () => {
const files = await fs.readdir(publicAssetsDir);
const stylexFile = files.some(
(file) => file.includes("stylex.") && file.endsWith(".css")
);

assert.ok(!stylexFile, "stylex file should not be in the build output");
});

test("stylex file should not be in the server build output", async () => {
const files = await fs
.readdir(path.join(tempDir, "build", "server", "assets"))
// Catching if the directory doesn't exist
.catch(() => []);
const stylexFile = files.some(
(file) => file.includes("stylex.") && file.endsWith(".css")
);

assert.ok(!stylexFile, "stylex file should not be in the build output");
});

test("server-build-HASH.css file should not be in the server build output", async () => {
const files = await fs
.readdir(path.join(tempDir, "build", "server", "assets"))
// Catching if the directory doesn't exist
.catch(() => []);
const stylexFile = files.some(
(file) => file.includes("server-build-") && file.endsWith(".css")
);

assert.ok(
!stylexFile,
"server-build-HASH.css file should not be in the build output"
);
});

describe("remix serve", () => {
let child: cp.ChildProcessWithoutNullStreams;
let address: string;
Expand Down
26 changes: 1 addition & 25 deletions apps/storybook-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,10 @@ describe("build output", () => {
await fs.rm(tempDir, { recursive: true });
});

test("built assets should contain a stylex stylesheet", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.some(
(file) => file.includes("stylex") && file.endsWith(".css")
);

assert.ok(stylexFile, "an stylex file should exist in the build output");
});

test("iframe.html contains a link to the stylex stylesheet", async () => {
const indexHtml = await fs.readFile(
path.join(tempDir, "iframe.html"),
"utf-8"
);
const stylexLink = indexHtml.includes(
`<link rel="stylesheet" href="assets/stylex.`
);

assert.ok(
stylexLink,
"iframe.html should contain a link to the stylex stylesheet"
);
});

test("stylex stylesheet contains the expected styles", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.find(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.startsWith("preview") && file.endsWith(".css")
);
const stylexCss = await fs.readFile(
path.join(tempDir, "assets", stylexFile),
Expand Down
9 changes: 0 additions & 9 deletions apps/sveltekit-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,6 @@ describe("build", () => {
}
});

test("stylex file should not be in the public build output", async () => {
const files = await fs.readdir(COMPILED_ASSETS_FOLDER);
const stylexFile = files.some(
(file) => file.includes("stylex.") && file.endsWith(".css")
);

assert.ok(!stylexFile, "stylex file should not be in the build output");
});

describe("preview", () => {
let server: vite.PreviewServer;
let serverUrl: string;
Expand Down
12 changes: 8 additions & 4 deletions apps/vite-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("build output", () => {
test("built assets should contain a stylex stylesheet", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.some(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);

assert.ok(stylexFile, "an stylex file should exist in the build output");
Expand All @@ -58,8 +58,12 @@ describe("build output", () => {
path.join(tempDir, "index.html"),
"utf-8"
);
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.some(
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexLink = indexHtml.includes(
`<link rel="stylesheet" href="/assets/stylex.`
`<link rel="stylesheet" href="/assets/${stylexFile}`
);

assert.ok(
Expand All @@ -71,7 +75,7 @@ describe("build output", () => {
test("stylex stylesheet contains the expected styles", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.find(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexCss = await fs.readFile(
path.join(tempDir, "assets", stylexFile),
Expand All @@ -88,7 +92,7 @@ describe("build output", () => {
test("stylex stylesheet contains styles from @stylexjs/open-props package", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.find(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexCss = await fs.readFile(
path.join(tempDir, "assets", stylexFile),
Expand Down
12 changes: 8 additions & 4 deletions apps/vue-demo/test/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ describe("build output", () => {
test("built assets should contain a stylex stylesheet", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.some(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);

assert.ok(stylexFile, "an stylex file should exist in the build output");
Expand All @@ -58,8 +58,12 @@ describe("build output", () => {
path.join(tempDir, "index.html"),
"utf-8"
);
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.some(
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexLink = indexHtml.includes(
`<link rel="stylesheet" href="/assets/stylex.`
`<link rel="stylesheet" href="/assets/${stylexFile}`
);

assert.ok(
Expand All @@ -71,10 +75,10 @@ describe("build output", () => {
test("stylex stylesheet contains the expected styles", async () => {
const files = await fs.readdir(path.join(tempDir, "assets"));
const stylexFile = files.find(
(file) => file.includes("stylex") && file.endsWith(".css")
(file) => file.includes("index") && file.endsWith(".css")
);
const stylexCss = await fs.readFile(
path.join(tempDir, "assets", stylexFile!),
path.join(tempDir, "assets", stylexFile),
"utf-8"
);
const expectedCss = `background-color:#fff`;
Expand Down

0 comments on commit 6a369c6

Please sign in to comment.