Skip to content

Commit 5b2fa44

Browse files
committed
build(deps): bump @flex-development/tutils from 6.0.0-alpha.10 to 6.0.0-alpha.12
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 05fff35 commit 5b2fa44

File tree

12 files changed

+159
-134
lines changed

12 files changed

+159
-134
lines changed

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,9 @@
8383
},
8484
"dependencies": {
8585
"@flex-development/docast": "1.0.0-alpha.12",
86-
"@flex-development/tutils": "6.0.0-alpha.10",
86+
"@flex-development/tutils": "6.0.0-alpha.12",
8787
"@types/unist": "2.0.6",
8888
"detab": "3.0.2",
89-
"escape-string-regexp": "5.0.0",
9089
"unist-builder": "3.0.1",
9190
"unist-util-source": "4.0.2",
9291
"vfile": "5.3.7",
@@ -177,7 +176,7 @@
177176
},
178177
"resolutions": {
179178
"@ardatan/sync-fetch": "larsgw/sync-fetch#head=worker_threads",
180-
"@flex-development/tutils": "6.0.0-alpha.10",
179+
"@flex-development/tutils": "6.0.0-alpha.12",
181180
"unist-util-inspect@npm:7.0.1": "patch:unist-util-inspect@npm%3A7.0.1#patches/unist-util-inspect+7.0.1.dev.patch"
182181
},
183182
"engines": {

src/__tests__/attacher.spec-d.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55

66
import type { Options } from '#src/interfaces'
77
import type { Root } from '@flex-development/docast'
8+
import type { Optional } from '@flex-development/tutils'
89
import type unified from 'unified'
910
import type testSubject from '../attacher'
1011

1112
describe('unit-d:attacher', () => {
1213
it('should be callable with [Options?]', () => {
13-
// Act
14-
type Params = [options?: Options | undefined]
14+
// Arrange
15+
type P = [options?: Optional<Options>]
1516

16-
expectTypeOf<typeof testSubject>().parameters.toEqualTypeOf<Params>()
17+
// Expect
18+
expectTypeOf<typeof testSubject>().parameters.toEqualTypeOf<P>()
1719
})
1820

1921
it('should be typeof unified.Plugin', () => {
2022
// Arrange
21-
type Plugin = unified.Plugin<[options?: Options | undefined], string, Root>
23+
type Plugin = unified.Plugin<[options?: Optional<Options>], string, Root>
2224

2325
// Expect
2426
expectTypeOf<typeof testSubject>().toEqualTypeOf<Plugin>()

src/__tests__/lexer.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { LexerState, TokenKind } from '#src/enums'
77
import type { Token } from '#src/interfaces'
8-
import type { Predicate } from '@flex-development/tutils'
8+
import { set, type Predicate } from '@flex-development/tutils'
99
import fs from 'node:fs'
1010
import { VFile } from 'vfile'
1111
import TestSubject from '../lexer'
@@ -47,7 +47,7 @@ describe('unit:lexer', () => {
4747
it(`should return true if ${position} is equal to ${max}`, () => {
4848
// Arrange
4949
const subject = new TestSubject(document, file)
50-
Object.assign(subject, { position: subject.tokens.length - 1 })
50+
set(subject, 'position', subject.tokens.length - 1)
5151

5252
// Act + Expect
5353
expect(subject.done).to.be.true
@@ -56,7 +56,7 @@ describe('unit:lexer', () => {
5656
it(`should return true if ${position} is greater than ${max}`, () => {
5757
// Arrange
5858
const subject = new TestSubject(document, file)
59-
Object.assign(subject, { position: subject.tokens.length })
59+
set(subject, 'position', subject.tokens.length)
6060

6161
// Act + Expect
6262
expect(subject.done).to.be.true
@@ -98,7 +98,7 @@ describe('unit:lexer', () => {
9898

9999
it('should return token sequence subset', () => {
100100
// Arrange
101-
const condition: Predicate<Token> = (token: Token) => {
101+
const condition: Predicate<Token[]> = (token: Token) => {
102102
return token.kind === TokenKind.EOF
103103
}
104104

@@ -108,7 +108,7 @@ describe('unit:lexer', () => {
108108

109109
it('should return token sequence subset from next k-th token', () => {
110110
// Arrange
111-
const condition: Predicate<Token> = (token: Token) => {
111+
const condition: Predicate<Token[]> = (token: Token) => {
112112
return token.kind === TokenKind.TAG_BLOCK_END
113113
}
114114

src/__tests__/parser.spec.ts

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
import { LexerState, TokenKind } from '#src/enums'
7-
import type { Token } from '#src/interfaces'
87
import type { Point } from '@flex-development/docast'
8+
import { cast } from '@flex-development/tutils'
99
import fs from 'node:fs'
1010
import path from 'node:path'
1111
import { VFile } from 'vfile'
@@ -29,41 +29,41 @@ describe('unit:parser', () => {
2929

3030
it('should throw if token is not of kind COMMENT_START', () => {
3131
// Arrange
32-
let error: SyntaxError | undefined
32+
const message: string = 'expected token of kind COMMENT_START'
33+
let error!: SyntaxError
3334

3435
// Act
3536
try {
3637
// @ts-expect-error ts(2445)
37-
subject.parseComment({} as Token, 0)
38+
subject.parseComment(cast({}), 0)
3839
} catch (e: unknown) {
39-
error = e as typeof error
40+
error = cast(e)
4041
}
4142

4243
// Expect
43-
expect(error).to.not.be.undefined
44-
expect(error).toBeInstanceOf(SyntaxError)
45-
expect(error?.message).to.equal('expected token of kind COMMENT_START')
44+
expect(error).to.be.instanceof(SyntaxError)
45+
expect(error).to.have.property('message', message)
4646
})
4747

4848
it('should throw if token match is not of kind COMMENT_END', () => {
4949
// Arrange
5050
const kind: TokenKind = TokenKind.COMMENT_START
51+
const message: string = 'expected token of kind COMMENT_END'
5152
const point: Point = { column: 1, line: 1, offset: 0 }
5253
const state: LexerState = LexerState.COMMENT
53-
let error: SyntaxError | undefined
54+
let error!: SyntaxError
5455

5556
// Act
5657
try {
5758
// @ts-expect-error ts(2445)
5859
subject.parseComment({ kind, point, state, value: '/**' }, 0)
5960
} catch (e: unknown) {
60-
error = e as typeof error
61+
error = cast(e)
6162
}
6263

6364
// Expect
64-
expect(error).to.not.be.undefined
65-
expect(error).toBeInstanceOf(SyntaxError)
66-
expect(error?.message).to.equal('expected token of kind COMMENT_END')
65+
expect(error).to.be.instanceof(SyntaxError)
66+
expect(error).to.have.property('message', message)
6767
})
6868
})
6969

@@ -77,22 +77,22 @@ describe('unit:parser', () => {
7777
it('should throw if token match is not of kind CONTEXT_END', () => {
7878
// Arrange
7979
const kind: TokenKind = TokenKind.CONTEXT_START
80+
const message: string = 'expected token of kind CONTEXT_END'
8081
const point: Point = { column: 1, line: 36, offset: 1005 }
8182
const state: LexerState = LexerState.READY
82-
let error: SyntaxError | undefined
83+
let error!: SyntaxError
8384

8485
// Act
8586
try {
8687
// @ts-expect-error ts(2445)
8788
subject.parseContext({ kind, point, state, value: '' }, 0)
8889
} catch (e: unknown) {
89-
error = e as typeof error
90+
error = cast(e)
9091
}
9192

9293
// Expect
93-
expect(error).to.not.be.undefined
94-
expect(error).toBeInstanceOf(SyntaxError)
95-
expect(error?.message).to.equal('expected token of kind CONTEXT_END')
94+
expect(error).to.be.instanceof(SyntaxError)
95+
expect(error).to.have.property('message', message)
9696
})
9797
})
9898

@@ -111,42 +111,42 @@ describe('unit:parser', () => {
111111
it(`should throw if token is not of kind ${kinds[0]}`, () => {
112112
// Arrange
113113
const kind: keyof typeof TokenKind = kinds[0]!
114-
let error: SyntaxError | undefined
114+
const message: string = `expected token of kind ${kind}`
115+
let error!: SyntaxError
115116

116117
// Act
117118
try {
118119
// @ts-expect-error ts(2445)
119-
subject.parseImplicitDescription({} as Token, 0)
120+
subject.parseImplicitDescription(cast({}), 0)
120121
} catch (e: unknown) {
121-
error = e as typeof error
122+
error = cast(e)
122123
}
123124

124125
// Expect
125-
expect(error).to.not.be.undefined
126-
expect(error).toBeInstanceOf(SyntaxError)
127-
expect(error?.message).to.equal(`expected token of kind ${kind}`)
126+
expect(error).to.be.instanceof(SyntaxError)
127+
expect(error).to.have.property('message', message)
128128
})
129129

130130
it(`should throw if token match is not of kind ${kinds[1]}`, () => {
131131
// Arrange
132132
const kind_expected: keyof typeof TokenKind = kinds[1]!
133133
const kind: TokenKind = TokenKind.IMPLICIT_DESCRIPTION_START
134+
const message: string = `expected token of kind ${kind_expected}`
134135
const point: Point = { column: 4, line: 9, offset: 95 }
135136
const state: LexerState = LexerState.IMPLICIT_DESCRIPTION
136-
let error: SyntaxError | undefined
137+
let error!: SyntaxError
137138

138139
// Act
139140
try {
140141
// @ts-expect-error ts(2445)
141142
subject.parseImplicitDescription({ kind, point, state, value: 'T' }, 0)
142143
} catch (e: unknown) {
143-
error = e as typeof error
144+
error = cast(e)
144145
}
145146

146147
// Expect
147-
expect(error).to.not.be.undefined
148-
expect(error).toBeInstanceOf(SyntaxError)
149-
expect(error?.message).to.equal(`expected token of kind ${kind_expected}`)
148+
expect(error).to.be.instanceof(SyntaxError)
149+
expect(error).to.have.property('message', message)
150150
})
151151
})
152152

@@ -159,41 +159,41 @@ describe('unit:parser', () => {
159159

160160
it('should throw if token is not of kind TAG_BLOCK_START', () => {
161161
// Arrange
162-
let error: SyntaxError | undefined
162+
const message: string = 'expected token of kind TAG_BLOCK_START'
163+
let error!: SyntaxError
163164

164165
// Act
165166
try {
166167
// @ts-expect-error ts(2445)
167-
subject.parseTagBlock({} as Token, 0)
168+
subject.parseTagBlock(cast({}), 0)
168169
} catch (e: unknown) {
169-
error = e as typeof error
170+
error = cast(e)
170171
}
171172

172173
// Expect
173-
expect(error).to.not.be.undefined
174-
expect(error).toBeInstanceOf(SyntaxError)
175-
expect(error?.message).to.equal('expected token of kind TAG_BLOCK_START')
174+
expect(error).to.be.instanceof(SyntaxError)
175+
expect(error).to.have.property('message', message)
176176
})
177177

178178
it('should throw if token match is not of kind TAG_BLOCK_END', () => {
179179
// Arrange
180180
const kind: TokenKind = TokenKind.TAG_BLOCK_START
181+
const message: string = 'expected token of kind TAG_BLOCK_END'
181182
const point: Point = { column: 4, line: 2, offset: 7 }
182183
const state: LexerState = LexerState.COMMENT
183-
let error: SyntaxError | undefined
184+
let error!: SyntaxError
184185

185186
// Act
186187
try {
187188
// @ts-expect-error ts(2445)
188189
subject.parseTagBlock({ kind, point, state, value: '@' }, 0)
189190
} catch (e: unknown) {
190-
error = e as typeof error
191+
error = cast(e)
191192
}
192193

193194
// Expect
194-
expect(error).to.not.be.undefined
195-
expect(error).toBeInstanceOf(SyntaxError)
196-
expect(error?.message).to.equal('expected token of kind TAG_BLOCK_END')
195+
expect(error).to.be.instanceof(SyntaxError)
196+
expect(error).to.have.property('message', message)
197197
})
198198
})
199199

@@ -206,42 +206,42 @@ describe('unit:parser', () => {
206206

207207
it('should throw if token is not of kind TAG_INLINE_START', () => {
208208
// Arrange
209-
let error: SyntaxError | undefined
209+
const message: string = 'expected token of kind TAG_INLINE_START'
210+
let error!: SyntaxError
210211

211212
// Act
212213
try {
213214
// @ts-expect-error ts(2445)
214-
subject.parseTagInline({} as Token, 0)
215+
subject.parseTagInline(cast({}), 0)
215216
} catch (e: unknown) {
216-
error = e as typeof error
217+
error = cast(e)
217218
}
218219

219220
// Expect
220-
expect(error).to.not.be.undefined
221-
expect(error).toBeInstanceOf(SyntaxError)
222-
expect(error?.message).to.equal('expected token of kind TAG_INLINE_START')
221+
expect(error).to.be.instanceof(SyntaxError)
222+
expect(error).to.have.property('message', message)
223223
})
224224

225225
it('should throw if token match is not of kind TAG_INLINE_END', () => {
226226
// Arrange
227227
const kind: TokenKind = TokenKind.TAG_INLINE_START
228+
const message: string = 'expected token of kind TAG_INLINE_END'
228229
const point: Point = { column: 9, line: 21, offset: 631 }
229230
const state: LexerState = LexerState.COMMENT
230231
const value: string = '{@link psum}'
231-
let error: SyntaxError | undefined
232+
let error!: SyntaxError
232233

233234
// Act
234235
try {
235236
// @ts-expect-error ts(2445)
236237
subject.parseTagInline({ kind, point, state, value }, 0)
237238
} catch (e: unknown) {
238-
error = e as typeof error
239+
error = cast(e)
239240
}
240241

241242
// Expect
242-
expect(error).to.not.be.undefined
243-
expect(error).toBeInstanceOf(SyntaxError)
244-
expect(error?.message).to.equal('expected token of kind TAG_INLINE_END')
243+
expect(error).to.be.instanceof(SyntaxError)
244+
expect(error).to.have.property('message', message)
245245
})
246246
})
247247

src/__tests__/reader.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @module docast-parse/tests/reader/unit
44
*/
55

6+
import { set } from '@flex-development/tutils'
67
import fs from 'node:fs'
78
import TestSubject from '../reader'
89

@@ -25,7 +26,7 @@ describe('unit:reader', () => {
2526
it('should return true if position is equal to document length', () => {
2627
// Arrange
2728
const subject = new TestSubject(document)
28-
Object.assign(subject, { position: document.length })
29+
set(subject, 'position', document.length)
2930

3031
// Act + Expect
3132
expect(subject.eof).to.be.true
@@ -34,7 +35,7 @@ describe('unit:reader', () => {
3435
it('should return true if position is greater than document length', () => {
3536
// Arrange
3637
const subject = new TestSubject(document)
37-
Object.assign(subject, { position: document.length + 1 })
38+
set(subject, 'position', document.length + 1)
3839

3940
// Act + Expect
4041
expect(subject.eof).to.be.true

0 commit comments

Comments
 (0)