Skip to content

Commit 5bf152a

Browse files
authored
Final Prettier Test Migration (#1510)
1 parent 1bcd1de commit 5bf152a

90 files changed

Lines changed: 563 additions & 381 deletions

File tree

Some content is hidden

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

src/slang-utils/create-hug-function.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ export function createHugFunction(
1818
{
1919
kind: NonterminalKind.TupleExpression,
2020
loc: { ...loc },
21-
comments: [],
21+
comments: undefined,
2222
items: Object.assign(
2323
Object.create(TupleValues.prototype) as TupleValues,
2424
{
2525
kind: NonterminalKind.TupleValues,
2626
loc: { ...loc },
27-
comments: [],
27+
comments: undefined,
2828
items: [
2929
Object.assign(
3030
Object.create(TupleValue.prototype) as TupleValue,
3131
{
3232
kind: NonterminalKind.TupleValue,
3333
loc: { ...loc },
34-
comments: [],
34+
comments: undefined,
3535
expression: node
3636
}
3737
)
File renamed without changes.

tests/config/constants.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const FORMAT_TEST_DIRECTORY = normalizeDirectory(
1010
path.join(__dirname, "../format/"),
1111
);
1212

13-
export const { FULL_TEST } = process.env;
13+
export const { FULL_TEST, TEST_STANDALONE } = process.env;
1414
export const BOM = "\uFEFF";
1515

1616
export const CURSOR_PLACEHOLDER = "<|>";
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { wrap as raw } from "jest-snapshot-serializer-raw";
2-
import { CURSOR_PLACEHOLDER } from "../constants.js";
2+
import { CURSOR_PLACEHOLDER } from "./constants.js";
33
import visualizeEndOfLine from "./visualize-end-of-line.js";
44
import visualizeRange from "./visualize-range.js";
55

tests/config/format-test-setup.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import runFormatTest from "./run-format-test.js";
1+
import { runFormatTest } from "./run-format-test.js";
22

33
globalThis.runFormatTest = runFormatTest;

tests/config/get-create-parser.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
import { TEST_STANDALONE } from "./constants.js";
2+
13
function getCreateParserInternal() {
2-
const entry = process.env.TEST_STANDALONE
4+
const entry = TEST_STANDALONE
35
? "../../dist/create-parser.js"
46
: "../../src/slang-utils/create-parser.js";
57

tests/config/get-fixtures.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
import fs from "node:fs";
22
import path from "node:path";
33
import { FORMAT_SCRIPT_FILENAME } from "./constants.js";
4-
import visualizeEndOfLine from "./utils/visualize-end-of-line.js";
4+
import visualizeEndOfLine from "./visualize-end-of-line.js";
55

6+
/**
7+
@import {Context} from "./run-format-test.js"
8+
@typedef {Exclude<ReturnType<ReturnType<getFixtures>["next"]>["value"], void>} Fixture
9+
*/
10+
11+
/**
12+
@param {Context} context
13+
*/
614
function* getFixtures(context) {
715
yield* getFiles(context);
816
yield* getSnippets(context);
917
}
1018

19+
/**
20+
@param {Context} context
21+
*/
1122
function* getFiles(context) {
1223
const { dirname } = context;
1324
for (const file of fs.readdirSync(dirname, { withFileTypes: true })) {
@@ -36,6 +47,9 @@ function* getFiles(context) {
3647
}
3748
}
3849

50+
/**
51+
@param {Context} context
52+
*/
3953
function* getSnippets(context) {
4054
for (const [index, snippet] of context.snippets.entries()) {
4155
const testCase =

tests/config/get-plugins.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import path from "node:path";
22
import createEsmUtils from "esm-utils";
33
import getPrettier from "./get-prettier.js";
4+
import { TEST_STANDALONE } from "./constants.js";
45

56
const { __dirname } = createEsmUtils(import.meta);
67

78
// populate the root object for the standalone in node
8-
if (process.env.TEST_STANDALONE) {
9+
if (TEST_STANDALONE) {
910
const root =
1011
typeof globalThis !== "undefined"
1112
? globalThis
@@ -19,7 +20,7 @@ if (process.env.TEST_STANDALONE) {
1920

2021
function getPluginsInternal() {
2122
return Promise.all(
22-
process.env.TEST_STANDALONE
23+
TEST_STANDALONE
2324
? [
2425
import("prettier/plugins/babel"),
2526
import("prettier/plugins/estree"),

tests/config/get-prettier.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
import { TEST_STANDALONE } from "./constants.js";
2+
13
function getPrettierInternal() {
2-
const entry = process.env.TEST_STANDALONE
3-
? "prettier/standalone"
4-
: "prettier";
4+
const entry = TEST_STANDALONE ? "prettier/standalone" : "prettier";
55

66
return import(entry).then((module) => module.default);
77
}

0 commit comments

Comments
 (0)