-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
36 additions
and
3 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import noNgAttr from '../serializers/no-ng-attributes'; | ||
|
||
describe('no-ng-attributes snapshot serializer', () => { | ||
test('should return true when matching the condition with attributes to remove', () => { | ||
const validElement = document.createElement('DIV'); | ||
['ng-reflect', '_nghost', '_ngcontent', 'ng-version'].forEach((attrToRemove) => { | ||
validElement.setAttribute(attrToRemove, 'foo'); | ||
}); | ||
|
||
expect(noNgAttr.test(validElement)).toBe(true); | ||
|
||
validElement.remove(); | ||
}); | ||
|
||
test('should return true when matching the condition with attributes to clean', () => { | ||
const validElement = document.createElement('SECTION'); | ||
['class', 'id', 'for', 'aria-owns', 'aria-labelledby', 'aria-controls'].forEach((attrToClean) => { | ||
validElement.setAttribute(attrToClean, 'foo'); | ||
}); | ||
|
||
expect(noNgAttr.test(validElement)).toBe(true); | ||
|
||
validElement.remove(); | ||
}); | ||
|
||
test.each([undefined, null, 1, document.createElement('INPUT')])( | ||
'should return false when not matching the condition', | ||
(val) => { | ||
expect(noNgAttr.test(val)).toBe(false); | ||
}, | ||
); | ||
}); |
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