Skip to content

Commit

Permalink
Fix multiple dependencies parse
Browse files Browse the repository at this point in the history
  • Loading branch information
ogonkov committed Sep 4, 2020
1 parent f5567d0 commit a822c7d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/filter-nodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export function filterNodes(
const {[nodeName]: nextItem} = item;

if (nodeNames.includes(nodeName)) {
found.push({
found.push(...nextItem.map((item) => ({
name: nodeName,
item: nextItem
});
item: [item]
})));

continue;
}
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/another-include.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<fest:template xmlns:fest="http://fest.mail.ru" context_name="json">
Simple include 2
</fest:template>
1 change: 1 addition & 0 deletions test/fixtures/nested-dependency.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<fest:template xmlns:fest="http://fest.mail.ru" context_name="json">
<fest:include context="json.list" src="./include.xml"/>
<fest:include context="json.list" src="./another-include.xml"/>
<fest:script src="./script.js"/>
</fest:template>
5 changes: 4 additions & 1 deletion test/loader.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('dependencies parse', function() {

await result;

expect(context.addDependency).toHaveBeenCalledTimes(4);
expect(context.addDependency).toHaveBeenCalledTimes(5);
expect(context.addDependency).toHaveBeenCalledWith(
expect.stringMatching('nested-dependency.xml')
);
Expand All @@ -59,6 +59,9 @@ describe('dependencies parse', function() {
expect(context.addDependency).toHaveBeenCalledWith(
expect.stringMatching('include.xml')
);
expect(context.addDependency).toHaveBeenCalledWith(
expect.stringMatching('another-include.xml')
);
expect(context.addDependency).toHaveBeenCalledWith(
expect.stringMatching('script.js')
);
Expand Down

0 comments on commit a822c7d

Please sign in to comment.