11import { deepStrictEqual , strictEqual } from 'node:assert' ;
22import { spawnSync } from 'node:child_process' ;
33import { execPath } from 'node:process' ;
4- import { describe , it , mock } from 'node:test' ;
4+ import { describe , it } from 'node:test' ;
55import { fileURLToPath } from 'node:url' ;
66
77import dedent from 'dedent' ;
88
99import { invalidChangeVersion } from '../invalid-change-version.mjs' ;
10+ import { createContext } from './utils.mjs' ;
1011
1112describe ( 'invalidChangeVersion' , ( ) => {
1213 it ( 'should not report if all change versions are non-empty' , ( ) => {
@@ -20,19 +21,12 @@ changes:
2021 - version: v5.0.0
2122-->` ;
2223
23- const context = {
24- tree : {
25- type : 'root' ,
26- children : [
27- {
28- type : 'html' ,
29- value : yamlContent ,
30- } ,
31- ] ,
24+ const context = createContext ( [
25+ {
26+ type : 'html' ,
27+ value : yamlContent ,
3228 } ,
33- report : mock . fn ( ) ,
34- getIssues : mock . fn ( ) ,
35- } ;
29+ ] ) ;
3630
3731 invalidChangeVersion ( context ) ;
3832
@@ -50,23 +44,16 @@ changes:
5044 - version:
5145-->` ;
5246
53- const context = {
54- tree : {
55- type : 'root' ,
56- children : [
57- {
58- type : 'html' ,
59- value : yamlContent ,
60- position : {
61- start : { line : 1 , column : 1 , offset : 1 } ,
62- end : { line : 1 , column : 1 , offset : 1 } ,
63- } ,
64- } ,
65- ] ,
47+ const context = createContext ( [
48+ {
49+ type : 'html' ,
50+ value : yamlContent ,
51+ position : {
52+ start : { line : 1 , column : 1 , offset : 1 } ,
53+ end : { line : 1 , column : 1 , offset : 1 } ,
54+ } ,
6655 } ,
67- report : mock . fn ( ) ,
68- getIssues : mock . fn ( ) ,
69- } ;
56+ ] ) ;
7057
7158 invalidChangeVersion ( context ) ;
7259
@@ -126,19 +113,12 @@ changes:
126113 - version: v5.0.0
127114-->` ;
128115
129- const context = {
130- tree : {
131- type : 'root' ,
132- children : [
133- {
134- type : 'html' ,
135- value : yamlContent ,
136- } ,
137- ] ,
116+ const context = createContext ( [
117+ {
118+ type : 'html' ,
119+ value : yamlContent ,
138120 } ,
139- report : mock . fn ( ) ,
140- getIssues : mock . fn ( ) ,
141- } ;
121+ ] ) ;
142122
143123 invalidChangeVersion ( context ) ;
144124
@@ -156,23 +136,16 @@ changes:
156136 - version: v5.0.0
157137-->` ;
158138
159- const context = {
160- tree : {
161- type : 'root' ,
162- children : [
163- {
164- type : 'html' ,
165- value : yamlContent ,
166- position : {
167- start : { column : 1 , line : 7 , offset : 103 } ,
168- end : { column : 35 , line : 7 , offset : 137 } ,
169- } ,
170- } ,
171- ] ,
139+ const context = createContext ( [
140+ {
141+ type : 'html' ,
142+ value : yamlContent ,
143+ position : {
144+ start : { column : 1 , line : 7 , offset : 103 } ,
145+ end : { column : 35 , line : 7 , offset : 137 } ,
146+ } ,
172147 } ,
173- report : mock . fn ( ) ,
174- getIssues : mock . fn ( ) ,
175- } ;
148+ ] ) ;
176149
177150 invalidChangeVersion ( context ) ;
178151 strictEqual ( context . report . mock . callCount ( ) , 1 ) ;
@@ -200,23 +173,16 @@ changes:
200173 - version: v5.0.0
201174-->` ;
202175
203- const context = {
204- tree : {
205- type : 'root' ,
206- children : [
207- {
208- type : 'html' ,
209- value : yamlContent ,
210- position : {
211- start : { column : 1 , line : 7 , offset : 103 } ,
212- end : { column : 35 , line : 7 , offset : 137 } ,
213- } ,
214- } ,
215- ] ,
176+ const context = createContext ( [
177+ {
178+ type : 'html' ,
179+ value : yamlContent ,
180+ position : {
181+ start : { column : 1 , line : 7 , offset : 103 } ,
182+ end : { column : 35 , line : 7 , offset : 137 } ,
183+ } ,
216184 } ,
217- report : mock . fn ( ) ,
218- getIssues : mock . fn ( ) ,
219- } ;
185+ ] ) ;
220186
221187 invalidChangeVersion ( context ) ;
222188 strictEqual ( context . report . mock . callCount ( ) , 1 ) ;
0 commit comments