app-decorators
Version:
Collection of useful ES7 Decorators, writtin in ES6, that can be used for building webapps
189 lines (158 loc) • 5.67 kB
JavaScript
System.register(['app-decorators/src/libs/random-storage', 'app-decorators/src/libs/customelement', 'app-decorators/src/libs/element-to-function', 'jquery', '../../src/bootstrap', '../../src/helpers/delay'], function (_export, _context) {
"use strict";
var _storage, _Register, _elementToFunc, $, bootstrapPolyfills, delay, _this2, _createClass;
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;
}
function _asyncToGenerator(fn) {
return function () {
var gen = fn.apply(this, arguments);
return new Promise(function (resolve, reject) {
function step(key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
return Promise.resolve(value).then(function (value) {
step("next", value);
}, function (err) {
step("throw", err);
});
}
}
return step("next");
});
};
}
return {
setters: [function (_appDecoratorsSrcLibsRandomStorage) {
_storage = _appDecoratorsSrcLibsRandomStorage;
}, function (_appDecoratorsSrcLibsCustomelement) {
_Register = _appDecoratorsSrcLibsCustomelement;
}, function (_appDecoratorsSrcLibsElementToFunction) {
_elementToFunc = _appDecoratorsSrcLibsElementToFunction.default;
}, function (_jquery) {
$ = _jquery.default;
}, function (_srcBootstrap) {
bootstrapPolyfills = _srcBootstrap.bootstrapPolyfills;
}, function (_srcHelpersDelay) {
delay = _srcHelpersDelay.delay;
}],
execute: function () {
_this2 = this;
_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;
};
}();
describe('imported component', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var _dec, _class, _class2, _temp;
var _ref2, component, _ref3, Test, Col;
return regeneratorRuntime.wrap(function _callee2$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return bootstrapPolyfills;
case 2:
_context3.next = 4;
return System.import('app-decorators');
case 4:
_ref2 = _context3.sent;
component = _ref2.component;
_context3.next = 8;
return System.import('test/imports/testcomponent');
case 8:
_ref3 = _context3.sent;
Test = _ref3.Test;
Col = (_dec = component(), _dec(_class = (_temp = _class2 = function (_elementToFunc2) {
_inherits(Col, _elementToFunc2);
function Col() {
_classCallCheck(this, Col);
return _possibleConstructorReturn(this, (Col.__proto__ || Object.getPrototypeOf(Col)).apply(this, arguments));
}
_createClass(Col, [{
key: 'created',
value: function created(_ref4) {
var testEl = _ref4.testEl;
this.item = {
name: 'A',
content: 1
};
testEl.render(this.item);
$(this).append(testEl);
}
}]);
return Col;
}(_elementToFunc(HTMLDivElement)), _class2.$$componentName = 'Col', _temp)) || _class);
_Register.Register.customElement(Col, _storage.storage.get(Col).get('@component'));
it('should create an domnode', _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var col;
return regeneratorRuntime.wrap(function _callee$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
col = Col.create({
testEl: Test.create()
});
_context2.next = 3;
return delay(5);
case 3:
col.outerHTML.should.equal('<com-col><com-test rendered="true"><div class="A">1</div> </com-test></com-col>');
case 4:
case 'end':
return _context2.stop();
}
}
}, _callee, _this2);
})));
case 13:
case 'end':
return _context3.stop();
}
}
}, _callee2, _this2);
})));
}
};
});
//# sourceMappingURL=app.spec.js.map