ng-stubs
Version:
[](https://travis-ci.org/planser/ng-stubs)
50 lines (49 loc) • 1.98 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.StubbedComponent = void 0;
var StubbedComponent = /** @class */ (function () {
function StubbedComponent(instances, type, controlValueAccessors) {
this.instances = instances;
this.type = type;
this.controlValueAccessors = controlValueAccessors;
}
Object.defineProperty(StubbedComponent.prototype, "instance", {
get: function () {
if (this.instances.length == 0)
throw new Error("No instance created yet.");
if (this.instances.length > 1)
throw new Error("Multiple instances available. Use the indices property instead.");
return this.instances[0];
},
enumerable: false,
configurable: true
});
Object.defineProperty(StubbedComponent.prototype, "mostRecent", {
get: function () {
if (this.instances.length == 0)
throw new Error("No instance created yet.");
return this.instances[this.instances.length - 1];
},
enumerable: false,
configurable: true
});
StubbedComponent.prototype.controlValueAccessorFor = function (component) {
return this.controlValueAccessors.get(component);
};
Object.defineProperty(StubbedComponent.prototype, "controlValueAccessor", {
get: function () {
return this.controlValueAccessors.get(this.instance);
},
enumerable: false,
configurable: true
});
StubbedComponent.prototype.query = function (predicate, context) {
var result = context.query(predicate);
return result ? result.componentInstance : null;
};
StubbedComponent.prototype.queryAll = function (predicate, context) {
return context.queryAll(predicate).map(function (e) { return e.componentInstance; });
};
return StubbedComponent;
}());
exports.StubbedComponent = StubbedComponent;
;