-
Notifications
You must be signed in to change notification settings - Fork 0
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
3 changed files
with
45 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import fs from 'node:fs'; | ||
import path from 'node:path'; | ||
import { execSync } from 'node:child_process'; | ||
import { fileURLToPath } from 'node:url'; | ||
|
||
import { describe, it, expect } from 'vitest'; | ||
|
||
describe( | ||
'Examples', | ||
() => { | ||
it('should build nuxt', async () => { | ||
const root = path.join(fileURLToPath(import.meta.url), '../../../../examples/nuxt/'); | ||
execSync(`pnpm run generate`, { cwd: root }); | ||
const indexHtml = await fs.promises.readFile(path.join(root, 'dist', 'index.html'), 'utf-8'); | ||
|
||
const expected = [ | ||
`<script defer data-website-id="a8602a4a-8d41-4df7-9797-5bd074785f2c" src="https://umami.onekuma.cn/script.js"></script>`, | ||
`<script defer data-domain="garden.onekuma.cn" src="https://plausible.io/js/script.js"></script>`, | ||
`<script defer data-cf-beacon="{"token": "aa68fa3bf166467082bc79ba029b057f"}" src="https://static.cloudflareinsights.com/beacon.min.js"></script>`, | ||
`(window, document, "clarity", "script", "kwj19d7z4j")` | ||
]; | ||
for (const text of expected) { | ||
expect(indexHtml.indexOf(text) !== -1).toBeTruthy(); | ||
} | ||
}); | ||
|
||
it('should build astro', async () => { | ||
const root = path.join(fileURLToPath(import.meta.url), '../../../../examples/astro/'); | ||
execSync(`pnpm run build`, { cwd: root }); | ||
const indexHtml = await fs.promises.readFile(path.join(root, 'dist', 'index.html'), 'utf-8'); | ||
|
||
const expected = [ | ||
`<script src="https://umami.onekuma.cn/script.js" defer data-website-id="a8602a4a-8d41-4df7-9797-5bd074785f2c"></script>`, | ||
`<script src="https://plausible.io/js/script.js" defer data-domain="garden.onekuma.cn"></script>`, | ||
`<script src="https://static.cloudflareinsights.com/beacon.min.js" defer data-cf-beacon="{"token": "aa68fa3bf166467082bc79ba029b057f"}"></script>`, | ||
`(window, document, "clarity", "script", "kwj19d7z4j")` | ||
]; | ||
for (const text of expected) { | ||
expect(indexHtml.indexOf(text) !== -1).toBeTruthy(); | ||
} | ||
}); | ||
}, | ||
20 * 1000 | ||
); |
This file was deleted.
Oops, something went wrong.
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