本文整理汇总了TypeScript中chai.assert.lengthOf方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.lengthOf方法的具体用法?TypeScript assert.lengthOf怎么用?TypeScript assert.lengthOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chai.assert
的用法示例。
在下文中一共展示了assert.lengthOf方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it("should correctly dispatch receiveMetrics with an unmatching nextRequest", function() {
const response = new protos.cockroach.ts.tspb.TimeSeriesQueryResponse({
results: [
{
datapoints: [],
},
],
});
const request = new protos.cockroach.ts.tspb.TimeSeriesQueryRequest({
start_nanos: Long.fromNumber(0),
end_nanos: Long.fromNumber(10),
queries: [
{
name: "test.metric.1",
},
],
});
state = metrics.metricsReducer(state, metrics.receiveMetrics(componentID, request, response));
assert.isDefined(state.queries);
assert.isDefined(state.queries[componentID]);
assert.lengthOf(_.keys(state.queries), 1);
assert.equal(state.queries[componentID].data, null);
assert.equal(state.queries[componentID].request, null);
assert.isUndefined(state.queries[componentID].nextRequest);
assert.isUndefined(state.queries[componentID].error);
});
示例2: Error
response: (url: string, requestObj: RequestInit) => {
const params = url.split("?")[1].split("&");
assert.lengthOf(params, 2);
_.each(params, (param) => {
let [k, v] = param.split("=");
k = decodeURIComponent(k);
v = decodeURIComponent(v);
switch (k) {
case "target_id":
assert.equal(req.target_id.toString(), v);
break;
case "type":
assert.equal(req.type, v);
break;
default:
throw new Error(`Unknown property ${k}`);
}
});
assert.isUndefined(requestObj.body);
const encodedResponse = protos.cockroach.server.serverpb.EventsResponse.encode({
events: [
{ event_type: "test" },
],
}).finish();
return {
body: api.toArrayBuffer(encodedResponse),
};
},
示例3: createFormatter
createFormatter("testCastNumber", RestTestCastService).deserializeRequest(message, (err, args) => {
if(err) return done(err);
assert.lengthOf(args, 1);
assert.strictEqual(args[0], 10.5);
done();
});
示例4: it
it('should remove the item from the array', () => {
let removedValue = dummy.values[1];
let lastValue = dummy.values[2];
dummy.remove(removedValue);
assert.lengthOf(dummy.values, 2, 'dummy.values should now be 2 items');
assert.notDeepEqual(dummy.values[1], removedValue, 'value[1] should now be a different value after remove');
assert.deepEqual(dummy.values[1], lastValue, 'value[1] should now be equal to the last value');
});
示例5: it
it('returns C numbers between S and (S + C) - 1', () => {
const result = [...gen.range(1, 10)];
assert.lengthOf(result, 10);
assert.equal(result[0], 1);
assert.equal(result[result.length - 1], 10);
});
示例6: assert
fetchMock.mock(eventsUrl, "get", (url: string, requestObj: RequestInit) => {
let params = url.split("?")[1].split("&");
assert.lengthOf(params, 1);
assert(params[0].split("=")[0] === "type");
assert(params[0].split("=")[1] === "here");
assert.isUndefined(requestObj.body);
return {};
});
示例7: clearTimeout
store.subscribe(() => {
let state = store.getState();
clearTimeout(timeout);
if (state.cachedData.cluster.data &&
state.cachedData.cluster.data.cluster_id &&
state.uiData[KEY_REGISTRATION_SYNCHRONIZED] &&
state.uiData[KEY_REGISTRATION_SYNCHRONIZED].data
) {
// Ensure every relevant url is called exactly once.
assert.lengthOf(fetchMock.calls(uiDataFetchURL), 1);
assert.lengthOf(fetchMock.calls(uiDataPostFetchURL), 1);
assert.lengthOf(fetchMock.calls(clusterFetchURL), 1);
assert.lengthOf(fetchMock.calls(registrationFetchURL), 1);
assert.lengthOf(fetchMock.calls(unregistrationFetchURL), 0);
timeout = setTimeout(() => done());
}
});
示例8:
return p.then(() => {
// Assert that the server got the correct number of requests (2).
assert.lengthOf(fetchMock.calls("/ts/query"), 2);
// Assert that the mock metrics state has 2 queries.
assert.lengthOf(_.keys(mockMetricsState.queries), 2);
// Assert query with id.1 has results.
let q1 = mockMetricsState.queries["id.1"];
assert.isDefined(q1);
assert.isDefined(q1.data);
assert.isUndefined(q1.error);
// Assert query with id.2 has an error.
let q2 = mockMetricsState.queries["id.2"];
assert.isDefined(q2);
assert.isDefined(q2.error);
assert.isUndefined(q2.data);
// Assert that inFlight is 0.
assert.equal(mockMetricsState.inFlight, 0);
});
示例9:
.then(users => {
assert.lengthOf(users, usersFromFile.length);
if (bypassLifecyclehooks) {
users.forEach(user => {
assert.lengthOf(user['posts'], 1);
});
}
});
示例10: it
it("does not break words, except as last resort", () => {
const availableWidth = measurer.measure(token).width * 3 / 4;
const result = wrapper.wrap(token, measurer, availableWidth);
assert.lengthOf(result.wrappedText.split("\n"), 2, "wrapping occured");
assert.deepEqual(result.truncatedText, "", "non of the text has been truncated");
assert.deepEqual(result.noBrokeWords, 1, "wrapping with breaking one word");
assert.deepEqual(result.noLines, 2, "wrapping was needed");
assert.operator(measurer.measure(result.wrappedText).width, "<=", availableWidth, "wrapped text fits in");
});