( config: Config, system: System = new System(), )
| 143 | } |
| 144 | |
| 145 | export function createInstance( |
| 146 | config: Config, |
| 147 | system: System = new System(), |
| 148 | ): { |
| 149 | instance: Instance |
| 150 | api: UserEvent |
| 151 | } { |
| 152 | const instance = {} as Instance |
| 153 | Object.assign(instance, { |
| 154 | config, |
| 155 | dispatchEvent: dispatchEvent.bind(instance), |
| 156 | dispatchUIEvent: dispatchUIEvent.bind(instance), |
| 157 | system, |
| 158 | levelRefs: {}, |
| 159 | ...userEventApi, |
| 160 | }) |
| 161 | |
| 162 | return { |
| 163 | instance, |
| 164 | api: { |
| 165 | ...(Object.fromEntries( |
| 166 | Object.entries(userEventApi).map(([name, api]) => [ |
| 167 | name, |
| 168 | wrapAndBindImpl(instance, api), |
| 169 | ]), |
| 170 | ) as UserEventApi), |
| 171 | setup: setupSub.bind(instance), |
| 172 | }, |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | function getDocument( |
| 177 | options: Partial<Config>, |
no test coverage detected