当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript assert.closeTo方法代码示例

本文整理汇总了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();
  };
开发者ID:palantir,项目名称:svg-typewriter,代码行数:25,代码来源:writerTests.ts

示例2: it

			it(`should map to ${testCase.expected}`, () => {
				assert.closeTo(
					NumberUtil.map(...testCase.args),
					testCase.expected,
					DELTA,
				);
			});
开发者ID:cocopon,项目名称:tweakpane,代码行数:7,代码来源:number-util-test.ts

示例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)
 })
开发者ID:faradayio,项目名称:node_smartystreets,代码行数:16,代码来源:program-tests.ts

示例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);
 });
开发者ID:JoshGlazebrook,项目名称:smart-buffer,代码行数:18,代码来源:smartbuffer.test.ts

示例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");
 });
开发者ID:palantir,项目名称:svg-typewriter,代码行数:10,代码来源:wrapperTests.ts

示例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);
	});
开发者ID:cocopon,项目名称:tweakpane,代码行数:12,代码来源:step-test.ts

示例7: it

 it('should use existing identifier for control flow storage with expected chance', () => {
     assert.closeTo(usingExistingIdentifierChance, expectedChance, delta);
 });
开发者ID:dssoft32,项目名称:javascript-obfuscator,代码行数:3,代码来源:LogicalExpressionControlFlowReplacer.spec.ts

示例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);
 });
开发者ID:dssoft32,项目名称:javascript-obfuscator,代码行数:3,代码来源:FunctionControlFlowTransformer.spec.ts

示例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);
			});
开发者ID:cocopon,项目名称:tweakpane,代码行数:6,代码来源:color-model-test.ts


注:本文中的chai.assert.closeTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。