Skip to content

Commit

Permalink
fix: fix misc small issues
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Oct 15, 2023
1 parent b69ed2e commit 43dba6f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docs/src/content/docs/apis/press-down.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: press
title: pressDown
---

Press a button programmatically.
Expand Down Expand Up @@ -54,3 +54,4 @@ await nostalgist.pressDown({ button: 'a', player: 2 }) // press the button "a" o
/* ...other options */
})
```
Because we are using these key bindings to simulate the control.
3 changes: 2 additions & 1 deletion docs/src/content/docs/apis/press-up.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: press up
title: pressUp
---

Release a button programmatically.
Expand Down Expand Up @@ -54,3 +54,4 @@ await nostalgist.pressUp({ button: 'a', player: 2 }) // press the button "a" on
/* ...other options */
})
```
Because we are using these key bindings to simulate the control.
15 changes: 9 additions & 6 deletions src/nostalgist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,24 +321,27 @@ export class Nostalgist {
}

pressDown(options: string | { button: string; player?: number }) {
const emulator = this.getEmulator()
if (typeof options === 'string') {
return this.getEmulator().pressDown(options, 1)
return emulator.pressDown(options)
}
return this.getEmulator().pressDown(options.button, options.player)
return emulator.pressDown(options.button, options.player)
}

pressUp(options: string | { button: string; player?: number }) {
const emulator = this.getEmulator()
if (typeof options === 'string') {
return this.getEmulator().pressUp(options, 1)
return emulator.pressUp(options)
}
return this.getEmulator().pressUp(options.button, options.player)
return emulator.pressUp(options.button, options.player)
}

press(options: string | { button: string; player?: number; time?: number }) {
const emulator = this.getEmulator()
if (typeof options === 'string') {
return this.getEmulator().press(options, 1, 100)
return emulator.press(options)
}
return this.getEmulator().press(options.button, options.player, options.time)
return emulator.press(options.button, options.player, options.time)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/instance.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ test.describe('instance methods', () => {
await expect(canvas).not.toHaveScreenshot('pause-and-resume.png')
})

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

Expand Down

0 comments on commit 43dba6f

Please sign in to comment.