Skip to content
This repository has been archived by the owner on Oct 29, 2019. It is now read-only.

Commit

Permalink
[TASK] Port all test specifications to the new test stack #28
Browse files Browse the repository at this point in the history
  • Loading branch information
Inkdpixels committed Aug 2, 2015
1 parent a5087b1 commit 4112a15
Show file tree
Hide file tree
Showing 38 changed files with 601 additions and 518 deletions.
27 changes: 14 additions & 13 deletions Dist/Component.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,33 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
minor: 0,
patch: 6
};
var global;

if (typeof window !== "undefined") {
global = window;
} else if (typeof global !== "undefined") {
global = global;
var world;

if(typeof global !== "undefined") {
world = global;
} else if (typeof window !== "undefined") {
world = window;
} else if (typeof world !== "undefined") {
world = world;
} else if (typeof self !== "undefined") {
global = self;
world = self;
} else {
global = this;
world = this;
}

if (typeof exports === "object" && typeof module !== "undefined") {
module.exports = factory(global, version);
module.exports = factory(world, version);
} else if (typeof define === "function" && define.amd) {
define([], function () {
return factory(global, version);
return factory(world, version);
});
} else {
global.reductComponent = factory(global, version);
world.reductComponent = factory(world, version);
}
})(function factory(global, version) {
var _this = this,
_arguments = arguments;

var doc = global.document;
var isScriptExecutedByNode = process && process.title && process.title.indexOf('node') > -1;
var messages = {
noElement: 'No element was specified while creating a instance of a Class. Creating a detached DOM Element instead.',
Expand Down Expand Up @@ -379,7 +380,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons
this.props = {};
this.states = {};
this.observers = {};
this.el = element || doc.createElement('div');
this.el = element || global.document.createElement('div');

_validateAndSetProps(this, opts.propTypes);
_setInitialStates(this);
Expand Down
2 changes: 1 addition & 1 deletion Dist/Component.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions Src/Component.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
function factory (global, version) {
const doc = global.document;
const isScriptExecutedByNode = process && process.title && process.title.indexOf('node') > -1;
var messages = {
noElement: 'No element was specified while creating a instance of a Class. Creating a detached DOM Element instead.',
Expand Down Expand Up @@ -331,7 +330,7 @@ function factory (global, version) {
this.props = {};
this.states = {};
this.observers = {};
this.el = element || doc.createElement('div');
this.el = element || global.document.createElement('div');

_validateAndSetProps(this, opts.propTypes);
_setInitialStates(this);
Expand Down
9 changes: 0 additions & 9 deletions Tests/API/Element.js

This file was deleted.

16 changes: 16 additions & 0 deletions Tests/API/Element.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var chai = require('@reduct/build-tools').chai;
var DOM = require('./../Helpers/DOM');
var DefaultComponent = require('./../ExampleComponents/Dist/Default.js');
var expect = chai.expect;

describe('@reduct/component: Element API', function () {
beforeEach(function before (done) {
return DOM.create(DOM.defaultMock, done);
});

it('should return a DOM element even if none was passed directly to the Constructor.', function () {
var componentInstance = new DefaultComponent();

expect(componentInstance.getElement()).to.not.be.undefined;
});
});
31 changes: 0 additions & 31 deletions Tests/API/Events.js

This file was deleted.

40 changes: 40 additions & 0 deletions Tests/API/Events.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
var chai = require('@reduct/build-tools').chai;
var spies = require('chai-spies');
var DOM = require('./../Helpers/DOM');
var DefaultComponent = require('./../ExampleComponents/Dist/Default.js');
var expect = chai.expect;

chai.use(spies);

describe('@reduct/component: Events API', function () {
var instance;
var eventCallback;

beforeEach(function before (done) {
instance = new DefaultComponent();
eventCallback = chai.spy(function (arg) { });

return DOM.create(DOM.defaultMock, done);
});

it('should listen to the trigger event and execute the callback with the provided argument.', function () {

instance.on('myEvent', eventCallback);
instance.trigger('myEvent', 1);

expect(eventCallback).to.have.been.called.with(1);
});

it('should remove the given function from the event queue.', function () {
instance.on('myEvent', eventCallback);
instance.off('myEvent', eventCallback);
instance.trigger('myEvent', 1);

expect(eventCallback).to.not.have.been.called.with(1);
});

afterEach(function () {
instance = null;
eventCallback = null;
});
});
16 changes: 0 additions & 16 deletions Tests/API/Extend.js

This file was deleted.

71 changes: 0 additions & 71 deletions Tests/API/Prop.js

This file was deleted.

Loading

0 comments on commit 4112a15

Please sign in to comment.