0.3.1 • Published 1 year ago

@signpostmarv/ts-assert v0.3.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 year ago

Coverage Status Workflow Status

@signpostmarv/ts-assert

Code-generated assertions for TypeScript type guarding functions.

Usage

import {describe, it} from 'node:test';
import assert from 'node:assert/strict';
import ts_assert from '@signpostmarv/ts-assert';
import ts from 'typescript';

void describe('isIdentifier', () => {
	void it('throws', () => {
		assert.throws(() =>
			ts_assert.isIdentifier(ts.factory.createStringLiteral('foo'))
		);
	});
});

void describe('isEmptyBindingPattern', () => {
	void it('throws', () => {
		assert.throws(() =>
			ts_assert.isEmptyBindingPattern(ts.factory.createIdentifier('foo'))
		);
	});
});

void describe('isBooleanLiteral', () => {
	void it('throws', () => {
		assert.throws(() =>
			ts_assert.isBooleanLiteral(
				ts.factory.createStringLiteral('foo'),
				true
			)
		);
		assert.throws(() =>
			ts_assert.isBooleanLiteral(ts.factory.createFalse(), true)
		);
		assert.throws(() =>
			ts_assert.isBooleanLiteral(ts.factory.createTrue(), false)
		);
	});
	void it('does not throw', () => {
		assert.doesNotThrow(() =>
			ts_assert.isBooleanLiteral(ts.factory.createTrue(), true)
		);
		assert.doesNotThrow(() =>
			ts_assert.isBooleanLiteral(ts.factory.createFalse(), false)
		);
	});
});

void describe('isTokenWithExpectedKind', () => {
	void it('throws', () => {
		assert.throws(() =>
			ts_assert.isTokenWithExpectedKind(
				ts.factory.createStringLiteral('foo'),
				ts.SyntaxKind.StringKeyword
			)
		);
		assert.throws(() =>
			ts_assert.isTokenWithExpectedKind(
				ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
				ts.SyntaxKind.NumberKeyword
			)
		);
	});
	void it('does not throw', () => {
		assert.doesNotThrow(() =>
			ts_assert.isTokenWithExpectedKind(
				ts.factory.createKeywordTypeNode(ts.SyntaxKind.StringKeyword),
				ts.SyntaxKind.StringKeyword
			)
		);
	});
});
0.3.1

1 year ago

0.3.0

1 year ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.1.0--beta

1 year ago

0.1.1--develop

1 year ago

0.1.0--develop

1 year ago