Skip to content

Commit c2a13f1

Browse files
pablosicherteric-adstage
authored andcommitted
Mock out "measureWidth" method
To guarantee same text width measuring in all test environments
1 parent e43c097 commit c2a13f1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

test/Truncate.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,12 @@ describe('<Truncate />', () => {
127127
'getBoundingClientRect', () => ({ width })
128128
);
129129

130+
sinon.stub(Truncate.prototype,
131+
'measureWidth', text => {
132+
return measureWidth(text);
133+
}
134+
);
135+
130136
// Approximate .offsetWidth
131137
sinon.stub(Truncate.prototype,
132138
'ellipsisWidth', node => {
@@ -138,6 +144,7 @@ describe('<Truncate />', () => {
138144
after(() => {
139145
global.window.HTMLDivElement.prototype.getBoundingClientRect.restore();
140146

147+
Truncate.prototype.measureWidth.restore();
141148
Truncate.prototype.ellipsisWidth.restore();
142149
});
143150

0 commit comments

Comments
 (0)