summaryrefslogtreecommitdiff
path: root/spec/javascripts/helpers
diff options
context:
space:
mode:
authorLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-04 12:01:14 +0000
committerLuke "Jared" Bennett <lbennett@gitlab.com>2017-01-18 13:33:08 +0000
commit2d2fe2cfee2c5919c95f872fb5c875d787ef084f (patch)
tree56d7e3e8888ef0b5e6dcba344eb0bb694fe0d6b6 /spec/javascripts/helpers
parente2f0b83061df3b19b683b67d142acea65d5df0fd (diff)
downloadgitlab-ce-2d2fe2cfee2c5919c95f872fb5c875d787ef084f.tar.gz
Add first shared examples to a helper and updated teaspoon_env to allow helper specs to runallow-shared-examples-jasmine
Diffstat (limited to 'spec/javascripts/helpers')
-rw-r--r--spec/javascripts/helpers/class_spec_helper.js.es69
-rw-r--r--spec/javascripts/helpers/class_spec_helper_spec.js.es635
2 files changed, 44 insertions, 0 deletions
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();
+ });
+ });
+});