summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <ClemMakesApps@gmail.com>2016-12-14 14:37:17 -0600
committerClement Ho <ClemMakesApps@gmail.com>2017-01-09 16:01:27 -0600
commit4577f1f1749976412ce03941ef712e763c9d618a (patch)
treedc575ddc69f57f4e622271569273cda78a026692
parent3cb156dd45e7a83d83c59094894e015386d4caea (diff)
downloadgitlab-ce-4577f1f1749976412ce03941ef712e763c9d618a.tar.gz
Add text utility spec
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js.es61
-rw-r--r--spec/javascripts/lib/utils/text_utility_spec.js.es625
2 files changed, 25 insertions, 1 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js.es6 b/spec/javascripts/lib/utils/common_utils_spec.js.es6
index 4ba83d235c4..031f9ca03c9 100644
--- a/spec/javascripts/lib/utils/common_utils_spec.js.es6
+++ b/spec/javascripts/lib/utils/common_utils_spec.js.es6
@@ -52,6 +52,5 @@
expect(value).toBe(null);
});
});
-
});
})();
diff --git a/spec/javascripts/lib/utils/text_utility_spec.js.es6 b/spec/javascripts/lib/utils/text_utility_spec.js.es6
new file mode 100644
index 00000000000..e97356b65d5
--- /dev/null
+++ b/spec/javascripts/lib/utils/text_utility_spec.js.es6
@@ -0,0 +1,25 @@
+//= require lib/utils/text_utility
+
+(() => {
+ describe('text_utility', () => {
+ describe('gl.text.getTextWidth', () => {
+ it('returns zero width when no text is passed', () => {
+ expect(gl.text.getTextWidth('')).toBe(0);
+ });
+
+ it('returns zero width when no text is passed and font is passed', () => {
+ expect(gl.text.getTextWidth('', '100px sans-serif')).toBe(0);
+ });
+
+ it('returns width when text is passed', () => {
+ expect(gl.text.getTextWidth('foo') > 0).toBe(true);
+ });
+
+ it('returns bigger width when font is larger', () => {
+ const largeFont = gl.text.getTextWidth('foo', '100px sans-serif');
+ const regular = gl.text.getTextWidth('foo', '10px sans-serif');
+ expect(largeFont > regular).toBe(true);
+ });
+ });
+ });
+})();