本文整理汇总了TypeScript中@tjoskar/assert.is函数的典型用法代码示例。如果您正苦于以下问题:TypeScript is函数的具体用法?TypeScript is怎么用?TypeScript is使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('Should set default image for img and all picture source elements', () => {
// Arrange
const imagePath1 = 'https://some-path/image1.jpg';
const imagePath2 = 'https://some-path/image2.jpg';
const imagePath3 = 'https://some-path/image3.jpg';
const picture = document.createElement('picture');
const source1 = document.createElement('source');
const source2 = document.createElement('source');
const img = document.createElement('img');
source1.setAttribute('defaultImage', imagePath2);
source2.setAttribute('defaultImage', imagePath3);
picture.appendChild(source1);
picture.appendChild(source2);
picture.appendChild(img);
const attribute = {
element: img,
defaultImagePath: imagePath1,
useSrcset: false
};
// Act
sharedPreset.setup(attribute as any);
// Assert
is(img.src, imagePath1);
is(source1.srcset, imagePath2);
is(source2.srcset, imagePath3);
});
示例2: getScrollListener
const subscriber = getScrollListener(element).subscribe(d => {
events.push(d);
if (events.length === 2) {
is(events[0], '');
is(events[1], 'oskar');
subscriber.unsubscribe();
done();
}
});
示例3: it
it("Should return an empty Rect if two Rect's don't intersect", () => {
// Arrange
const rectA = new Rect(0, 0, 20, 20);
const rectB = new Rect(30, 30, 50, 50);
// Act
const result = rectA.getIntersectionWith(rectB);
// Assert
is(result.top, 0);
is(result.right, 0);
is(result.bottom, 0);
is(result.left, 0);
});
示例4: it
it('Should call removeEventListener on unsubscribe', () => {
// Arrange
let argumants = {
eventName: '',
handler: null,
options: null
};
const element = {
addEventListener(eventName, handler, options) {
argumants = { eventName, handler, options };
},
removeEventListener: spy((eventName, handler, options) => {
is(argumants.eventName, eventName);
is(argumants.options.passive, options.passive);
is(argumants.options.capture, options.capture);
is(argumants.handler, handler);
})
};
// Act
const subscription = getScrollListener(element).subscribe();
subscription.unsubscribe();
// Assert
is(
element.removeEventListener.callCount,
1,
'Should call removeEventListener one time'
);
});
示例5: it
it("Should not be visible when image's rect is empty and has an offset", () => {
const attribute = {
event: undefined,
element: generateElement(0, 0, 0, 0),
offset: 100
};
const result = isVisible(attribute, getWindow);
is(result, false);
});