Skip to content

Commit eda6e30

Browse files
committed
revert unexpected test case changes
1 parent 5957a1d commit eda6e30

2 files changed

Lines changed: 26 additions & 19 deletions

File tree

packages/typespec-ts/test-next/unit/metadata/package-json.test.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ describe("Package file generation", () => {
123123
expect(packageFile["//sampleConfiguration"]).toEqual(expectedSampleConfig);
124124
});
125125

126-
it("[esm] should include correct base entrypoints by default", () => {
126+
it("[esm] should include correct entrypoints (without react-native by default)", () => {
127127
const model = createMockModel({
128128
...baseConfig,
129129
withSamples: true,
@@ -138,9 +138,13 @@ describe("Package file generation", () => {
138138
expect(packageFile).to.have.property("module", "./dist/esm/index.js");
139139
expect(packageFile).to.have.property("types", "./dist/commonjs/index.d.ts");
140140
expect(packageFile).to.have.property("browser", "./dist/browser/index.js");
141+
// Default: no react-native entrypoint
142+
expect(packageFile).not.toHaveProperty("react-native");
141143
expect(packageFile).to.have.property("exports");
142144
expect(packageFile.exports["./package.json"]).to.equal("./package.json");
143145
expect(packageFile.exports["."]).to.have.property("browser");
146+
// Default: no react-native in exports
147+
expect(packageFile.exports["."]).not.toHaveProperty("react-native");
144148
expect(packageFile.exports["."]).to.have.property("import");
145149
expect(packageFile.exports["."]).to.have.property("require");
146150
expect(packageFile.exports["."]["import"]).toEqual({
@@ -149,21 +153,20 @@ describe("Package file generation", () => {
149153
});
150154
});
151155

152-
it("[esm] should include consistent export conditions", () => {
156+
it("[esm] should include react-native entrypoints when generateReactNativeTarget is true", () => {
153157
const model = createMockModel({
154158
...baseConfig,
155159
withSamples: true,
160+
generateReactNativeTarget: true,
156161
});
157162
const packageFileContent = buildPackageFile(model);
158163
const packageFile = JSON.parse(packageFileContent?.content ?? "{}");
159164

160-
expect(packageFile.exports["."]["browser"]).toEqual({
161-
types: "./dist/browser/index.d.ts",
162-
default: "./dist/browser/index.js",
163-
});
164-
expect(packageFile.exports["."]["require"]).toEqual({
165-
types: "./dist/commonjs/index.d.ts",
166-
default: "./dist/commonjs/index.js",
165+
expect(packageFile).to.have.property("react-native", "./dist/react-native/index.js");
166+
expect(packageFile.exports["."]).to.have.property("react-native");
167+
expect(packageFile.exports["."]["react-native"]).toEqual({
168+
types: "./dist/react-native/index.d.ts",
169+
default: "./dist/react-native/index.js",
167170
});
168171
});
169172

@@ -314,7 +317,7 @@ describe("Package file generation", () => {
314317
expect(packageFile.scripts).to.have.property("pack", "pnpm pack 2>&1");
315318
});
316319

317-
it("should include browser entrypoint by default for modular ARM packages", () => {
320+
it("should include browser but not react-native entrypoints by default", () => {
318321
const model = createMockModel({
319322
...baseConfig,
320323
azureArm: true,
@@ -324,21 +327,22 @@ describe("Package file generation", () => {
324327
const packageFile = JSON.parse(packageFileContent?.content ?? "{}");
325328

326329
expect(packageFile).to.have.property("browser", "./dist/browser/index.js");
327-
expect(packageFile.exports["."]).to.have.property("browser");
330+
// Default: no react-native entrypoint
331+
expect(packageFile).not.toHaveProperty("react-native");
328332
});
329333

330-
it("should include standard export conditions for modular ARM packages", () => {
334+
it("should include react-native entrypoint when generateReactNativeTarget is true", () => {
331335
const model = createMockModel({
332336
...baseConfig,
333337
azureArm: true,
334338
isModularLibrary: true,
339+
generateReactNativeTarget: true,
335340
});
336341
const packageFileContent = buildPackageFile(model);
337342
const packageFile = JSON.parse(packageFileContent?.content ?? "{}");
338343

339344
expect(packageFile).to.have.property("browser", "./dist/browser/index.js");
340-
expect(packageFile.exports["."]).to.have.property("import");
341-
expect(packageFile.exports["."]).to.have.property("require");
345+
expect(packageFile).to.have.property("react-native", "./dist/react-native/index.js");
342346
});
343347
});
344348

packages/typespec-ts/test-next/unit/metadata/warp-config.test.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,35 @@ import { buildWarpConfig } from "../../../src/metadata/build-warp-config.js";
77
import { createMockModel } from "./mock-helper.js";
88

99
describe("warp.config.yml generation", () => {
10-
it("should generate a self-contained config without polyfillSuffix by default", () => {
10+
it("should generate a self-contained config without polyfillSuffix and without react-native by default", () => {
1111
const model = createMockModel({});
1212

1313
const result = buildWarpConfig(model);
1414
expect(result).toBeDefined();
1515
expect(result!.path).toBe("warp.config.yml");
1616
expect(result!.content).not.toContain("extends:");
1717
expect(result!.content).not.toContain("polyfillSuffix");
18+
// Default: three targets without react-native
1819
expect(result!.content).toContain("name: browser");
20+
expect(result!.content).not.toContain("name: react-native");
1921
expect(result!.content).toContain("name: esm");
2022
expect(result!.content).toContain("name: commonjs");
2123
expect(result!.content).toContain("tsconfig:");
2224
expect(result!.content).toContain('"./package.json"');
2325
expect(result!.content).toContain('"."');
2426
});
2527

26-
it("should include the standard build targets", () => {
27-
const model = createMockModel({});
28+
it("should include react-native target when generateReactNativeTarget is true", () => {
29+
const model = createMockModel({
30+
generateReactNativeTarget: true,
31+
});
2832

2933
const result = buildWarpConfig(model);
3034
expect(result).toBeDefined();
31-
expect(result!.path).toBe("warp.config.yml");
3235
expect(result!.content).toContain("name: browser");
36+
expect(result!.content).toContain("name: react-native");
3337
expect(result!.content).toContain("name: esm");
3438
expect(result!.content).toContain("name: commonjs");
35-
expect(result!.content).toContain("moduleType: commonjs");
3639
});
3740

3841
it("should include custom exports alongside base exports", () => {

0 commit comments

Comments
 (0)