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


TypeScript assert.isArray方法代码示例

本文整理汇总了TypeScript中chai.assert.isArray方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.isArray方法的具体用法?TypeScript assert.isArray怎么用?TypeScript assert.isArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chai.assert的用法示例。


在下文中一共展示了assert.isArray方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: while

	export function assertUnorderedLike<T>(actual:T[], expected:T[], matcher:IsLikeCB<T>, assertion:AssertCB<T>, message:string) {
		assert.isArray(actual, 'actual');
		assert.isArray(expected, 'expected');
		assert.isFunction(matcher, 'matcher');
		assert.isFunction(assertion, 'assertion');
		assert.strictEqual(actual.length, expected.length, message + ': length not equal: ' + actual.length + ' != ' + expected.length);

		// clones
		var actualQueue = actual.slice(0);
		var expectedQueue = expected.slice(0);

		outer : while (actualQueue.length > 0) {
			var act = actualQueue.pop();
			for (var i = 0, ii = expectedQueue.length; i < ii; i++) {
				var exp = expectedQueue[i];

				// check if this combination should be asserted
				if (matcher(act, exp)) {
					// do assertion
					assertion(act, exp, message);
					expectedQueue.splice(i, 1);
					// jump
					continue outer;
				}
			}
			// use assert.deepEqual for diff report
			// assert(false, message + ': no matching element for actual: ' + xm.toValueStrim(act));
			assert.deepEqual([act], expectedQueue, message + ': no matching element for actual: ' + xm.toValueStrim(act));
		}
		// also bad
		if (expectedQueue.length > 0) {
			// use deepEqual for nice report
			assert.deepEqual([], expectedQueue, message + ': remaining expect elements: ' + expectedQueue.length);
		}
	}
开发者ID:AbraaoAlves,项目名称:tsd,代码行数:35,代码来源:unordered.ts

示例2: firstPageByDefault

  @test('If no page option is specified, first page is returned')
  public async firstPageByDefault() {
    let result = await getAllOrders();
    let firstPageResult = await getAllOrders({ page: 1 });
    assert.isArray(result, 'Expected result to be an array');
    assert.isArray(firstPageResult, 'Expected result to be an array');

    assert.deepEqual(
      result[0],
      firstPageResult[0],
      'First item is the same, regardless of whether page=1 or page option is not provided at all'
    );
  }
开发者ID:qjac,项目名称:sql-fundamentals,代码行数:13,代码来源:ex03.pagination-all-orders.test.ts

示例3: getArgs

	function getArgs(test, data, info:helper.TestInfo):string[] {
		assert.isObject(test, 'test');
		assert.isObject(data, 'data');
		assert.instanceOf(info, helper.TestInfo, 'info');

		var args:string[] = [];

		if (test.command) {
			assert.isArray(test.command, 'test.command');
			args.push.apply(args, test.command);
		}
		else if (data.command) {
			assert.isArray(data.command, 'data.command');
			args.push.apply(args, data.command);
		}

		if (test.query) {
			if (test.query.pattern) {
				args.push(test.query.pattern);
			}
			if (test.query.overwrite) {
				args.push('--overwrite');
			}
			if (test.query.resolve) {
				args.push('--resolve');
			}
			if (test.query.save) {
				args.push('--save');
			}
		}

		if (test.style) {
			args.push('--style', test.style);
		}
		else {
			args.push('--style', 'plain');
		}

		args.push('--progress', 'no');
		args.push('--services', 'no');
		args.push('--cacheMode', xm.http.CacheMode[helper.settings.cache]);

		args.push('--cacheDir', info.cacheDirTestFixed);
		args.push('--config', path.resolve('./test/fixtures/config/default.json'));

		// TODO also write a .bat/.cmd and a shell script; with absolute paths etc (for lazy re-run)
		xm.file.writeJSONSync(info.argsDump, {list: args, flat: args.join(' ')});

		return args;
	}
开发者ID:HansS,项目名称:tsd,代码行数:50,代码来源:CLI.ts

示例4: assertCoords

export function assertCoords(coords: coord) {
  assert.isArray(coords);
  assert.lengthOf(coords, 2);

  assert.approximately(coords[0], 13, 1);
  assert.approximately(coords[1], 51, 3);
}
开发者ID:kiliankoe,项目名称:dvbjs,代码行数:7,代码来源:helper.ts

