mirror of
https://github.com/pyscript/pyscript.git
synced 2026-04-05 05:00:30 -04:00
Apply prettier to css, html, js, md, ts, and yml (#1249)
* Apply prettier to css, js, html, md, ts, and yml As a followup I will add prettier to the .pre-commit config. This patch is 100% generated by prettier. I used a forked version of prettier that understands the py-script tag. See https://github.com/hoodmane/pyscript-prettier-precommit for more info. * Apply old pre-commit * Revert some problems * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Revert some changes * More changes * Fix pre-commit * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
import { describe, it, beforeEach, expect } from "@jest/globals"
|
||||
import { UserError, ErrorCode } from "../../src/exceptions"
|
||||
import { PyScriptApp } from "../../src/main"
|
||||
|
||||
describe("Test withUserErrorHandler", () => {
|
||||
import { describe, it, beforeEach, expect } from '@jest/globals';
|
||||
import { UserError, ErrorCode } from '../../src/exceptions';
|
||||
import { PyScriptApp } from '../../src/main';
|
||||
|
||||
describe('Test withUserErrorHandler', () => {
|
||||
class MyApp extends PyScriptApp {
|
||||
myRealMain: any;
|
||||
|
||||
@@ -24,46 +23,46 @@ describe("Test withUserErrorHandler", () => {
|
||||
|
||||
it("userError doesn't stop execution", () => {
|
||||
function myRealMain() {
|
||||
throw new UserError(ErrorCode.GENERIC, "Computer says no");
|
||||
throw new UserError(ErrorCode.GENERIC, 'Computer says no');
|
||||
}
|
||||
|
||||
const app = new MyApp(myRealMain);
|
||||
app.main();
|
||||
const banners = document.getElementsByClassName("alert-banner");
|
||||
const banners = document.getElementsByClassName('alert-banner');
|
||||
expect(banners.length).toBe(1);
|
||||
expect(banners[0].innerHTML).toBe("(PY0000): Computer says no");
|
||||
expect(banners[0].innerHTML).toBe('(PY0000): Computer says no');
|
||||
});
|
||||
|
||||
it("userError escapes by default", () => {
|
||||
it('userError escapes by default', () => {
|
||||
function myRealMain() {
|
||||
throw new UserError(ErrorCode.GENERIC, "hello <br>");
|
||||
throw new UserError(ErrorCode.GENERIC, 'hello <br>');
|
||||
}
|
||||
|
||||
const app = new MyApp(myRealMain);
|
||||
app.main();
|
||||
const banners = document.getElementsByClassName("alert-banner");
|
||||
const banners = document.getElementsByClassName('alert-banner');
|
||||
expect(banners.length).toBe(1);
|
||||
expect(banners[0].innerHTML).toBe("(PY0000): hello <br>");
|
||||
expect(banners[0].innerHTML).toBe('(PY0000): hello <br>');
|
||||
});
|
||||
|
||||
it("userError messageType=html don't escape", () => {
|
||||
function myRealMain() {
|
||||
throw new UserError(ErrorCode.GENERIC, "hello <br>", "html");
|
||||
throw new UserError(ErrorCode.GENERIC, 'hello <br>', 'html');
|
||||
}
|
||||
|
||||
const app = new MyApp(myRealMain);
|
||||
app.main();
|
||||
const banners = document.getElementsByClassName("alert-banner");
|
||||
const banners = document.getElementsByClassName('alert-banner');
|
||||
expect(banners.length).toBe(1);
|
||||
expect(banners[0].innerHTML).toBe("(PY0000): hello <br>");
|
||||
expect(banners[0].innerHTML).toBe('(PY0000): hello <br>');
|
||||
});
|
||||
|
||||
it("any other exception should stop execution and raise", () => {
|
||||
it('any other exception should stop execution and raise', () => {
|
||||
function myRealMain() {
|
||||
throw new Error("Explosions!");
|
||||
throw new Error('Explosions!');
|
||||
}
|
||||
|
||||
const app = new MyApp(myRealMain);
|
||||
expect(() => app.main()).toThrow(new Error("Explosions!"))
|
||||
expect(() => app.main()).toThrow(new Error('Explosions!'));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user