-
-
Notifications
You must be signed in to change notification settings - Fork 293
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
1 parent
b4cd427
commit fa6c8e2
Showing
6 changed files
with
96 additions
and
35 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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,44 @@ | ||
import chai from 'chai'; | ||
import {renderToString} from 'react-dom/server'; | ||
|
||
import {highlightNodeMatchingSearchTerm} from '../../app/renderer/src/components/Inspector/Source.jsx'; | ||
|
||
const should = chai.should(); | ||
|
||
describe('components/Inspector/Source.jsx', function () { | ||
describe('#highlightNodeMatchingSearchTerm', function () { | ||
it('should return the node text when search value is empty', function () { | ||
const nodeText = highlightNodeMatchingSearchTerm('android.widget.FrameLayout', ''); | ||
nodeText.should.equal('android.widget.FrameLayout'); | ||
}); | ||
|
||
it('should return the node text when search value is undefined', function () { | ||
const nodeText = highlightNodeMatchingSearchTerm('android.widget.FrameLayout'); | ||
nodeText.should.equal('android.widget.FrameLayout'); | ||
}); | ||
|
||
it('should return the node text when the value is undefined', function () { | ||
const nodeText = highlightNodeMatchingSearchTerm(undefined, 'widget'); | ||
should.equal(nodeText, undefined); | ||
}); | ||
|
||
it('should return the node text when the value is empty', function () { | ||
const nodeText = highlightNodeMatchingSearchTerm('', 'widget'); | ||
nodeText.should.equal(''); | ||
}); | ||
|
||
it('should return the node text when search value is not matched', function () { | ||
const nodeText = highlightNodeMatchingSearchTerm('android.widget.FrameLayout', 'login'); | ||
nodeText.should.equal('android.widget.FrameLayout'); | ||
}); | ||
|
||
it('should higlight the node text if a part of text matches the search value lowercase', function () { | ||
const nodeText = highlightNodeMatchingSearchTerm('android.Widget.FrameLayout', 'widget'); | ||
renderToString(nodeText) | ||
.toString() | ||
.should.equal( | ||
'android.<span class="search-word-highlighted" data-match="widget">Widget</span>.FrameLayout', | ||
); | ||
}); | ||
}); | ||
}); |