Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
test: it should correctly resolve "SettingsType.ANY" in the rc file
  • Loading branch information
jj811208 committed Nov 23, 2022
commit 1088515e7ec2c9007e2acf6da7a79f8aaed9917f
61 changes: 61 additions & 0 deletions packages/yarnpkg-core/tests/Configuration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,6 +664,26 @@ describe(`Configuration`, () => {
},
},
},
any: {
description: "",
type: "ANY",
default: "",
},
anyReset: {
description: "",
type: "ANY",
default: "",
},
anyExtend: {
description: "",
type: "ANY",
default: "",
},
anyHardReset: {
description: "",
type: "ANY",
default: "",
},
}`);

await initializeConfiguration({
Expand Down Expand Up @@ -700,6 +720,18 @@ describe(`Configuration`, () => {
mapHardReset: {
foo: {string: `foo`},
},
any: {
foo: {string: `foo`},
},
anyReset: {
foo: {string: `foo`},
},
anyExtend: {
foo: {string: `foo`},
},
anyHardReset: {
foo: {string: `foo`},
},
}, async dir => {
const workspaceDirectory = `${dir}/workspace` as PortablePath;
await xfs.mkdirPromise(workspaceDirectory);
Expand Down Expand Up @@ -772,6 +804,27 @@ describe(`Configuration`, () => {
bar: {number: 2, string: `bar`},
},
},
any: {
bar: {number: 2, string: `bar`},
},
anyReset: {
onConflict: `reset`,
value: {
bar: {number: 2, string: `bar`},
},
},
anyExtend: {
onConflict: `extend`,
value: {
bar: {number: 2, string: `bar`},
},
},
anyHardReset: {
onConflict: `hardReset`,
value: {
bar: {number: 2, string: `bar`},
},
},
}));

const workspaceDirectory2 = `${dir}/workspace/workspace` as PortablePath;
Expand All @@ -785,6 +838,9 @@ describe(`Configuration`, () => {
mapHardReset: {
baz: {string: `baz`},
},
anyHardReset: {
baz: {string: `baz`},
},
}));

const configuration = await Configuration.find(workspaceDirectory2, pluginConfiguration);
Expand Down Expand Up @@ -818,6 +874,11 @@ describe(`Configuration`, () => {
expect(configuration.get(`mapHardReset`)).toEqual(new Map([
[`baz`, new Map<string, any>([[`number`, 0], [`string`, `baz`]])],
]));

expect(configuration.get(`any`)).toEqual({bar: {number: `2`, string: `bar`}, foo: {string: `foo`}});
expect(configuration.get(`anyReset`)).toEqual({bar: {number: `2`, string: `bar`}});
expect(configuration.get(`anyExtend`)).toEqual({bar: {number: `2`, string: `bar`}, foo: {string: `foo`}});
expect(configuration.get(`anyHardReset`)).toEqual({baz: {string: `baz`}});
});
});
});
Expand Down