本文整理汇总了TypeScript中chai.assert.closeTo方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.closeTo方法的具体用法?TypeScript assert.closeTo怎么用?TypeScript assert.closeTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chai.assert
的用法示例。
在下文中一共展示了assert.closeTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: assertBBoxInclusion
const checkWriting = (text: string, width: number, height: number, shouldHaveTitle = false) => {
svg.attr("width", width);
svg.attr("height", height);
writer.write(text, width, height, writeOptions);
const bbox = SvgUtils.getDimensions(svg.select(".text-area").node() as SVGGraphicsElement);
const dimensions = measurer.measure(
wrapper.wrap(
text,
measurer,
isHorizontal ? width : height,
isHorizontal ? height : width,
).wrappedText);
assert.closeTo(bbox.width, dimensions.width, 1,
"width of the text should be almost the same as measurer width");
assert.closeTo(bbox.height, dimensions.height, 1,
"height of the text should be almost the same as measurer height");
assertBBoxInclusion(svg, svg.select(".text-area"));
assert.equal(svg.select(".text-container").select("title").empty(),
!shouldHaveTitle,
"title element was created according to writer options");
svg.remove();
};
示例2: it
it(`should map to ${testCase.expected}`, () => {
assert.closeTo(
NumberUtil.map(...testCase.args),
testCase.expected,
DELTA,
);
});
示例3: it
it('adds geocoding columns to CSV', async () => {
const bin = path.join(__dirname, '..', 'lib', 'program.js')
const fixture = path.join(__dirname, 'fixtures', 'landmarks.csv')
let out = await execP(`${bin} --input ${fixture} --output -`)
const geocoded: { [key: string]: string }[] = []
await new Promise<void>((resolve, reject) => {
csv.fromString(out.stdout, { headers: true })
.on('data', (data) => { geocoded.push(data) })
.on('end', () => { resolve() })
.on('error', () => { reject() })
})
assert.strictEqual(geocoded[0].landmark, "White House")
assert.strictEqual(geocoded[0].ss_zipcode, "20500")
assert.closeTo(Number(geocoded[0].ss_latitude), 38.8987, 0.1)
assert.closeTo(Number(geocoded[0].ss_longitude), -77.0352, 0.1)
})
示例4: it
it('should equal the correct values that were written above', () => {
assert.strictEqual(reader.readUInt8(), 0xc8);
assert.strictEqual(reader.readUInt8(), 0xff);
assert.strictEqual(reader.readInt16BE(), 0x6699);
assert.strictEqual(reader.readInt16LE(), 0xc8);
assert.strictEqual(reader.readInt16LE(), 0x6699);
assert.strictEqual(reader.readUInt16BE(), 0xffdd);
assert.strictEqual(reader.readUInt16LE(), 0xffdd);
assert.strictEqual(reader.readInt32BE(), 0x77889900);
assert.strictEqual(reader.readInt32LE(), 0x77889900);
assert.strictEqual(reader.readUInt32BE(), 0xffddccbb);
assert.strictEqual(reader.readUInt32LE(), 0xffddccbb);
assert.closeTo(reader.readFloatBE(), 1.234, 0.001);
assert.closeTo(reader.readFloatLE(), 1.234, 0.001);
assert.closeTo(reader.readDoubleBE(), 1.23456789, 0.001);
assert.closeTo(reader.readDoubleLE(), 1.23456789, 0.001);
assert.equal(reader.readUInt8(0), 0xc8);
});
示例5: it
it("multi time wrapping", () => {
const availableWidth = measurer.measure("hell").width;
const result = wrapper.wrap(line, measurer, availableWidth);
assert.deepEqual(result.originalText, line, "original text has been set");
assert.lengthOf(result.wrappedText.split("\n"), 5, "wrapping occured");
assert.deepEqual(result.truncatedText, "", "non of the text has been truncated");
assert.closeTo(result.noBrokeWords, 3, 1, "wrapping with breaking two words about three times");
assert.equal(result.noLines, 5, "wrapping was needed");
assert.operator(measurer.measure(result.wrappedText).width, "<=", availableWidth, "wrapped text fits in");
});
示例6: it
it('should constrain value with step', () => {
const c = new StepConstraint({
step: 1,
});
assert.closeTo(c.constrain(-0.51), -1, DELTA);
assert.closeTo(c.constrain(-0.5), -1, DELTA);
assert.closeTo(c.constrain(-0.49), 0, DELTA);
assert.closeTo(c.constrain(0), 0, DELTA);
assert.closeTo(c.constrain(1.49), 1, DELTA);
assert.closeTo(c.constrain(1.5), 2, DELTA);
assert.closeTo(c.constrain(1.51), 2, DELTA);
});
示例7: it
it('should use existing identifier for control flow storage with expected chance', () => {
assert.closeTo(usingExistingIdentifierChance, expectedChance, delta);
});
示例8: it
it('should add two `control flow storage` nodes (root and inner) to the obfuscated code in different scopes', () => {
assert.closeTo(appendToScopeThreshold, expectedAppendToScopeThreshold, delta);
});
示例9: it
it(`it should convert to ${JSON.stringify(rgb)}`, () => {
const actual = ColorModel.hsvToRgb(hsv.h, hsv.s, hsv.v);
assert.closeTo(actual[0], rgb.r, DELTA);
assert.closeTo(actual[1], rgb.g, DELTA);
assert.closeTo(actual[2], rgb.b, DELTA);
});