Skip to content

Commit

Permalink
test(ts): add remaining type tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
  • Loading branch information
unicornware committed Mar 3, 2023
1 parent 17ec0c8 commit eaf2254
Show file tree
Hide file tree
Showing 16 changed files with 602 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .eslintrc.base.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,8 @@ const config = {
expectTypeOf: true
},
rules: {
'@typescript-eslint/ban-types': 0
'@typescript-eslint/ban-types': 0,
'@typescript-eslint/no-redundant-type-constituents': 0
}
},
{
Expand Down
162 changes: 162 additions & 0 deletions src/enums/__tests__/kind.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/**
* @file Type Tests - Kind
* @module docast/enums/tests/unit-d/Kind
*/

import type { EmptyString } from '@flex-development/tutils'
import type TestSubject from '../kind'

describe('unit-d:enums/Kind', () => {
it('should match [ACCESSOR = "accessor"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('ACCESSOR')
.extract<'accessor'>()
.toBeString()
})

it('should match [CLASS = "class"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('CLASS')
.extract<'class'>()
.toBeString()
})

it('should match [CONST = "const"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('CONST')
.extract<'const'>()
.toBeString()
})

it('should match [CONSTRUCTOR = "constructor"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('CONSTRUCTOR')
.extract<'constructor'>()
.toBeString()
})

it('should match [DEFAULT = "default"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('DEFAULT')
.extract<'default'>()
.toBeString()
})

it('should match [ENUM = "enum"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('ENUM')
.extract<'enum'>()
.toBeString()
})

it('should match [ENUM_CONST = "const enum"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('ENUM_CONST')
.extract<'const enum'>()
.toBeString()
})

it('should match [FUNCTION = "function"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('FUNCTION')
.extract<'function'>()
.toBeString()
})

it('should match [GENERATOR = "function*"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('GENERATOR')
.extract<'function*'>()
.toBeString()
})

it('should match [GET = "get"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('GET')
.extract<'get'>()
.toBeString()
})

it('should match [INTERFACE = "interface"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('INTERFACE')
.extract<'interface'>()
.toBeString()
})

it('should match [LET = "let"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('LET')
.extract<'let'>()
.toBeString()
})

it('should match [MEMBER = "member"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('MEMBER')
.extract<'member'>()
.toBeString()
})

it('should match [METHOD = "method"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('METHOD')
.extract<'method'>()
.toBeString()
})

it('should match [MODULE = "module"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('MODULE')
.extract<'module'>()
.toBeString()
})

it('should match [NAMESPACE = "namespace"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('NAMESPACE')
.extract<'namespace'>()
.toBeString()
})

it('should match [PROPERTY = "property"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('PROPERTY')
.extract<'property'>()
.toBeString()
})

it('should match [SET = "set"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('SET')
.extract<'set'>()
.toBeString()
})

it('should match [STATEMENT = "statement"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('STATEMENT')
.extract<'statement'>()
.toBeString()
})

it('should match [TYPE = "type"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('TYPE')
.extract<'type'>()
.toBeString()
})

it('should match [UNKNOWN = ""]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('UNKNOWN')
.toMatchTypeOf<EmptyString>()
})

it('should match [VAR = "var"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('VAR')
.extract<'var'>()
.toBeString()
})
})
85 changes: 85 additions & 0 deletions src/enums/__tests__/modifier.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/**
* @file Type Tests - Modifier
* @module docast/enums/tests/unit-d/Modifier
*/

import type TestSubject from '../modifier'

describe('unit-d:enums/Modifier', () => {
it('should match [ABSTRACT = "abstract"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('ABSTRACT')
.extract<'abstract'>()
.toBeString()
})

it('should match [ASYNC = "async"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('ASYNC')
.extract<'async'>()
.toBeString()
})

it('should match [DECLARE = "declare"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('DECLARE')
.extract<'declare'>()
.toBeString()
})

it('should match [DEFAULT = "default"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('DEFAULT')
.extract<'default'>()
.toBeString()
})

it('should match [EXPORT = "export"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('EXPORT')
.extract<'export'>()
.toBeString()
})

it('should match [OVERRIDE = "override"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('OVERRIDE')
.extract<'override'>()
.toBeString()
})

