diff --git a/.gitignore b/.gitignore index 7a60b85..b4bc537 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ __pycache__/ *.pyc +node_modules/ diff --git a/docs/index.test.js b/docs/index.test.js new file mode 100644 index 0000000..e1051ed --- /dev/null +++ b/docs/index.test.js @@ -0,0 +1,54 @@ +const fs = require('fs'); +const path = require('path'); +const { JSDOM } = require('jsdom'); + +describe('Universal Image Converter', () => { + let dom; + let document; + let window; + + beforeEach(async () => { + const htmlPath = path.resolve(__dirname, 'index.html'); + const htmlContent = fs.readFileSync(htmlPath, 'utf8'); + + // We need runScripts: "dangerously" to use window.eval + dom = new JSDOM(htmlContent, { + runScripts: "dangerously" + }); + document = dom.window.document; + window = dom.window; + }); + + test('should display error message when initWasm fails', async () => { + const htmlPath = path.resolve(__dirname, 'index.html'); + const htmlContent = fs.readFileSync(htmlPath, 'utf8'); + + const scriptContent = htmlContent.match(/