File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ import Mitm from 'mitm';
22import { InSim } from 'node-insim' ;
33import { IS_BTN , IS_ISI , IS_VER } from 'node-insim/packets' ;
44
5- import type { CreateRootOptions } from '../src' ;
65import { Button , createRoot } from '../src' ;
76
87function stringToBytes ( string : string ) {
@@ -21,18 +20,20 @@ describe('Buttons', () => {
2120 } ) ;
2221
2322 it ( 'should connect to InSim and send a button' , ( done ) => {
24- const createRootOptions : CreateRootOptions = {
25- name : 'Test App' ,
26- host : '127.0.0.1' ,
27- port : 29999 ,
28- adminPassword : 'adminPassword' ,
29- prefix : '!' ,
30- } ;
31-
3223 let root : ReturnType < typeof createRoot > ;
24+ const inSim = new InSim ( ) ;
3325
3426 process . nextTick ( ( ) => {
35- root = createRoot ( createRootOptions ) ;
27+ inSim . connect ( {
28+ ReqI : 255 ,
29+ IName : 'Test App' ,
30+ Host : '127.0.0.1' ,
31+ Port : 29999 ,
32+ Admin : 'adminPassword' ,
33+ Prefix : '!' ,
34+ } ) ;
35+
36+ root = createRoot ( inSim ) ;
3637 root . render (
3738 < Button width = { 20 } height = { 5 } >
3839 Hello world
@@ -90,7 +91,7 @@ describe('Buttons', () => {
9091 if ( combined . length >= btn . Size ) {
9192 expect ( combined ) . toEqual ( Buffer . from ( btn . pack ( ) ) ) ;
9293
93- root . disconnect ( ) ;
94+ inSim . disconnect ( ) ;
9495 done ( ) ;
9596 }
9697 } ) ;
Original file line number Diff line number Diff line change 11import Mitm from 'mitm' ;
2+ import { InSim } from 'node-insim' ;
23
34import { createRoot } from '../src' ;
45
@@ -18,8 +19,7 @@ describe('InSim connection', () => {
1819 } ) ;
1920
2021 it ( 'should connect to InSim and send an IS_ISI packet' , ( done ) => {
21- // eslint-disable-next-line prefer-const
22- let root : ReturnType < typeof createRoot > ;
22+ const inSim = new InSim ( ) ;
2323
2424 mitm . on ( 'connection' , ( socket , opts ) => {
2525 expect ( opts . host ) . toEqual ( '127.0.0.1' ) ;
@@ -45,17 +45,20 @@ describe('InSim connection', () => {
4545 ] ) ,
4646 ) ;
4747
48- root . disconnect ( ) ;
48+ inSim . disconnect ( ) ;
4949 done ( ) ;
5050 } ) ;
5151 } ) ;
5252
53- root = createRoot ( {
54- name : 'Test App' ,
55- host : '127.0.0.1' ,
56- port : 29999 ,
57- adminPassword : 'adminPassword' ,
58- prefix : '!' ,
53+ inSim . connect ( {
54+ ReqI : 255 ,
55+ IName : 'Test App' ,
56+ Host : '127.0.0.1' ,
57+ Port : 29999 ,
58+ Admin : 'adminPassword' ,
59+ Prefix : '!' ,
5960 } ) ;
61+
62+ createRoot ( inSim ) ;
6063 } ) ;
6164} ) ;
You can’t perform that action at this time.
0 commit comments