-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
- Loading branch information
1 parent
1fbe902
commit 0a118cb
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* @file Type Tests - Root | ||
* @module esast/nodes/tests/unit-d/Root | ||
*/ | ||
|
||
import type { | ||
Data, | ||
EcmaVersion, | ||
Parent, | ||
RootChild, | ||
SourceMode | ||
} from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
import type * as TestSubject from '../root' | ||
|
||
describe('unit-d:nodes/Root', () => { | ||
type Subject = TestSubject.default | ||
type SubjectData = TestSubject.RootData | ||
|
||
it('should extend Parent', () => { | ||
expectTypeOf<Subject>().toMatchTypeOf<Parent>() | ||
}) | ||
|
||
it('should match [children: RootChild[]]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('children') | ||
.toEqualTypeOf<RootChild[]>() | ||
}) | ||
|
||
it('should match [data?: Optional<RootData>]', () => { | ||
expectTypeOf<Subject>() | ||
.toHaveProperty('data') | ||
.toEqualTypeOf<Optional<SubjectData>>() | ||
}) | ||
|
||
it('should match [mode: SourceMode]', () => { | ||
expectTypeOf<Subject>().toHaveProperty('mode').toEqualTypeOf<SourceMode>() | ||
}) | ||
|
||
it('should match [type: "root"]', () => { | ||
expectTypeOf<Subject>().toHaveProperty('type').toEqualTypeOf<'root'>() | ||
}) | ||
|
||
describe('RootData', () => { | ||
it('should extend Data', () => { | ||
expectTypeOf<SubjectData>().toMatchTypeOf<Data>() | ||
}) | ||
|
||
it('should match [ecmaVersion?: Nilable<EcmaVersion>]', () => { | ||
expectTypeOf<SubjectData>() | ||
.toHaveProperty('ecmaVersion') | ||
.toEqualTypeOf<Nilable<EcmaVersion>>() | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* @file Nodes - Root | ||
* @module esast/nodes/Root | ||
*/ | ||
|
||
import type { | ||
Data, | ||
EcmaVersion, | ||
Parent, | ||
RootChild, | ||
SourceMode | ||
} from '@flex-development/esast' | ||
import type { Nilable, Optional } from '@flex-development/tutils' | ||
|
||
/** | ||
* Info associated with documents. | ||
* | ||
* @see {@linkcode Data} | ||
* | ||
* @extends {Data} | ||
*/ | ||
interface RootData extends Data { | ||
/** | ||
* ECMAScript version of source document. | ||
* | ||
* @see {@linkcode EcmaVersion} | ||
*/ | ||
ecmaVersion?: Nilable<EcmaVersion> | ||
} | ||
|
||
/** | ||
* A document fragment or whole document. | ||
* | ||
* Should be used as the root of a tree; must not be used as a child. | ||
* | ||
* @see {@linkcode Parent} | ||
* | ||
* @extends {Parent} | ||
*/ | ||
interface Root extends Parent { | ||
/** | ||
* List of children. | ||
* | ||
* @see {@linkcode RootChild} | ||
*/ | ||
children: RootChild[] | ||
|
||
/** | ||
* Data associated with esast root. | ||
* | ||
* @see {@linkcode RootData} | ||
*/ | ||
data?: Optional<RootData> | ||
|
||
/** | ||
* Mode source document was parsed in. | ||
* | ||
* @see {@linkcode SourceMode} | ||
*/ | ||
mode: SourceMode | ||
|
||
/** | ||
* Node type. | ||
*/ | ||
type: 'root' | ||
} | ||
|
||
export type { RootData, Root as default } |