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 23, 2023
1 parent 0b5f53b commit f8c15f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/tests/unit/export_tests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
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.StreamActions, "object")
assert.equal(typeof Turbo.start, "function")
assert.equal(typeof Turbo.registerAdapter, "function")
assert.equal(typeof Turbo.visit, "function")
Expand All @@ -16,3 +18,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 f8c15f7

Please sign in to comment.