mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-19 18:27:29 -05:00
Restore output attribute of py-script tags, add py-script exec lifecycle hooks (#1063)
* Add beforePyScriptExec, afterPyScriptExec lifecycle hooks * Add stdiodirector plugin for `output`, `stderr` attributes of py-script tag * Add docs on `output` and `stderr` attributes of py-script tag * Tests * Removed output deprecation warning for `output` attribute * Add createSingularWarning(), with createDeprecationWarning as alias
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { beforeEach, expect, describe, it } from "@jest/globals"
|
||||
import { ensureUniqueId, joinPaths} from "../../src/utils"
|
||||
import { ensureUniqueId, joinPaths, createSingularWarning} from "../../src/utils"
|
||||
|
||||
describe("Utils", () => {
|
||||
|
||||
@@ -51,4 +51,23 @@ describe("JoinPaths", () => {
|
||||
const joinedPath = joinPaths(paths);
|
||||
expect(joinedPath).toStrictEqual('hhh/ll/pp/kkk');
|
||||
})
|
||||
|
||||
describe("createSingularBanner", () => {
|
||||
it("should create one and new banner containing the sentinel text, and not duplicate it", () => {
|
||||
//One warning banner with the desired text should be created
|
||||
createSingularWarning("A unique error message", "unique")
|
||||
expect(document.getElementsByClassName("alert-banner")?.length).toEqual(1)
|
||||
expect(document.getElementsByClassName("alert-banner")[0].textContent).toEqual(expect.stringContaining("A unique error message"))
|
||||
|
||||
//Should still only be one banner, since the second uses the existing sentinel value "unique"
|
||||
createSingularWarning("This banner should not appear", "unique")
|
||||
expect(document.getElementsByClassName("alert-banner")?.length).toEqual(1)
|
||||
expect(document.getElementsByClassName("alert-banner")[0].textContent).toEqual(expect.stringContaining("A unique error message"))
|
||||
|
||||
//If the sentinel value is not provided, the entire msg is used as the sentinel
|
||||
createSingularWarning("A unique error message", null)
|
||||
expect(document.getElementsByClassName("alert-banner")?.length).toEqual(1)
|
||||
expect(document.getElementsByClassName("alert-banner")[0].textContent).toEqual(expect.stringContaining("A unique error message"))
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user