Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83b4899

Browse files
committed
fix routeString tests
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parentc09fae9 commit83b4899

File tree

3 files changed

+26
-24
lines changed

3 files changed

+26
-24
lines changed

‎web-app/src/services/state/useStateMachine.tsx

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react'
22
import*asTfrom'typings'
33
import{createMachine}from'./machine'
44
import{useMachine}from'../xstate-react'
5+
importcreateRouteStringfrom'./utils/routeString'
56
importloggerfrom'../logger'
67

78
interfaceOutput{
@@ -12,29 +13,6 @@ interface Output {
1213

1314
declareletacquireVsCodeApi:any
1415

15-
exportconstcreateRouteString=(route:object|string):string=>{
16-
if(typeofroute==='string'){
17-
returnroute
18-
}
19-
constpaths:string[]=[]
20-
letcurrent:object|string|undefined=route
21-
while(current){
22-
// current is final string value
23-
if(typeofcurrent==='string'){
24-
paths.push(current)
25-
break
26-
}
27-
28-
// current is object
29-
constnext:string=Object.keys(current)[0]
30-
paths.push(next)
31-
//@ts-ignore
32-
current=current[next]
33-
}
34-
35-
returnpaths.join('.')
36-
}
37-
3816
consteditor=acquireVsCodeApi()
3917
consteditorSend=(action:T.Action)=>{
4018
logger(`TO EXT: "${action.type}"`)

‎web-app/src/services/state/routeString.test.tsrenamed to‎web-app/src/services/state/utils/routeString.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{createRouteString}from'./useStateMachine'
1+
importcreateRouteStringfrom'./routeString'
22

33
describe('route string',()=>{
44
it('should take a single key route',()=>{
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
constcreateRouteString=(route:object|string):string=>{
2+
if(typeofroute==='string'){
3+
returnroute
4+
}
5+
constpaths:string[]=[]
6+
letcurrent:object|string|undefined=route
7+
while(current){
8+
// current is final string value
9+
if(typeofcurrent==='string'){
10+
paths.push(current)
11+
break
12+
}
13+
14+
// current is object
15+
constnext:string=Object.keys(current)[0]
16+
paths.push(next)
17+
//@ts-ignore
18+
current=current[next]
19+
}
20+
21+
returnpaths.join('.')
22+
}
23+
24+
exportdefaultcreateRouteString

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp