Skip to content

Commit

Permalink
fix: fix the exit method not working
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Jan 23, 2025
1 parent f287b0c commit 8d12600
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
4 changes: 4 additions & 0 deletions playground/activate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ const handlers = {
exit() {
nostalgist.exit()
},

exitWithoutRemovingCanvas() {
nostalgist.exit({ removeCanvas: false })
},
}

export function activate(mod: typeof Nostalgist_) {
Expand Down
1 change: 1 addition & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ <h3>Instance Methods</h3>
<button type="button">pressStart</button>
<button type="button">screenshot</button>
<button type="button">exit</button>
<button type="button">exitWithoutRemovingCanvas</button>
</div>

<script type="module">
Expand Down
4 changes: 0 additions & 4 deletions src/classes/emulator-file-system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ export class EmulatorFileSystem {
return emulatorFileSystem
}

dispose() {
this.FS.unmount('/home')
}

mkdirTree(directory: string) {
const { FS } = this
FS.mkdirTree(directory)
Expand Down
2 changes: 0 additions & 2 deletions src/classes/emulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@ export class Emulator {
exit(statusCode)
JSEvents.removeAllEventListeners()
} catch {}

this.fs.dispose()
}

getEmscripten() {
Expand Down
26 changes: 26 additions & 0 deletions tests/e2e/instance-ra-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,30 @@ export function tests() {
await page.getByText('screenshot', { exact: true }).click()
await expect(screenshot).toHaveScreenshot('screenshot.png')
})

test('exit', async ({ page }) => {
const canvas = page.locator('#canvas')
await expect(canvas).not.toBeAttached()

await page.getByText('nes', { exact: true }).click()
await page.waitForLoadState('networkidle')
await page.waitForTimeout(500)
await expect(canvas).toBeAttached()

await page.getByText('exit', { exact: true }).click()
await expect(canvas).not.toBeAttached()
})

test('exit without removing the canvas', async ({ page }) => {
const canvas = page.locator('#canvas')
await expect(canvas).not.toBeAttached()

await page.getByText('nes', { exact: true }).click()
await page.waitForLoadState('networkidle')
await page.waitForTimeout(500)
await expect(canvas).toBeAttached()

await page.getByText('exitWithoutRemovingCanvas', { exact: true }).click()
await expect(canvas).toBeAttached()
})
}

0 comments on commit 8d12600

Please sign in to comment.