summaryrefslogtreecommitdiff
path: root/spec/frontend/lib/utils/common_utils_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/frontend/lib/utils/common_utils_spec.js')
-rw-r--r--spec/frontend/lib/utils/common_utils_spec.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/frontend/lib/utils/common_utils_spec.js b/spec/frontend/lib/utils/common_utils_spec.js
index 947c38c8ae8..08ba78cddff 100644
--- a/spec/frontend/lib/utils/common_utils_spec.js
+++ b/spec/frontend/lib/utils/common_utils_spec.js
@@ -1,4 +1,5 @@
import * as commonUtils from '~/lib/utils/common_utils';
+import setWindowLocation from 'helpers/set_window_location_helper';
describe('common_utils', () => {
describe('getPagePath', () => {
@@ -1069,4 +1070,35 @@ describe('common_utils', () => {
expect(result).toEqual([{ hello: '' }, { helloWorld: '' }]);
});
});
+
+ describe('useNewFonts', () => {
+ let beforeGon;
+ const beforeLocation = window.location.href;
+
+ beforeEach(() => {
+ window.gon = window.gon || {};
+ beforeGon = { ...window.gon };
+ });
+
+ describe.each`
+ featureFlag | queryParameter | fontEnabled
+ ${false} | ${false} | ${false}
+ ${true} | ${false} | ${true}
+ ${false} | ${true} | ${true}
+ `('new font', ({ featureFlag, queryParameter, fontEnabled }) => {
+ it(`will ${fontEnabled ? '' : 'NOT '}be applied when feature flag is ${
+ featureFlag ? '' : 'NOT '
+ }set and query parameter is ${queryParameter ? '' : 'NOT '}present`, () => {
+ const search = queryParameter ? `?new_fonts` : '';
+ setWindowLocation(search);
+ window.gon = { features: { newFonts: featureFlag } };
+ expect(commonUtils.useNewFonts()).toBe(fontEnabled);
+ });
+ });
+
+ afterEach(() => {
+ window.gon = beforeGon;
+ setWindowLocation(beforeLocation);
+ });
+ });
});