Skip to content

Commit

Permalink
chore: fix pc load letter error
Browse files Browse the repository at this point in the history
  • Loading branch information
favna authored and imranbarbhuiya committed Jul 10, 2022
1 parent bade78b commit 615b7cf
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions tests/browser/browser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,41 @@
* @vitest-environment jsdom
*/

import { readFileSync } from 'node:fs';
import { DOMWindow, JSDOM } from 'jsdom';
import path from 'node:path';

const script = readFileSync(path.join(__dirname, '../../dist/index.global.js'), 'utf8');

declare global {
interface Window {
SapphireShapeshift: typeof import('../../src');
}
namespace JSX {
interface Element {
outerHTML: string;
}
}
}

let window: DOMWindow;
import { type DOMWindow, JSDOM } from 'jsdom';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';

describe('browser-bundle-test', () => {
beforeEach(() => {
window = new JSDOM('', {
runScripts: 'dangerously'
}).window;

const { document } = window;

const scriptTag = document.createElement('script');
scriptTag.textContent = script;
document.head.appendChild(scriptTag);
let window: DOMWindow;

beforeAll(async () => {
window = new JSDOM(
`
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BrowserBundleTest</title>
<script>${await readFile(join(__dirname, '../../dist/index.global.js'), 'utf8')}</script>
</head>
<body></body>
</html>
`,
{
runScripts: 'dangerously'
}
).window;
});

test('GIVEN an unique array THEN return the given value', () => {
expect(window.SapphireShapeshift.s.string.parse('Hello')).toBe('Hello');
});
});

declare global {
interface Window {
SapphireShapeshift: typeof import('../../src');
}
}

0 comments on commit 615b7cf

Please sign in to comment.