"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const browser_test_1 = require("./browser-test");
const html = `
  <!DOCTYPE html>
  <html lang="ja">
  <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>Hello</title>
    <style>
      h2 {
        color: red;
      }
    </style>
  </head>
  <body>
    <h1>Title1</h1>
    <h2>Title2</h2>
  </body>
  <script>
    function main() {
      console.log('hello')
    }
  </script>
  </html>
`;
const main = async () => {
    const browserTest = new browser_test_1.BrowserTester({ html, width: 980, height: 980 });
    browserTest.test('h1,h2 textContent should have right textContent', async (_, doc) => {
        const h1 = doc.querySelector('h1');
        const h2 = doc.querySelector('h2');
        browserTest.expect(h1?.textContent).toBe('Title1');
        browserTest.expect(h2?.textContent).toBe('Title2');
    });
    browserTest.test('title should have right textContent', async (_, doc) => {
        const title = doc.querySelector('title');
        browserTest.expect(title?.textContent).toBe('Hello');
    });
    browserTest.test('h2 should have red text', async (window, doc) => {
        const h2 = doc.querySelector('h2');
        browserTest.expect(window.getComputedStyle(h2).color).toBe('rgb(255, 0, 0)');
    });
    browserTest.test('console.log to have been called with `hello`', async (window) => {
        const spy = browserTest.spyOn(window.console, 'log');
        // @ts-ignore
        window.main();
        browserTest.expect(spy).toHaveBeenCalled();
        browserTest.expect(spy).toHaveBeenCalledWith('hello');
    });
    await browserTest.evaluate(`
    test('h1,h2 textContent should have right textContent2', async (_, doc) => {
      const h1 = doc.querySelector('h1')
      const h2 = doc.querySelector('h2')
      expect(h1?.textContent).toBe('Title1')
      expect(h2?.textContent).toBe('Title2')
    })
  `);
    const results = await browserTest.run();
    console.log(results);
};
main();
