chai#Assertion TypeScript Examples

The following examples show how to use chai#Assertion. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: filter-matcher.ts    From metadata-filter with MIT License 6 votes vote down vote up
function filterWith(
	this: Chai.AssertionStatic,
	...filterFunctions: FilterFunction[]
) {
	const filter = this._obj as unknown;
	if (!(filter instanceof MetadataFilter)) {
		throw new Error(
			"'filterWith' method must be used for MetadataFilter objects"
		);
	}

	for (const field of filter.getFields()) {
		filter.filterField(field, 'Test');
	}

	for (const f of filterFunctions) {
		new Assertion(f).to.have.been.called();
	}
}
Example #2
Source File: filter-matcher.ts    From metadata-filter with MIT License 5 votes vote down vote up
export function filterMatcher(chai: Chai.ChaiStatic): void {
	chai.Assertion.addMethod('filterWith', filterWith);
}