-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ngMocks.findInstance): finds pipes in attributes #2314
- Loading branch information
Showing
11 changed files
with
252 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
libs/ng-mocks/src/lib/mock-helper/crawl/nested-check-parent.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { MockedDebugNode } from '../../mock-render/types'; | ||
|
||
import elDefCompare from './el-def-compare'; | ||
import elDefGetNode from './el-def-get-node'; | ||
import elDefGetParent from './el-def-get-parent'; | ||
|
||
const detectParent = (node: MockedDebugNode, parent: MockedDebugNode | undefined): MockedDebugNode | undefined => { | ||
if (parent) { | ||
return parent; | ||
} | ||
|
||
const expected = elDefGetParent(node); | ||
const currentParent = node.parent ? elDefGetNode(node.parent) : undefined; | ||
if (node.parent && elDefCompare(expected, currentParent)) { | ||
return node.parent; | ||
} | ||
for (const childNode of node.parent?.childNodes || []) { | ||
const childElDef = elDefGetNode(childNode); | ||
if (elDefCompare(expected, childElDef)) { | ||
return childNode; | ||
} | ||
} | ||
|
||
return undefined; | ||
}; | ||
|
||
export default ((): typeof detectParent => detectParent)(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.