diff options
author | Fatih Acet <acetfatih@gmail.com> | 2017-01-19 17:16:03 +0000 |
---|---|---|
committer | Fatih Acet <acetfatih@gmail.com> | 2017-01-19 17:16:03 +0000 |
commit | aab60054e879c4c8c14f0e0d1d0059da92b5e345 (patch) | |
tree | 561228add84b02f116e9636c54658442d2fc0666 /spec/javascripts | |
parent | 52762df285751dec4e54c4c55be5bbecb3bd4fc9 (diff) | |
parent | 2d2fe2cfee2c5919c95f872fb5c875d787ef084f (diff) | |
download | gitlab-ce-aab60054e879c4c8c14f0e0d1d0059da92b5e345.tar.gz |
Merge branch 'allow-shared-examples-jasmine' into 'master'
Add jasmine helpers and run their specs
Closes #26305
See merge request !8437
Diffstat (limited to 'spec/javascripts')
-rw-r--r-- | spec/javascripts/.eslintrc | 4 | ||||
-rw-r--r-- | spec/javascripts/helpers/class_spec_helper.js.es6 | 9 | ||||
-rw-r--r-- | spec/javascripts/helpers/class_spec_helper_spec.js.es6 | 35 |
3 files changed, 47 insertions, 1 deletions
diff --git a/spec/javascripts/.eslintrc b/spec/javascripts/.eslintrc index dcbcd014dc3..3cd419b37c9 100644 --- a/spec/javascripts/.eslintrc +++ b/spec/javascripts/.eslintrc @@ -23,6 +23,8 @@ "plugins": ["jasmine"], "rules": { "prefer-arrow-callback": 0, - "func-names": 0 + "func-names": 0, + "jasmine/no-suite-dupes": [1, "branch"], + "jasmine/no-spec-dupes": [1, "branch"] } } diff --git a/spec/javascripts/helpers/class_spec_helper.js.es6 b/spec/javascripts/helpers/class_spec_helper.js.es6 new file mode 100644 index 00000000000..92a20687ec5 --- /dev/null +++ b/spec/javascripts/helpers/class_spec_helper.js.es6 @@ -0,0 +1,9 @@ +/* eslint-disable no-unused-vars */ + +class ClassSpecHelper { + static itShouldBeAStaticMethod(base, method) { + return it('should be a static method', () => { + expect(Object.prototype.hasOwnProperty.call(base, method)).toBeTruthy(); + }); + } +} diff --git a/spec/javascripts/helpers/class_spec_helper_spec.js.es6 b/spec/javascripts/helpers/class_spec_helper_spec.js.es6 new file mode 100644 index 00000000000..d1155f1bd1e --- /dev/null +++ b/spec/javascripts/helpers/class_spec_helper_spec.js.es6 @@ -0,0 +1,35 @@ +/* global ClassSpecHelper */ +//= require ./class_spec_helper + +describe('ClassSpecHelper', () => { + describe('.itShouldBeAStaticMethod', function () { + beforeEach(() => { + class TestClass { + instanceMethod() { this.prop = 'val'; } + static staticMethod() {} + } + + this.TestClass = TestClass; + }); + + ClassSpecHelper.itShouldBeAStaticMethod(ClassSpecHelper, 'itShouldBeAStaticMethod'); + + it('should have a defined spec', () => { + expect(ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'staticMethod').description).toBe('should be a static method'); + }); + + it('should pass for a static method', () => { + const spec = ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'staticMethod'); + expect(spec.status()).toBe('passed'); + }); + + it('should fail for an instance method', (done) => { + const spec = ClassSpecHelper.itShouldBeAStaticMethod(this.TestClass, 'instanceMethod'); + spec.resultCallback = (result) => { + expect(result.status).toBe('failed'); + done(); + }; + spec.execute(); + }); + }); +}); |