Skip to content

Commit

Permalink
Add test coverage for StreamActions export
Browse files Browse the repository at this point in the history
According to the [official documentation][], applications that need to
extend `StreamActions` should be importing it directly from the module
instead of accessing it through `window.Turbo.StreamActions`.

This commit adds test coverage to exercise the corresponding `import`.
It also re-arranges the `export` to explicitly occur in the
`@hotwired/turbo` module itself, instead of being transitively exported
as part of the `@hotwired/turbo/core` module.

[official documentation]: https://turbo.hotwired.dev/handbook/streams#custom-actions
  • Loading branch information
seanpdoyle committed Oct 8, 2023
1 parent c207f5b commit c001f7f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ const cache = new Cache(session)
const { navigator } = session
export { navigator, session, cache, PageRenderer, PageSnapshot, FrameRenderer }

export { StreamActions } from "./streams/stream_actions"

/**
* Starts the main session.
* This initialises any necessary observers such as those to monitor
Expand Down
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ Turbo.start()
export * from "./core"
export * from "./elements"
export * from "./http"
export { StreamActions } from "./core/streams/stream_actions"
7 changes: 6 additions & 1 deletion src/tests/unit/export_tests.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { assert } from "@open-wc/testing"
import * as Turbo from "../../index"
import * as Turbo from "../../"
import { StreamActions } from "../../"

test("test Turbo interface", () => {
assert.equal(typeof Turbo.start, "function")
Expand All @@ -16,3 +17,7 @@ test("test Turbo interface", () => {
assert.equal(typeof Turbo.navigator, "object")
assert.equal(typeof Turbo.session, "object")
})

test("test StreamActions interface", () => {
assert.equal(typeof StreamActions, "object")
})

0 comments on commit c001f7f

Please sign in to comment.