Fix collector testing related to plugins key change

Signed-off-by: Eric Peterson <ericpeterson@spotify.com>
This commit is contained in:
Eric Peterson
2023-06-06 15:57:52 +02:00
parent 12adfbc8fe
commit 905e26e780
4 changed files with 9 additions and 6 deletions
@@ -112,16 +112,17 @@ function routeObj(
caseSensitive: false,
element: type,
routeRefs: new Set(refs),
plugins: backstagePlugin ? new Set([backstagePlugin]) : new Set(),
children: [
{
path: '*',
caseSensitive: false,
element: 'match-all',
routeRefs: new Set(),
plugins: new Set(),
},
...children,
],
plugin: backstagePlugin,
};
}
@@ -129,12 +129,14 @@ describe.each(['beta', 'stable'])('react-router %s', rrVersion => {
caseSensitive: false,
element: type,
routeRefs: new Set(refs),
plugins: new Set(),
children: [
{
path: '*',
caseSensitive: false,
element: 'match-all',
routeRefs: new Set(),
plugins: new Set(),
},
...children,
],
@@ -118,10 +118,11 @@ function routeObj(
caseSensitive: false,
element: 'match-all',
routeRefs: new Set(),
plugins: new Set(),
},
...children,
],
plugin: backstagePlugin,
plugins: backstagePlugin ? new Set([backstagePlugin]) : new Set(),
};
}
@@ -333,11 +334,11 @@ describe('discovery', () => {
[ref5, ref3],
]);
expect(routing.objects).toEqual([
routeObj('foo', [ref1, ref2], [], 'gathered'),
routeObj('foo', [ref1, ref2], [], 'gathered', plugin),
routeObj(
'bar',
[ref3],
[routeObj('', [ref4, ref5], [], 'gathered')],
[routeObj('', [ref4, ref5], [], 'gathered', plugin)],
undefined,
plugin,
),
@@ -403,6 +404,7 @@ describe('discovery', () => {
),
],
'gathered',
plugin,
),
],
undefined,
@@ -144,7 +144,6 @@ export const routingV2Collector = createCollector(
caseSensitive: Boolean(node.props?.caseSensitive),
children: [MATCH_ALL_ROUTE],
plugins: new Set<BackstagePlugin>(),
plugin: undefined,
};
parentChildren.push(newObj);
@@ -175,7 +174,6 @@ export const routingV2Collector = createCollector(
caseSensitive: Boolean(node.props?.caseSensitive),
children: [MATCH_ALL_ROUTE],
plugins: pluginSet(plugin),
plugin,
};
parentChildren.push(newObj);
acc.paths.set(routeRef, path);