Skip to content

Commit d7a28b9

Browse files
committed
chore(tests): add test cases for various languages with formatting issues
1 parent 536408e commit d7a28b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+775
-1
lines changed

tests/__snapshots__/fixtures.spec.ts.snap

Lines changed: 468 additions & 0 deletions
Large diffs are not rendered by default.

tests/fixtures.spec.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { existsSync, readFileSync } from "node:fs";
22
import path from "node:path";
33
import prettier from "prettier";
44
import { globSync } from "tinyglobby";
5-
import { describe, expect, it } from "vitest";
5+
import { beforeAll, describe, expect, it } from "vitest";
66
import * as embed from "../src";
77

88
interface LanguageOptions {
@@ -95,6 +95,11 @@ for (const languageDir of languageDirs) {
9595

9696
// Create a describe block for each language
9797
describe(language, () => {
98+
beforeAll(() => {
99+
// mute pug logs during tests
100+
process.env.PRETTIER_PLUGIN_PUG_LOG_LEVEL = "off";
101+
});
102+
98103
for (const file of files) {
99104
// Skip options.json
100105
if (file.endsWith("options.json")) {

tests/fixtures/css/basic.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// CSS - Tag `css` test (with formatting issues)
2+
const tagTest = css`
3+
.container{padding:10px;margin:5px}.button{background:blue;color:white}
4+
`;
5+
6+
// CSS - Comment `/* css */` test (with formatting issues)
7+
/* css */ `
8+
body{font-size:14px;line-height:1.5}div{display:flex;justify-content:center}
9+
`;

tests/fixtures/es/basic.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// ES/JavaScript - Tag `js` test (with formatting issues)
2+
const tagTest = js`
3+
function test(a,b){return a+b}const x=1,y=2;
4+
`;
5+
6+
// ES/JavaScript - Comment `/* js */` test (with formatting issues)
7+
/* js */ `
8+
const obj={name:"test",value:42};const arr=[1,2,3];
9+
`;

tests/fixtures/glsl/basic.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// GLSL - Tag `glsl` test (with formatting issues)
2+
const tagTest = glsl`
3+
attribute vec3 position;uniform mat4 matrix;void main(){gl_Position=matrix*vec4(position,1.0);}
4+
`;
5+
6+
// GLSL - Comment `/* glsl */` test (with formatting issues)
7+
/* glsl */ `
8+
varying vec3 color;void main(){gl_FragColor=vec4(color,1.0);}
9+
`;

tests/fixtures/glsl/options.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["prettier-plugin-glsl"]
3+
}

tests/fixtures/graphql/basic.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// GraphQL - Tag `graphql` test (with formatting issues)
2+
const tagTest = graphql`
3+
query GetUser($id:ID!){user(id:$id){id name email}}
4+
`;
5+
6+
// GraphQL - Comment `/* graphql */` test (with formatting issues)
7+
/* graphql */ `
8+
mutation CreateUser($name:String!,$email:String!){createUser(name:$name,email:$email){id}}
9+
`;

tests/fixtures/html/basic.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// HTML - Tag `html` test (with formatting issues)
2+
const tagTest = html`
3+
<div class="container"><p>Hello</p><span>World</span></div>
4+
`;
5+
6+
// HTML - Comment `/* html */` test (with formatting issues)
7+
/* html */ `
8+
<form><input type="text" placeholder="Name"><button type="submit">Submit</button></form>
9+
`;

tests/fixtures/ini/basic.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// INI - Tag `ini` test (with formatting issues: inconsistent spacing)
2+
const tagTest = ini`
3+
[database]
4+
host=localhost
5+
port =5432
6+
user= admin
7+
`;
8+
9+
// INI - Comment `/* ini */` test (with formatting issues)
10+
/* ini */ `
11+
[server]
12+
address=0.0.0.0
13+
timeout= 30
14+
`;

tests/fixtures/ini/options.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"plugins": ["prettier-plugin-ini"]
3+
}

0 commit comments

Comments
 (0)