diff --git a/src/core/session.js b/src/core/session.js index 181b6b2a2..e7e57a90f 100644 --- a/src/core/session.js +++ b/src/core/session.js @@ -144,6 +144,22 @@ export class Session { return config.drive.progressBarDelay } + set drive(value) { + config.drive.enabled = value + } + + get drive() { + return config.drive.enabled + } + + set formMode(value) { + config.forms.mode = value + } + + get formMode() { + return config.forms.mode + } + get location() { return this.history.location } diff --git a/src/tests/fixtures/drive_disabled.html b/src/tests/fixtures/drive_disabled.html index da787f0bb..477ca3c65 100644 --- a/src/tests/fixtures/drive_disabled.html +++ b/src/tests/fixtures/drive_disabled.html @@ -15,7 +15,7 @@ }) diff --git a/src/tests/unit/export_tests.js b/src/tests/unit/export_tests.js index d255a3fc0..485963043 100644 --- a/src/tests/unit/export_tests.js +++ b/src/tests/unit/export_tests.js @@ -19,9 +19,28 @@ test("Turbo interface", () => { assert.equal(typeof Turbo.cache.clear, "function") assert.equal(typeof Turbo.navigator, "object") assert.equal(typeof Turbo.session, "object") + assert.equal(typeof Turbo.session.drive, "boolean") + assert.equal(typeof Turbo.session.formMode, "string") assert.equal(typeof Turbo.fetch, "function") }) +test("Session interface", () => { + const { session, config } = Turbo + + assert.equal(true, session.drive) + assert.equal(true, config.drive.enabled) + assert.equal("on", session.formMode) + assert.equal("on", config.forms.mode) + + session.drive = false + session.formMode = "off" + + assert.equal(false, session.drive) + assert.equal(false, config.drive.enabled) + assert.equal("off", session.formMode) + assert.equal("off", config.forms.mode) +}) + test("StreamActions interface", () => { assert.equal(typeof StreamActions, "object") })