-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
196 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
es5/spec/component/component.properties.then.multi.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
"use strict"; | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
var _component = require("../../lib/component/component.js"); | ||
|
||
var _component2 = _interopRequireDefault(_component); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
|
||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
|
||
describe(".properties.then(thenFunction)", function () { | ||
var numbers = void 0, | ||
actualContext = void 0, | ||
results = void 0, | ||
returnValue = void 0; | ||
|
||
var Numbers = function (_Component) { | ||
_inherits(Numbers, _Component); | ||
|
||
function Numbers() { | ||
_classCallCheck(this, Numbers); | ||
|
||
return _possibleConstructorReturn(this, Object.getPrototypeOf(Numbers).apply(this, arguments)); | ||
} | ||
|
||
_createClass(Numbers, [{ | ||
key: "initialize", | ||
value: function initialize() { | ||
returnValue = this.properties("values").multi.aggregate.flat.then(function (value) { | ||
actualContext = this; | ||
results.push(value); | ||
}); | ||
} | ||
}]); | ||
|
||
return Numbers; | ||
}(_component2.default); | ||
|
||
beforeEach(function () { | ||
actualContext = null; | ||
results = []; | ||
numbers = new Numbers(); | ||
}); | ||
|
||
it("should return this when setting to enable chaining", function () { | ||
var propertyCollection = numbers.propertyCollections()[0]; | ||
returnValue.should.eql(propertyCollection); | ||
}); | ||
|
||
it("should call .then each time the property has a value set", function () { | ||
numbers.values("1").values("2").values("3"); | ||
results.should.eql(["1", "2", "3"]); | ||
}); | ||
|
||
it("should be called with the correct context", function () { | ||
numbers.values("1"); | ||
actualContext.should.eql(numbers); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
es6/spec/component/component.properties.then.multi.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import Component from "../../lib/component/component.js"; | ||
|
||
describe(".properties.then(thenFunction)", () => { | ||
let numbers, | ||
actualContext, | ||
results, | ||
returnValue; | ||
|
||
class Numbers extends Component { | ||
initialize() { | ||
returnValue = this.properties("values") | ||
.multi.aggregate.flat | ||
.then(function (value) { | ||
actualContext = this; | ||
results.push(value); | ||
}); | ||
} | ||
} | ||
|
||
beforeEach(() => { | ||
actualContext = null; | ||
results = []; | ||
numbers = new Numbers(); | ||
}); | ||
|
||
it("should return this when setting to enable chaining", () => { | ||
const propertyCollection = numbers.propertyCollections()[0]; | ||
returnValue.should.eql(propertyCollection); | ||
}); | ||
|
||
it("should call .then each time the property has a value set", () => { | ||
numbers | ||
.values("1") | ||
.values("2") | ||
.values("3"); | ||
results.should.eql([ "1", "2", "3" ]); | ||
}); | ||
|
||
it("should be called with the correct context", () => { | ||
numbers.values("1"); | ||
actualContext.should.eql(numbers); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,42 @@ | ||
import Component from "../../lib/component/component.js"; | ||
|
||
class Numbers extends Component { | ||
initialize() { | ||
this.results = []; | ||
this.returnValue = this.properties("values") | ||
.aggregate | ||
.then(value => { | ||
this.results.push(value); | ||
}); | ||
} | ||
} | ||
|
||
describe(".properties.then(thenFunction)", () => { | ||
let numbers; | ||
let numbers, | ||
actualContext, | ||
results, | ||
returnValue; | ||
|
||
class Numbers extends Component { | ||
initialize() { | ||
returnValue = this.properties("value") | ||
.then(function (value) { | ||
actualContext = this; | ||
results.push(value); | ||
}); | ||
} | ||
} | ||
|
||
beforeEach(() => { | ||
actualContext = null; | ||
results = []; | ||
numbers = new Numbers(); | ||
}); | ||
|
||
it("should return this when setting to enable chaining", () => { | ||
const propertyCollection = numbers.propertyCollections()[0]; | ||
numbers.returnValue.should.eql(propertyCollection); | ||
returnValue.should.eql(propertyCollection); | ||
}); | ||
|
||
it("should call .then each time the property has a value set", () => { | ||
numbers | ||
.values("1") | ||
.values("2") | ||
.values("3"); | ||
numbers.results.should.eql([ "1", "2", "3" ]); | ||
.value("1") | ||
.value("2") | ||
.value("3"); | ||
results.should.eql([ "1", "2", "3" ]); | ||
}); | ||
|
||
it("should be called with the correct context", () => { | ||
numbers.value("1"); | ||
actualContext.should.eql(numbers); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters