summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorKushal Pandya <kushalspandya@gmail.com>2019-01-15 06:04:37 +0000
committerKushal Pandya <kushalspandya@gmail.com>2019-01-15 06:04:37 +0000
commit2abbfda301cdb6f1360800b5db203b10debeaffa (patch)
treef0a3ef998f7f1126c478344e9bf2cf67db20d75c /spec
parent0e510780a15955b06445fb4c440230151da9ae93 (diff)
parent159c18221d6759737e689156d473c7e4957e6fd3 (diff)
downloadgitlab-ce-2abbfda301cdb6f1360800b5db203b10debeaffa.tar.gz
Merge branch 'winh-idempotent-parseboolean' into 'master'
Make parseBoolean idempotent See merge request gitlab-org/gitlab-ce!24365
Diffstat (limited to 'spec')
-rw-r--r--spec/javascripts/lib/utils/common_utils_spec.js19
1 files changed, 15 insertions, 4 deletions
diff --git a/spec/javascripts/lib/utils/common_utils_spec.js b/spec/javascripts/lib/utils/common_utils_spec.js
index f320f232687..0dc7e93539a 100644
--- a/spec/javascripts/lib/utils/common_utils_spec.js
+++ b/spec/javascripts/lib/utils/common_utils_spec.js
@@ -347,20 +347,31 @@ describe('common_utils', () => {
});
describe('parseBoolean', () => {
+ const { parseBoolean } = commonUtils;
+
it('returns true for "true"', () => {
- expect(commonUtils.parseBoolean('true')).toEqual(true);
+ expect(parseBoolean('true')).toEqual(true);
});
it('returns false for "false"', () => {
- expect(commonUtils.parseBoolean('false')).toEqual(false);
+ expect(parseBoolean('false')).toEqual(false);
});
it('returns false for "something"', () => {
- expect(commonUtils.parseBoolean('something')).toEqual(false);
+ expect(parseBoolean('something')).toEqual(false);
});
it('returns false for null', () => {
- expect(commonUtils.parseBoolean(null)).toEqual(false);
+ expect(parseBoolean(null)).toEqual(false);
+ });
+
+ it('is idempotent', () => {
+ const input = ['true', 'false', 'something', null];
+ input.forEach(value => {
+ const result = parseBoolean(value);
+
+ expect(parseBoolean(result)).toBe(result);
+ });
});
});