Skip to content

Commit

Permalink
refactor(nodes): [Root] allow position
Browse files Browse the repository at this point in the history
Signed-off-by: Lexus Drumgold <[email protected]>
  • Loading branch information
unicornware committed Apr 12, 2024
1 parent c178afd commit b8e7388
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ children &mdash; it is a [*leaf*][unist-leaf].
interface Root extends Parent {
children: Comment[]
data?: RootData | undefined
position?: undefined
type: 'root'
}
```
Expand Down
26 changes: 15 additions & 11 deletions src/nodes/__tests__/root.spec-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,37 @@
* @module docast/nodes/tests/unit-d/Root
*/

import type { Comment, Data, Parent } from '@flex-development/docast'
import type { Optional } from '@flex-development/tutils'
import type Comment from '../comment'
import type Parent from '../parent'
import type { RootData, default as TestSubject } from '../root'
import type * as TestSubject from '../root'

describe('unit-d:nodes/Root', () => {
type Subject = TestSubject.default
type SubjectData = TestSubject.RootData

it('should extend Parent', () => {
expectTypeOf<TestSubject>().toMatchTypeOf<Parent>()
expectTypeOf<Subject>().toMatchTypeOf<Parent>()
})

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

it('should match [data?: Optional<RootData>]', () => {
expectTypeOf<TestSubject>()
expectTypeOf<Subject>()
.toHaveProperty('data')
.toEqualTypeOf<Optional<RootData>>()
.toEqualTypeOf<Optional<SubjectData>>()
})

it('should match [position?: undefined]', () => {
expectTypeOf<TestSubject>().toHaveProperty('position').toBeUndefined()
it('should match [type: "root"]', () => {
expectTypeOf<Subject>().toHaveProperty('type').toEqualTypeOf<'root'>()
})

it('should match [type: "root"]', () => {
expectTypeOf<TestSubject>().toHaveProperty('type').toEqualTypeOf<'root'>()
describe('RootData', () => {
it('should extend Data', () => {
expectTypeOf<SubjectData>().toMatchTypeOf<Data>()
})
})
})
11 changes: 2 additions & 9 deletions src/nodes/root.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
* @module docast/nodes/Root
*/

import type { Data } from '#src/interfaces'
import type { Comment, Data, Parent } from '@flex-development/docast'
import type { Optional } from '@flex-development/tutils'
import type Comment from './comment'
import type Parent from './parent'

/**
* Info associated with documents.
Expand Down Expand Up @@ -35,17 +33,12 @@ interface Root extends Parent {
children: Comment[]

/**
* Data associated with docast root.
* Info from the ecosystem.
*
* @see {@linkcode RootData}
*/
data?: Optional<RootData>

/**
* Position of root in source document.
*/
position?: undefined

/**
* Node type.
*/
Expand Down

0 comments on commit b8e7388

Please sign in to comment.