示例5: it

      it("sendBatches correctly batches multiple requests", function () {
        const shortRequests = [
          metrics.requestMetrics("id", createRequest(shortTimespan, "short.1")).payload,
          metrics.requestMetrics("id", createRequest(shortTimespan, "short.2", "short.3")).payload,
          metrics.requestMetrics("id", createRequest(shortTimespan, "short.4")).payload,
        ];
        const longRequests = [
          metrics.requestMetrics("id", createRequest(longTimespan, "long.1")).payload,
          metrics.requestMetrics("id", createRequest(longTimespan, "long.2", "long.3")).payload,
          metrics.requestMetrics("id", createRequest(longTimespan, "long.4", "long.5")).payload,
        ];

        // Mix the requests together and send the combined request set.
        const mixedRequests = _.flatMap(shortRequests, (short, i) => [short, longRequests[i]]);
        const sendBatches = metrics.batchAndSendRequests(mixedRequests);

        // sendBatches next puts a "fetchMetrics" action into the store.
        assert.deepEqual(sendBatches.next().value, put(metrics.fetchMetrics()));

        // Next, sendBatches dispatches a "all" effect with a "call" for each
        // batch; there should be two batches in total, one containing the
        // short requests and one containing the long requests. The order
        // of requests in each batch is maintained.
        const allEffect = sendBatches.next().value as AllEffect;
        assert.isArray(allEffect.ALL);
        assert.deepEqual(allEffect.ALL, [
          call(metrics.sendRequestBatch, shortRequests),
          call(metrics.sendRequestBatch, longRequests),
        ]);

        // After completion, puts "fetchMetricsComplete" to store.
        assert.deepEqual(sendBatches.next().value, put(metrics.fetchMetricsComplete()));
        assert.isTrue(sendBatches.next().done);
      });
开发者ID:jordanlewis,项目名称:cockroach,代码行数:34,代码来源:metrics.spec.ts

示例6: assertPin

export function assertPin(pin: IPin, type?: PIN_TYPE) {
  assert.isObject(pin);
  assertNotEmptyString(pin.type);

  if (type) {
    assert.strictEqual(pin.type, type);
  }

  assertNotEmptyString(pin.name);
  assertCoords(pin.coords);

  if (pin.type === PIN_TYPE.platform) {
    assert.isString(pin.id);
    assertNotEmptyString(pin.platform_nr);
  } else {
    assertNotEmptyString(pin.id);
    assert.isUndefined(pin.platform_nr);
  }

  if (pin.type === PIN_TYPE.stop) {
    assert.isArray(pin.connections);
    if (pin.name !== "Ebertplatz") {
      assert.isNotEmpty(pin.connections);
    }
    pin.connections!.forEach(assertConnection);
  } else {
    assert.isUndefined(pin.connections);
  }

  if (pin.type === PIN_TYPE.parkandride) {
    assertNotEmptyString(pin.info);
  } else {
    assert.isUndefined(pin.info);
  }
}
开发者ID:kiliankoe,项目名称:dvbjs,代码行数:35,代码来源:helper.ts

示例7: it

 it('should have default values', () => {
   assert.equal(group.name, '');
   assert.equal(group.path, '');
   assert.isArray(group.items);
   assert.deepEqual(group.items, []);
   assert.equal(group.groupBy, undefined);
   assert.equal(group.orderGroupBy, undefined);
 });
开发者ID:uwdata,项目名称:compassql,代码行数:8,代码来源:model.test.ts

示例8: tagUpdatesPersist

  @test('updating product tags persists successfully')
  public async tagUpdatesPersist() {
    await updateProduct(this.productId, { tags: ['foo', 'bar'] });
    let prod = await getProduct(this.productId);

    assert.isArray(prod.tags, 'tags property is an array');
    assert.equal(prod.tags.length, 2, 'tags has length 2');
  }
开发者ID:qjac,项目名称:sql-fundamentals,代码行数:8,代码来源:ex14.product.tags.test.ts

示例9: it

 it('should create a stack trace', () => {
   assert.isArray(subject.stackTrace);
   assert.ok(subject.stackTrace[0].fileName);
   assert.ok(subject.stackTrace[0].lineNumber);
   assert.ok(subject.stackTrace[0].columnNumber);
   assert.ok(subject.stackTrace[0].methodName);
   assert.ok(subject.stackTrace[0].className);
 });
开发者ID:LiberisLabs,项目名称:raygun-angular2,代码行数:8,代码来源:RaygunError.ts

示例10: assertTrip

export function assertTrip(trip: ITrip) {
  assertStopLocation(trip.departure!);
  assertStopLocation(trip.arrival!);
  assert.isNumber(trip.duration);
  assert.isNumber(trip.interchanges);

  assert.isArray(trip.nodes);
  trip.nodes.forEach(assertNode);
}
开发者ID:kiliankoe,项目名称:dvbjs,代码行数:9,代码来源:helper.ts


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