Skip to content

Commit

Permalink
reorganize and refactor behaviors and features unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
wesmangum authored and paulfalgout committed Nov 16, 2017
1 parent 2b2bee3 commit 996d3ed
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
31 changes: 16 additions & 15 deletions test/unit/config/behaviors.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import Behavior from '../../../src/behavior';
import Region from '../../../src/region';
import View from '../../../src/view';
import CollectionView from '../../../src/collection-view';
import { bindEvents } from '../../../src/backbone.marionette';

describe('Behaviors', function() {

Expand Down Expand Up @@ -233,7 +234,7 @@ describe('Behaviors', function() {
bar: Behavior.extend({initialize: barStub})
};

FooView = Marionette.View.extend({
FooView = View.extend({
behaviors: [behaviorSpies.foo]
});
});
Expand Down Expand Up @@ -263,25 +264,25 @@ describe('Behaviors', function() {
viewClickStub = this.sinon.stub();

behaviorSpies = {
foo: Marionette.Behavior.extend({
foo: Behavior.extend({
events: {
'click': fooClickStub
}
}),
bar: Marionette.Behavior.extend({
bar: Behavior.extend({
events: {
'click': barClickStub
}
}),
baz: Marionette.Behavior.extend({
baz: Behavior.extend({
events: {
'click': 'handleClick'
},
handleClick: bazClickStub
})
};

FooView = Marionette.View.extend({
FooView = View.extend({
events: {
'click': viewClickStub
},
Expand Down Expand Up @@ -337,7 +338,7 @@ describe('Behaviors', function() {
})
};

const FooView = Marionette.View.extend({
const FooView = View.extend({
triggers: {
'click': 'click:foo:view'
},
Expand Down Expand Up @@ -390,14 +391,14 @@ describe('Behaviors', function() {

beforeEach(function() {
const behaviorSpies = {
foo: Marionette.Behavior.extend({
foo: Behavior.extend({
initialize: function() {
fooBehavior = this;
}
})
};

const FooView = Marionette.View.extend({
const FooView = View.extend({
behaviors: [behaviorSpies.foo]
});

Expand Down Expand Up @@ -751,7 +752,7 @@ describe('Behaviors', function() {
handleModelFooChangeStub = this.sinon.stub();

const behaviorSpies = {
foo: Marionette.Behavior.extend({
foo: Behavior.extend({
initialize: function() {
fooBehavior = this;
},
Expand Down Expand Up @@ -826,7 +827,7 @@ describe('Behaviors', function() {
onRenderStub = this.sinon.stub();

const behaviorSpies = {
foo: Marionette.Behavior.extend({
foo: Behavior.extend({
onRender: onRenderStub
})
};
Expand All @@ -850,7 +851,7 @@ describe('Behaviors', function() {

beforeEach(function() {
const behaviorSpies = {
foo: Marionette.Behavior.extend({
foo: Behavior.extend({
onFoo: function() {
return 'behavior foo';
}
Expand Down Expand Up @@ -883,10 +884,10 @@ describe('Behaviors', function() {
listenToStub = this.sinon.stub();
changeStub = this.sinon.stub();

behavior = new Marionette.Behavior({}, {});
behavior = new Behavior({}, {});
fooModel = new Backbone.Model();

Marionette.bindEvents(behavior, fooModel, {
bindEvents(behavior, fooModel, {
'change': changeStub
});

Expand Down Expand Up @@ -938,7 +939,7 @@ describe('Behaviors', function() {
barCollectionSyncStub = this.sinon.stub();
bazClickStub = this.sinon.stub();

const BarBehavior = Marionette.Behavior.extend({
const BarBehavior = Behavior.extend({
initialize: function() {
initializeStub();
barBehavior = this;
Expand All @@ -959,7 +960,7 @@ describe('Behaviors', function() {
});

const behaviorSpies = {
foo: Marionette.Behavior.extend({
foo: Behavior.extend({
initialize: function() {
fooBehavior = this;
},
Expand Down
12 changes: 7 additions & 5 deletions test/unit/config/features.spec.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { setEnabled, isEnabled } from '../../../src/config/features';

describe('features', function() {
it('enabled when its present and true', function() {
Marionette.setEnabled('foo', true);
expect(Marionette.isEnabled('foo')).to.be.true;
setEnabled('foo', true);
expect(isEnabled('foo')).to.be.true;
});

it('disabled when its present and false', function() {
Marionette.setEnabled('foo', false);
expect(Marionette.isEnabled('foo')).to.be.false;
setEnabled('foo', false);
expect(isEnabled('foo')).to.be.false;
});

it('disabled when not present', function() {
expect(Marionette.isEnabled('foo')).to.be.false;
expect(isEnabled('foo')).to.be.false;
});
});

0 comments on commit 996d3ed

Please sign in to comment.