本文整理匯總了TypeScript中should類的典型用法代碼示例。如果您正苦於以下問題:TypeScript should類的具體用法?TypeScript should怎麽用?TypeScript should使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了should類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should set correct API path based on passed configuration (version="asp")', function() {
const api = new NodeApi({url: 'http://localhost', version: 'asp'})
should(api._httpOptions.path).equal('/attask/api-asp')
})
示例2: before
before(() => {
addressSpace = maintest.addressSpace;
should(addressSpace).be.instanceof(AddressSpace);
});
示例3: assertBlock
.catch(err => assertBlock(done, () => {
should(err).deepEqual({
"": ["> 50", "> 100"]
})
}));
示例4: assertBlock
.then(v => assertBlock(done, () => {
should(v).be.null();
}))
示例5: it
it("should be possible to choose which optional item to instantiate in sub objects", () => {
const namespace = addressSpace.getOwnNamespace();
function constructObjectType() {
const mySubObjectType1 = namespace.addObjectType({
browseName: "MySubObjectType1"
}) as MySubObjectType1;
const prop1 = namespace.addVariable({
browseName: "Property1",
dataType: "Double",
modellingRule: "Mandatory",
propertyOf: mySubObjectType1,
});
mySubObjectType1.property1.browseName.toString().should.eql("1:Property1");
const prop2 = namespace.addVariable({
browseName: "Property2",
dataType: "Double",
modellingRule: "Optional",
propertyOf: mySubObjectType1,
});
const prop3 = namespace.addVariable({
browseName: "Property3",
dataType: "Double",
modellingRule: "Optional",
propertyOf: mySubObjectType1,
});
const myObjectType2 = namespace.addObjectType({
browseName: "MyObjectType1"
}) as MyObjectType1;
const subObj = mySubObjectType1.instantiate({
browseName: "SubObj",
componentOf: myObjectType2,
modellingRule: "Optional",
optionals: ["Property2", "Property3"]
}) as MySubObject1;
myObjectType2.getComponentByName("SubObj")!.browseName.toString().should.eql("1:SubObj");
myObjectType2.subObj.getPropertyByName("Property1")!.browseName.toString().should.eql("1:Property1");
myObjectType2.subObj.getPropertyByName("Property2")!.browseName.toString().should.eql("1:Property2");
myObjectType2.subObj.getPropertyByName("Property3")!.browseName.toString().should.eql("1:Property3");
}
constructObjectType();
const myObjectType1 = addressSpace.findObjectType("1:MyObjectType1")!;
// -----------------------------------------------
const obj1 = myObjectType1.instantiate({
browseName: "Obj1",
organizedBy: addressSpace.rootFolder.objects,
}) as MyObject1;
should(obj1.getComponentByName("SubObj")).eql(null);
// -----------------------------------------------
const obj2 = myObjectType1.instantiate({
browseName: "Obj2",
optionals: ["SubObj"],
organizedBy: addressSpace.rootFolder.objects,
}) as MyObject1;
should.exist(obj2.getComponentByName("SubObj"));
obj2.getComponentByName("SubObj")!.browseName.toString().should.eql("1:SubObj");
should.exist(obj2.subObj.getPropertyByName("Property1"));
should.not.exist(obj2.subObj.getPropertyByName("Property2"));
should.not.exist(obj2.subObj.getPropertyByName("Property3"));
// -----------------------------------------------
const obj3 = myObjectType1.instantiate({
browseName: "Obj3",
optionals: [
"SubObj.Property2",
"SubObj.Property3"
],
organizedBy: addressSpace.rootFolder.objects,
}) as MyObject1;
obj3.getComponentByName("SubObj")!.browseName.toString().should.eql("1:SubObj");
should.exist(obj3.subObj.getPropertyByName("Property1"));
should.exist(obj3.subObj.getPropertyByName("Property2"));
should.exist(obj3.subObj.getPropertyByName("Property3"));
// -----------------------------------------------
const obj4 = myObjectType1.instantiate({
browseName: "Obj4",
optionals: [
"SubObj.Property3"
],
organizedBy: addressSpace.rootFolder.objects,
}) as MyObject1;
obj4.getComponentByName("SubObj")!.browseName.toString().should.eql("1:SubObj");
//.........這裏部分代碼省略.........
示例6: it
it('should return null when a zero-length array is given', () => {
should(mergeIntervals([])).be.null();
});
示例7: before
before(() => {
addressSpace = maintest.addressSpace;
namespace = addressSpace.getOwnNamespace();
should(addressSpace).be.instanceof(AddressSpace);
});
示例8: should
}).on('end', () => {
should(data.toString()).be.eql('<h1>hello lleohao</h1>')
done();
server.close();
})
示例9: it
it('return string template', () => {
const template = '<h1>hello world</h1>';
should(render(template)).be.eql(template);
})