11import { describe , expect , it } from 'vitest'
2- import { CONTEXT } from './config'
2+ import { config , CONTEXT } from './config'
33import { Context } from './context'
4- import { defaultOptions } from './engine'
54
65describe ( 'context' , ( ) => {
76 it ( 'should initialize with default context' , ( ) => {
8- const context = new Context ( defaultOptions )
7+ const context = new Context ( config )
98 expect ( context . context ) . toBe ( CONTEXT )
109 } )
1110
1211 describe ( 'affix' , ( ) => {
1312 it ( 'should affix string to context' , ( ) => {
14- const context = new Context ( defaultOptions )
13+ const context = new Context ( config )
1514 const result = context . affix ( 'test' )
1615 expect ( result ) . toBe ( 'c_test' )
1716 expect ( context . context ) . toBe ( 'c_test' )
1817 } )
1918
2019 it ( 'should affix number to context' , ( ) => {
21- const context = new Context ( defaultOptions )
20+ const context = new Context ( config )
2221 const result = context . affix ( 123 )
2322 expect ( result ) . toBe ( 'c_123' )
2423 expect ( context . context ) . toBe ( 'c_123' )
2524 } )
2625
2726 it ( 'should support multiple affixes' , ( ) => {
28- const context = new Context ( defaultOptions )
27+ const context = new Context ( config )
2928
3029 context . affix ( 'first' )
3130 expect ( context . context ) . toBe ( 'c_first' )
@@ -38,7 +37,7 @@ describe('context', () => {
3837 } )
3938
4039 it ( 'should return the new context value' , ( ) => {
41- const context = new Context ( defaultOptions )
40+ const context = new Context ( config )
4241 const result1 = context . affix ( 'alpha' )
4342 const result2 = context . affix ( 'beta' )
4443
@@ -50,7 +49,7 @@ describe('context', () => {
5049
5150 describe ( 'reset' , ( ) => {
5251 it ( 'should reset to previous context after single affix' , ( ) => {
53- const context = new Context ( defaultOptions )
52+ const context = new Context ( config )
5453
5554 context . affix ( 'temp' )
5655 expect ( context . context ) . toBe ( 'c_temp' )
@@ -60,7 +59,7 @@ describe('context', () => {
6059 } )
6160
6261 it ( 'should reset to previous context after multiple affixes' , ( ) => {
63- const context = new Context ( defaultOptions )
62+ const context = new Context ( config )
6463
6564 context . affix ( 'first' )
6665 context . affix ( 'second' )
@@ -78,7 +77,7 @@ describe('context', () => {
7877 } )
7978
8079 it ( 'should handle reset on base context gracefully' , ( ) => {
81- const context = new Context ( defaultOptions )
80+ const context = new Context ( config )
8281 expect ( context . context ) . toBe ( 'c' )
8382
8483 context . reset ( )
@@ -88,7 +87,7 @@ describe('context', () => {
8887
8988 describe ( 'nested operations' , ( ) => {
9089 it ( 'should handle complex affix and reset patterns' , ( ) => {
91- const context = new Context ( defaultOptions )
90+ const context = new Context ( config )
9291
9392 // Build nested context
9493 context . affix ( '1' )
@@ -111,7 +110,7 @@ describe('context', () => {
111110 } )
112111
113112 it ( 'should maintain context stack integrity' , ( ) => {
114- const context = new Context ( defaultOptions )
113+ const context = new Context ( config )
115114
116115 // Create multiple contexts
117116 const contexts = [ 'a' , 'b' , 'c' , 'd' , 'e' ]
@@ -130,21 +129,21 @@ describe('context', () => {
130129
131130 describe ( 'edge cases' , ( ) => {
132131 it ( 'should handle empty string affix' , ( ) => {
133- const context = new Context ( defaultOptions )
132+ const context = new Context ( config )
134133 const result = context . affix ( '' )
135134 expect ( result ) . toBe ( 'c_' )
136135 expect ( context . context ) . toBe ( 'c_' )
137136 } )
138137
139138 it ( 'should handle zero as affix' , ( ) => {
140- const context = new Context ( defaultOptions )
139+ const context = new Context ( config )
141140 const result = context . affix ( 0 )
142141 expect ( result ) . toBe ( 'c_0' )
143142 expect ( context . context ) . toBe ( 'c_0' )
144143 } )
145144
146145 it ( 'should handle special characters in affix' , ( ) => {
147- const context = new Context ( defaultOptions )
146+ const context = new Context ( config )
148147 const result = context . affix ( 'test-name.property[0]' )
149148 expect ( result ) . toBe ( 'c_test-name.property[0]' )
150149 expect ( context . context ) . toBe ( 'c_test-name.property[0]' )
0 commit comments