it('should match [PRIVATE = "private"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('PRIVATE')
.extract<'private'>()
.toBeString()
})

it('should match [PROTECTED = "protected"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('PROTECTED')
.extract<'protected'>()
.toBeString()
})

it('should match [PUBLIC = "public"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('PUBLIC')
.extract<'public'>()
.toBeString()
})

it('should match [READONLY = "readonly"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('READONLY')
.extract<'readonly'>()
.toBeString()
})

it('should match [STATIC = "static"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('STATIC')
.extract<'static'>()
.toBeString()
})
})
43 changes: 43 additions & 0 deletions src/enums/__tests__/type.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* @file Type Tests - Type
* @module docast/enums/tests/unit-d/Type
*/

import type TestSubject from '../type'

describe('unit-d:enums/Type', () => {
it('should match [BLOCK_TAG = "block-tag"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('BLOCK_TAG')
.extract<'block-tag'>()
.toBeString()
})

it('should match [COMMENT = "comment"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('COMMENT')
.extract<'comment'>()
.toBeString()
})

it('should match [IMPLICIT_DESCRIPTION = "implicit-description"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('IMPLICIT_DESCRIPTION')
.extract<'implicit-description'>()
.toBeString()
})

it('should match [INLINE_TAG = "inline-tag"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('INLINE_TAG')
.extract<'inline-tag'>()
.toBeString()
})

it('should match [ROOT = "root"]', () => {
expectTypeOf<typeof TestSubject>()
.toHaveProperty('ROOT')
.extract<'root'>()
.toBeString()
})
})
33 changes: 33 additions & 0 deletions src/interfaces/__tests__/context.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @file Type Tests - Context
* @module docast/interfaces/tests/unit-d/Context
*/

import type { Kind } from '#src/enums'
import type { LiteralUnion, Nullable } from '@flex-development/tutils'
import type TestSubject from '../context'
import type Position from '../position'

describe('unit-d:interfaces/Context', () => {
it('should match [identifier: string]', () => {
expectTypeOf<TestSubject>().toHaveProperty('identifier').toBeString()
})

it('should match [kind: LiteralUnion<Kind, "string">]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('kind')
.toEqualTypeOf<LiteralUnion<Kind, 'string'>>()
})

it('should match [parent: Nullable<string>]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('parent')
.toEqualTypeOf<Nullable<string>>()
})

it('should match [position: Position]', () => {
expectTypeOf<TestSubject>()
.toHaveProperty('position')
.toEqualTypeOf<Position>()
})
})
13 changes: 13 additions & 0 deletions src/interfaces/__tests__/point.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @file Type Tests - Point
* @module docast/interfaces/tests/unit-d/Point
*/

import type unist from 'unist'
import type TestSubject from '../point'

describe('unit-d:interfaces/Point', () => {
it('should extend Required<unist.Point>', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<Required<unist.Point>>()
})
})
22 changes: 22 additions & 0 deletions src/interfaces/__tests__/position.spec-d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* @file Type Tests - Position
* @module docast/interfaces/tests/unit-d/Position
*/

import type unist from 'unist'
import type Point from '../point'
import type TestSubject from '../position'

describe('unit-d:interfaces/Position', () => {
it('should extend unist.Position', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<unist.Position>()
})

it('should match [end: Point]', () => {
expectTypeOf<TestSubject>().toHaveProperty('end').toEqualTypeOf<Point>()
})

it('should match [start: Point]', () => {
expectTypeOf<TestSubject>().toHaveProperty('start').toEqualTypeOf<Point>()
})
})
5 changes: 3 additions & 2 deletions src/interfaces/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
* @module docast/interfaces/Context
*/

import type { Nullable } from '@flex-development/tutils'
import type { Kind } from '#src/enums'
import type { LiteralUnion, Nullable } from '@flex-development/tutils'
import type Position from './position'

/**
Expand All @@ -20,7 +21,7 @@ interface Context {
/**
* Segment syntax kind.
*/
kind: string
kind: LiteralUnion<Kind, 'string'>

/**
* Segment parent.
Expand Down
Loading

0 comments on commit eaf2254

Please sign in to comment.