From 4b47954dbad430ee78f2e570203c42d6c2fe4b5d Mon Sep 17 00:00:00 2001 From: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com> Date: Wed, 1 Mar 2023 00:16:28 +0100 Subject: [PATCH] Fixup unit test --- .../core/core/test/SymbolPropagation.test.js | 89 +++++++++---------- 1 file changed, 43 insertions(+), 46 deletions(-) diff --git a/packages/core/core/test/SymbolPropagation.test.js b/packages/core/core/test/SymbolPropagation.test.js index 00200da4f6c..3637512153e 100644 --- a/packages/core/core/test/SymbolPropagation.test.js +++ b/packages/core/core/test/SymbolPropagation.test.js @@ -399,6 +399,7 @@ function changeAsset( n => n.type === 'asset' && n.value.filePath === asset, ), ); + node.usedSymbolsUpDirty = true; node.usedSymbolsDownDirty = true; cb(nullthrows(node.value.symbols)); return [[node.id, node.value]]; @@ -508,52 +509,48 @@ describe('SymbolPropagation', () => { ]); }); - // it('basic tree - asset symbol change export and error', async () => { - // // prettier-ignore - // let graph = await testPropagation( - // [ - // ['/index.js', [], true, []], - // ['/lib.js', [['f', {local: 'f'}]], true, ['f']], - // ], - // [ - // ['/index.js', '/lib.js', [['f', {local: 'f', isWeak: false}]], [['f']]], - // ], - // ); - - // let changedAssets = [ - // ...changeAsset(graph, 'lib.js', symbols => { - // symbols.delete('f'); - // symbols.set('f2', { - // local: 'f2', - // loc: undefined, - // }); - // }), - // ]; - - // console.log('----'); - - // await dumpGraphToGraphViz(graph, '2'); - // let errors = propagateSymbols({ - // options: DEFAULT_OPTIONS, - // assetGraph: graph, - // changedAssetsPropagation: new Set(new Map(changedAssets).keys()), - // assetGroupsWithRemovedParents: new Set(), - // }); - // await dumpGraphToGraphViz(graph, '3'); - - // assertPropagationErrors(graph, errors, [ - // [ - // 'lib.js', - // [ - // { - // message: "lib.js does not export 'f2'", - // origin: '@parcel/core', - // codeFrames: undefined, - // }, - // ], - // ], - // ]); - // }); + it('basic tree - asset symbol change export and error', async () => { + // prettier-ignore + let graph = await testPropagation( + [ + ['/index.js', [], true, []], + ['/lib.js', [['f', {local: 'f'}]], true, ['f']], + ], + [ + ['/index.js', '/lib.js', [['f', {local: 'f', isWeak: false}]], [['f']]], + ], + ); + + let changedAssets = [ + ...changeAsset(graph, 'lib.js', symbols => { + symbols.delete('f'); + symbols.set('f2', { + local: 'f2', + loc: undefined, + }); + }), + ]; + + let errors = propagateSymbols({ + options: DEFAULT_OPTIONS, + assetGraph: graph, + changedAssetsPropagation: new Set(new Map(changedAssets).keys()), + assetGroupsWithRemovedParents: new Set(), + }); + + assertPropagationErrors(graph, errors, [ + [ + 'lib.js', + [ + { + message: "lib.js does not export 'f'", + origin: '@parcel/core', + codeFrames: undefined, + }, + ], + ], + ]); + }); it('basic tree - dependency symbol change reexport', async () => { // prettier-ignore