summaryrefslogtreecommitdiff
path: root/spec/javascripts/landing_spec.js
diff options
context:
space:
mode:
Diffstat (limited to 'spec/javascripts/landing_spec.js')
-rw-r--r--spec/javascripts/landing_spec.js70
1 files changed, 38 insertions, 32 deletions
diff --git a/spec/javascripts/landing_spec.js b/spec/javascripts/landing_spec.js
index 7916073190a..2fe5a47b63e 100644
--- a/spec/javascripts/landing_spec.js
+++ b/spec/javascripts/landing_spec.js
@@ -1,9 +1,9 @@
import Landing from '~/landing';
import Cookies from 'js-cookie';
-describe('Landing', function () {
- describe('class constructor', function () {
- beforeEach(function () {
+describe('Landing', function() {
+ describe('class constructor', function() {
+ beforeEach(function() {
this.landingElement = {};
this.dismissButton = {};
this.cookieName = 'cookie_name';
@@ -11,25 +11,25 @@ describe('Landing', function () {
this.landing = new Landing(this.landingElement, this.dismissButton, this.cookieName);
});
- it('should set .landing', function () {
+ it('should set .landing', function() {
expect(this.landing.landingElement).toBe(this.landingElement);
});
- it('should set .cookieName', function () {
+ it('should set .cookieName', function() {
expect(this.landing.cookieName).toBe(this.cookieName);
});
- it('should set .dismissButton', function () {
+ it('should set .dismissButton', function() {
expect(this.landing.dismissButton).toBe(this.dismissButton);
});
- it('should set .eventWrapper', function () {
+ it('should set .eventWrapper', function() {
expect(this.landing.eventWrapper).toEqual({});
});
});
- describe('toggle', function () {
- beforeEach(function () {
+ describe('toggle', function() {
+ beforeEach(function() {
this.isDismissed = false;
this.landingElement = { classList: jasmine.createSpyObj('classList', ['toggle']) };
this.landing = {
@@ -44,20 +44,20 @@ describe('Landing', function () {
Landing.prototype.toggle.call(this.landing);
});
- it('should call .isDismissed', function () {
+ it('should call .isDismissed', function() {
expect(this.landing.isDismissed).toHaveBeenCalled();
});
- it('should call .classList.toggle', function () {
+ it('should call .classList.toggle', function() {
expect(this.landingElement.classList.toggle).toHaveBeenCalledWith('hidden', this.isDismissed);
});
- it('should call .addEvents', function () {
+ it('should call .addEvents', function() {
expect(this.landing.addEvents).toHaveBeenCalled();
});
- describe('if isDismissed is true', function () {
- beforeEach(function () {
+ describe('if isDismissed is true', function() {
+ beforeEach(function() {
this.isDismissed = true;
this.landingElement = { classList: jasmine.createSpyObj('classList', ['toggle']) };
this.landing = {
@@ -74,14 +74,14 @@ describe('Landing', function () {
Landing.prototype.toggle.call(this.landing);
});
- it('should not call .addEvents', function () {
+ it('should not call .addEvents', function() {
expect(this.landing.addEvents).not.toHaveBeenCalled();
});
});
});
- describe('addEvents', function () {
- beforeEach(function () {
+ describe('addEvents', function() {
+ beforeEach(function() {
this.dismissButton = jasmine.createSpyObj('dismissButton', ['addEventListener']);
this.eventWrapper = {};
this.landing = {
@@ -93,17 +93,20 @@ describe('Landing', function () {
Landing.prototype.addEvents.call(this.landing);
});
- it('should set .eventWrapper.dismissLanding', function () {
+ it('should set .eventWrapper.dismissLanding', function() {
expect(this.eventWrapper.dismissLanding).toEqual(jasmine.any(Function));
});
- it('should call .addEventListener', function () {
- expect(this.dismissButton.addEventListener).toHaveBeenCalledWith('click', this.eventWrapper.dismissLanding);
+ it('should call .addEventListener', function() {
+ expect(this.dismissButton.addEventListener).toHaveBeenCalledWith(
+ 'click',
+ this.eventWrapper.dismissLanding,
+ );
});
});
- describe('removeEvents', function () {
- beforeEach(function () {
+ describe('removeEvents', function() {
+ beforeEach(function() {
this.dismissButton = jasmine.createSpyObj('dismissButton', ['removeEventListener']);
this.eventWrapper = { dismissLanding: () => {} };
this.landing = {
@@ -114,13 +117,16 @@ describe('Landing', function () {
Landing.prototype.removeEvents.call(this.landing);
});
- it('should call .removeEventListener', function () {
- expect(this.dismissButton.removeEventListener).toHaveBeenCalledWith('click', this.eventWrapper.dismissLanding);
+ it('should call .removeEventListener', function() {
+ expect(this.dismissButton.removeEventListener).toHaveBeenCalledWith(
+ 'click',
+ this.eventWrapper.dismissLanding,
+ );
});
});
- describe('dismissLanding', function () {
- beforeEach(function () {
+ describe('dismissLanding', function() {
+ beforeEach(function() {
this.landingElement = { classList: jasmine.createSpyObj('classList', ['add']) };
this.cookieName = 'cookie_name';
this.landing = { landingElement: this.landingElement, cookieName: this.cookieName };
@@ -130,17 +136,17 @@ describe('Landing', function () {
Landing.prototype.dismissLanding.call(this.landing);
});
- it('should call .classList.add', function () {
+ it('should call .classList.add', function() {
expect(this.landingElement.classList.add).toHaveBeenCalledWith('hidden');
});
- it('should call Cookies.set', function () {
+ it('should call Cookies.set', function() {
expect(Cookies.set).toHaveBeenCalledWith(this.cookieName, 'true', { expires: 365 });
});
});
- describe('isDismissed', function () {
- beforeEach(function () {
+ describe('isDismissed', function() {
+ beforeEach(function() {
this.cookieName = 'cookie_name';
this.landing = { cookieName: this.cookieName };
@@ -149,11 +155,11 @@ describe('Landing', function () {
this.isDismissed = Landing.prototype.isDismissed.call(this.landing);
});
- it('should call Cookies.get', function () {
+ it('should call Cookies.get', function() {
expect(Cookies.get).toHaveBeenCalledWith(this.cookieName);
});
- it('should return a boolean', function () {
+ it('should return a boolean', function() {
expect(typeof this.isDismissed).toEqual('boolean');
});
});