11import { beforeEach , describe , expect } from "vitest" ;
22import { Given , When , Then } from "./gherkin.js" ;
33import * as JsonPointer from "./index.js" ;
4- import type { Json , JsonObject , Pointable } from "./index.js" ;
4+
5+ /**
6+ * @import { Json, JsonObject } from "./index.js"
7+ */
58
69
710describe ( "JsonPointer.assign" , ( ) => {
@@ -13,7 +16,7 @@ describe("JsonPointer.assign", () => {
1316 JsonPointer . assign ( pointer , subject , "foo" ) ;
1417
1518 Then ( "the value is not changed" , ( ) => {
16- expect ( subject ) . to . eql ( { " foo" : "bar" } ) ;
19+ expect ( subject ) . to . eql ( { foo : "bar" } ) ;
1720 } ) ;
1821 } ) ;
1922 } ) ;
@@ -22,7 +25,7 @@ describe("JsonPointer.assign", () => {
2225 const pointer = "/aaa" ;
2326
2427 When ( "mutating a property" , ( ) => {
25- const subject = { " aaa" : 111 , " bbb" : [ ] } ;
28+ const subject = { aaa : 111 , bbb : [ ] } ;
2629 JsonPointer . assign ( pointer , subject , "foo" ) ;
2730
2831 Then ( "the new value should be set" , ( ) => {
@@ -48,7 +51,7 @@ describe("JsonPointer.assign", () => {
4851 const pointer = "/aaa/ccc" ;
4952
5053 When ( "mutating a property" , ( ) => {
51- const subject = { " aaa" : { " ccc" : 333 , " ddd" : 444 } , " bbb" : 222 } ;
54+ const subject = { aaa : { ccc : 333 , ddd : 444 } , bbb : 222 } ;
5255 JsonPointer . assign ( pointer , subject , "foo" ) ;
5356
5457 Then ( "the new value should be set" , ( ) => {
@@ -58,7 +61,8 @@ describe("JsonPointer.assign", () => {
5861 } ) ;
5962
6063 Given ( "an object" , ( ) => {
61- let subject : JsonObject ;
64+ /** @type JsonObject */
65+ let subject ;
6266
6367 beforeEach ( ( ) => {
6468 subject = { aaa : { bbb : { } } } ;
@@ -84,7 +88,8 @@ describe("JsonPointer.assign", () => {
8488 } ) ;
8589
8690 Given ( "an array" , ( ) => {
87- let subject : Json [ ] ;
91+ /** @type Json[] */
92+ let subject ;
8893
8994 beforeEach ( ( ) => {
9095 subject = [ ] ;
@@ -112,7 +117,8 @@ describe("JsonPointer.assign", () => {
112117 } ) ;
113118
114119 Given ( "a number" , ( ) => {
115- let subject : unknown ;
120+ /** @type number */
121+ let subject ;
116122
117123 beforeEach ( ( ) => {
118124 subject = 42 ;
@@ -122,13 +128,14 @@ describe("JsonPointer.assign", () => {
122128 const assign = JsonPointer . assign ( "/0" ) ;
123129
124130 Then ( "an error should be thrown" , ( ) => {
125- expect ( ( ) => assign ( subject as Pointable , "foo" ) ) . to . throw ( Error , "Value at '' is a number and does not have property '0'" ) ;
131+ expect ( ( ) => assign ( subject , "foo" ) ) . to . throw ( Error , "Value at '' is a number and does not have property '0'" ) ;
126132 } ) ;
127133 } ) ;
128134 } ) ;
129135
130136 Given ( "a string" , ( ) => {
131- let subject : unknown ;
137+ /** @type string */
138+ let subject ;
132139
133140 beforeEach ( ( ) => {
134141 subject = "foo" ;
@@ -138,13 +145,14 @@ describe("JsonPointer.assign", () => {
138145 const assign = JsonPointer . assign ( "/0" ) ;
139146
140147 Then ( "an error should be thrown" , ( ) => {
141- expect ( ( ) => assign ( subject as Pointable , "foo" ) ) . to . throw ( Error , "Value at '' is a string and does not have property '0'" ) ;
148+ expect ( ( ) => assign ( subject , "foo" ) ) . to . throw ( Error , "Value at '' is a string and does not have property '0'" ) ;
142149 } ) ;
143150 } ) ;
144151 } ) ;
145152
146153 Given ( "null" , ( ) => {
147- let subject : unknown ;
154+ /** @type null */
155+ let subject ;
148156
149157 beforeEach ( ( ) => {
150158 subject = null ;
@@ -154,7 +162,7 @@ describe("JsonPointer.assign", () => {
154162 const assign = JsonPointer . assign ( "/0" ) ;
155163
156164 Then ( "an error should be thrown" , ( ) => {
157- expect ( ( ) => assign ( subject as Pointable , "foo" ) ) . to . throw ( Error , "Value at '' is null and does not have property '0'" ) ;
165+ expect ( ( ) => assign ( subject , "foo" ) ) . to . throw ( Error , "Value at '' is null and does not have property '0'" ) ;
158166 } ) ;
159167 } ) ;
160168 } ) ;
0 commit comments