jsdom#JSDOM JavaScript Examples

The following examples show how to use jsdom#JSDOM. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: webp2mp4.js    From HinataMd with GNU General Public License v3.0 7 votes vote down vote up
/**
 * 
 * @param {Buffer|String} source 
 */
async function webp2mp4(source) {
  let form = new FormData()
  let isUrl = typeof source === 'string' && /https?:\/\//.test(source)
  const blob = !isUrl && new Blob([source.toArrayBuffer()])
  form.append('new-image-url', isUrl ? blob : '')
  form.append('new-image', isUrl ? '' : blob, 'image.webp')
  let res = await fetch('https://s6.ezgif.com/webp-to-mp4', {
    method: 'POST',
    body: form
  })
  let html = await res.text()
  let { document } = new JSDOM(html).window
  let form2 = new FormData()
  let obj = {}
  for (let input of document.querySelectorAll('form input[name]')) {
    obj[input.name] = input.value
    form2.append(input.name, input.value)
  }
  let res2 = await fetch('https://ezgif.com/webp-to-mp4/' + obj.file, {
    method: 'POST',
    body: form2
  })
  let html2 = await res2.text()
  let { document: document2 } = new JSDOM(html2).window
  return new URL(document2.querySelector('div#output > p.outfile > video > source').src, res2.url).toString()
}
Example #2
Source File: webp2mp4.js    From HinataMd with GNU General Public License v3.0 6 votes vote down vote up
async function webp2png(source) {
  let form = new FormData()
  let isUrl = typeof source === 'string' && /https?:\/\//.test(source)
  const blob = !isUrl && new Blob([source.toArrayBuffer()])
  form.append('new-image-url', isUrl ? blob : '')
  form.append('new-image', isUrl ? '' : blob, 'image.webp')
  let res = await fetch('https://s6.ezgif.com/webp-to-png', {
    method: 'POST',
    body: form
  })
  let html = await res.text()
  let { document } = new JSDOM(html).window
  let form2 = new FormData()
  let obj = {}
  for (let input of document.querySelectorAll('form input[name]')) {
    obj[input.name] = input.value
    form2.append(input.name, input.value)
  }
  let res2 = await fetch('https://ezgif.com/webp-to-png/' + obj.file, {
    method: 'POST',
    body: form2
  })
  let html2 = await res2.text()
  let { document: document2 } = new JSDOM(html2).window
  return new URL(document2.querySelector('div#output > p.outfile > img').src, res2.url).toString()
}
Example #3
Source File: font.js    From HinataMd with GNU General Public License v3.0 6 votes vote down vote up
async function stylizeText(text) {
    let res = await fetch('http://qaz.wtf/u/convert.cgi?text=' + encodeURIComponent(text))
    let html = await res.text()
    let dom = new JSDOM(html)
    let table = dom.window.document.querySelector('table').children[0].children
    let obj = {}
    for (let tr of table) {
      let name = tr.querySelector('.aname').innerHTML
      let content = tr.children[1].textContent.replace(/^\n/, '').replace(/\n$/, '')
      obj[name + (obj[name] ? ' Reversed' : '')] = content
    }
    return obj
}
Example #4
Source File: ini_styletext.js    From HinataMd with GNU General Public License v3.0 6 votes vote down vote up
async function stylizeText(text) {
let res = await fetch('http://qaz.wtf/u/convert.cgi?text=' + encodeURIComponent(text))
let html = await res.text()
let dom = new JSDOM(html)
let table = dom.window.document.querySelector('table').children[0].children
let obj = {}
for (let tr of table) {
let name = tr.querySelector('.aname').innerHTML
let content = tr.children[1].textContent.replace(/^\n/, '').replace(/\n$/, '')
obj[name + (obj[name] ? ' Reversed' : '')] = content
}
return obj
}
Example #5
Source File: kristian-alkitab.js    From HinataMd with GNU General Public License v3.0 6 votes vote down vote up
handler = async (m, { text, usedPrefix, command }) => {
    if (!text) throw `uhm.. teksnya mana?\n\ncontoh:\n${usedPrefix + command} kejadian`
    let res = await fetch(`https://alkitab.me/search?q=${encodeURIComponent(text)}`, {
        headers: {
            "User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
        }
    })
    if (!res.ok) throw await res.text()
    let html = await res.text()
    let { document } = new JSDOM(html).window
    let result = [...document.querySelectorAll('div.vw')].map(el => {
        let a = el.querySelector('a')
        return {
            teks: el.querySelector('p'),
            link: a.href,
            title: a.textContent.trim()
        }
    })

    m.reply(result.map(v => `${v.title}\n${v.teks}`).join('\n────────\n'))
}
Example #6
Source File: tool-styletext.js    From HinataMd with GNU General Public License v3.0 6 votes vote down vote up
async function stylizeText(text) {
    let res = await fetch('http://qaz.wtf/u/convert.cgi?text=' + encodeURIComponent(text))
    let html = await res.text()
    let dom = new JSDOM(html)
    let table = dom.window.document.querySelector('table').children[0].children
    let obj = {}
    for (let tr of table) {
        let name = tr.querySelector('.aname').innerHTML
        let content = tr.children[1].textContent.replace(/^\n/, '').replace(/\n$/, '')
        obj[name + (obj[name] ? ' Reversed' : '')] = content
    }
    return obj
}
Example #7
Source File: test.affichage.js    From mesconseilscovid with MIT License 6 votes vote down vote up
describe('Affichage', function () {
    it('On peut masquer des éléments visibles', function () {
        var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
        var element = dom.window.document.querySelector('div')
        element.innerHTML = '<div class="visible"></div>'

        affichage.hideSelector(element, '.visible')

        assert.strictEqual(element.firstElementChild.className, '')
        assert.isTrue(element.firstElementChild.hasAttribute('hidden'))
    })

    it('On peut afficher des éléments masqués', function () {
        var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
        var element = dom.window.document.querySelector('div')
        element.innerHTML = '<div id="foo" hidden></div>'

        affichage.displayBlocks(element, ['foo'])

        assert.strictEqual(element.firstElementChild.className, 'visible')
        assert.isFalse(element.firstElementChild.hasAttribute('hidden'))
    })
})
Example #8
Source File: watch.test.js    From Flux with GNU Affero General Public License v3.0 6 votes vote down vote up
describe('Watch View', () => {

    global.console = {
        log: jest.fn(),
        error: console.error,
        warn: console.warn,
    };

    const dom = new JSDOM();
    window.document.body.innerHTML = page;

    test('placeholder', () => {
        expect(1).toBe(1);
    });

});
Example #9
Source File: Chart_spec.js    From Lynx with MIT License 5 votes vote down vote up
createDOM = () => jsdom('<!doctype html><html><body><div></div></body></html>')
Example #10
Source File: test-main.js    From cb-operator with Apache License 2.0 5 votes vote down vote up
// Setup jsdom
// Required for loading angularjs
global.document = jsdom('<html><head><script></script></head><body></body></html>');
Example #11
Source File: okit-cli.js    From oci-designer-toolkit with Universal Permissive License v1.0 5 votes vote down vote up
dom = new JSDOM(`<!DOCTYPE html><body><div id="okit-canvas-div"></div></body>`)
Example #12
Source File: env.js    From uvu with MIT License 5 votes vote down vote up
{ window } = new JSDOM('')
Example #13
Source File: env.js    From uvu with MIT License 5 votes vote down vote up
{ window } = new JSDOM('<main></main>')
Example #14
Source File: lempire-server.js    From lemverse with GNU Affero General Public License v3.0 5 votes vote down vote up
{ window } = new JSDOM('')
Example #15
Source File: setupTests.js    From kube-design with MIT License 5 votes vote down vote up
doc = new JSDOM("<!doctype html><html><body></body></html>")
Example #16
Source File: pdf-parts-gen.js    From rapipdf-cli with MIT License 5 votes vote down vote up
function markdownToPdfmake(markdown) {
  const html = marked(markdown);
  const jsdom = new JSDOM("");
  return htmlToPdfmake(html, { window: jsdom.window });
}
Example #17
Source File: render.js    From Learning-Redux with MIT License 5 votes vote down vote up
serverSideRendering = (indexFile, loadStaticFile) => (req, res) => {
  const isIndexPage = req.url === "/" || req.url === "/index.html";
  if (isIndexPage) {
    if (cachedResult) return res.send(cachedResult);
  }

  console.log("server-side rendering started for", req.url);

  const history = createHistory();

  const store = configureStore({}, history, true);
  return initStore(store)
    .then(() => {
      const context = {};
      const markup = renderToString(
        <Provider store={store}>
          <StaticRouter
            location={isIndexPage ? "/" : req.url}
            context={context}
          >
            <App />
          </StaticRouter>
        </Provider>
      );

      const storeState = JSON.stringify(store.getState()).replace(
        /</g,
        "\\u003c"
      );

      const dom = new JSDOM(indexFile, { runScripts: "outside-only" });
      dom.window.eval(`
        document.getElementById('root').innerHTML = '${markup}'
      `);
      dom.window.eval(`
        var script = document.createElement('script')
        script.innerHTML = 'window.__PRELOADED_STATE__ = ${storeState}'
        document.body.insertBefore(script,
          document.getElementsByTagName('script')[0]
        )
      `);

      if (isIndexPage) {
        cachedResult = dom.serialize();
        console.log("server-side rendering done, cached result");
        if (res) return res.send(cachedResult);
      } else {
        console.log("server-side rendering done");
        if (res) return res.send(dom.serialize());
      }
    })
    .catch((err) => {
      console.error("server-side rendering error:", err);
      if (loadStaticFile) return loadStaticFile(req, res);
    });
}
Example #18
Source File: setupTests.js    From mattress-store with MIT License 5 votes vote down vote up
{ document } = new JSDOM('').window
Example #19
Source File: y2mate.js    From HinataMd with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Download YouTube Video via y2mate
 * @param {String} url YouTube Video URL
 * @param {String} quality (avaiable: `144p`, `240p`, `360p`, `480p`, `720p`, `1080p`, `1440p`, `2160p`)
 * @param {String} type (avaiable: `mp3`, `mp4`)
 * @param {String} bitrate (avaiable for video: `144`, `240`, `360`, `480`, `720`, `1080`, `1440`, `2160`)
 * (avaiable for audio: `128`)
 * @param {String} server (avaiable: `id4`, `en60`, `en61`, `en68`)
 */
async function yt(url, quality, type, bitrate, server = 'en68') {
    if (!ytIdRegex.test(url)) throw 'Invalid URL'
    let ytId = ytIdRegex.exec(url)
    url = 'https://youtu.be/' + ytId[1]
    let res = await post(`https://www.y2mate.com/mates/${server}/analyze/ajax`, {
        url,
        q_auto: 0,
        ajax: 1
    })
    let json = await res.json()
    let { document } = (new JSDOM(json.result)).window
    let tables = document.querySelectorAll('table')
    let table = tables[{ mp4: 0, mp3: 1 }[type] || 0]
    let list
    switch (type) {
        case 'mp4':
            list = Object.fromEntries([...table.querySelectorAll('td > a[href="#"]')].filter(v => !/\.3gp/.test(v.innerHTML)).map(v => [v.innerHTML.match(/.*?(?=\()/)[0].trim(), v.parentElement.nextSibling.nextSibling.innerHTML]))
            break
        case 'mp3':
            list = {
                '128kbps': table.querySelector('td > a[href="#"]').parentElement.nextSibling.nextSibling.innerHTML
            }
            break
        default:
            list = {}
    }
    let filesize = list[quality]
    let id = /var k__id = "(.*?)"/.exec(document.body.innerHTML) || ['', '']
    let thumb = document.querySelector('img').src
    let title = document.querySelector('b').innerHTML
    let res2 = await post(`https://www.y2mate.com/mates/${server}/convert`, {
        type: 'youtube',
        _id: id[1],
        v_id: ytId[1],
        ajax: '1',
        token: '',
        ftype: type,
        fquality: bitrate
    })
    let json2 = await res2.json()
    let KB = parseFloat(filesize) * (1000 * /MB$/.test(filesize))
    return {
        dl_link: /<a.+?href="(.+?)"/.exec(json2.result)[1],
        thumb,
        title,
        filesizeF: filesize,
        filesize: KB
    }
}
Example #20
Source File: welcome.js    From HinataMd with GNU General Public License v3.0 5 votes vote down vote up
{ document: svg } = new JSDOM(_svg).window
Example #21
Source File: TitleBlockEdit.test.jsx    From volto-slate with MIT License 4 votes vote down vote up
describe('renders edit blocks', () => {
  beforeEach(() => {
    const jsdom = new JSDOM();
    global.window = jsdom.window;
    global.document = jsdom.window.document;
    global.Document = document.constructor;
  });

  test('renders an edit title block component', () => {
    const store = mockStore({
      intl: {
        locale: 'en',
        messages: {},
      },
    });
    const component = renderer.create(
      <Provider store={store}>
        <Edit
          properties={{ title: 'My Title' }}
          selected={false}
          block="1234"
          onAddBlock={() => {}}
          onChangeField={() => {}}
          onSelectBlock={() => {}}
          onDeleteBlock={() => {}}
          onFocusPreviousBlock={() => {}}
          onFocusNextBlock={() => {}}
          handleKeyDown={() => {}}
          index={1}
          blockNode={{ current: null }}
          className="documentFirstHeading"
          formFieldName="title"
          data={{ disableNewBlocks: false }}
        />
      </Provider>,
      {
        createNodeMock: () => ({
          ownerDocument: global.document,
          getRootNode: () => global.document,
        }),
      },
    );
    const json = component.toJSON();
    expect(json).toMatchSnapshot();
  });

  test('renders an edit description block component', () => {
    const store = mockStore({
      intl: {
        locale: 'en',
        messages: {},
      },
    });
    const component = renderer.create(
      <Provider store={store}>
        <Edit
          properties={{ description: 'My Description' }}
          selected={false}
          block="1234"
          onAddBlock={() => {}}
          onChangeField={() => {}}
          onSelectBlock={() => {}}
          onDeleteBlock={() => {}}
          onFocusPreviousBlock={() => {}}
          onFocusNextBlock={() => {}}
          handleKeyDown={() => {}}
          index={1}
          blockNode={{ current: null }}
          className="documentDescription"
          formFieldName="description"
          data={{ disableNewBlocks: false }}
        />
      </Provider>,
      {
        createNodeMock: () => ({
          ownerDocument: global.document,
          getRootNode: () => global.document,
        }),
      },
    );
    const json = component.toJSON();
    expect(json).toMatchSnapshot();
  });
});
Example #22
Source File: test.injection.js    From mesconseilscovid with MIT License 4 votes vote down vote up
describe('Injection', function () {
    describe('Caractéristiques à risques', function () {
        it('âge', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-caracteristiques-a-risques"></b>'

            var profil = new Profil('mes_infos', {
                age: 65,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.caracteristiquesARisques(
                element.querySelector('.nom-caracteristiques-a-risques'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-caracteristiques-a-risques">vous êtes âgé·e de plus de 65&nbsp;ans.</b>'
            )
        })

        it('grossesse', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-caracteristiques-a-risques"></b>'

            var profil = new Profil('mes_infos', {
                grossesse_3e_trimestre: true,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.caracteristiquesARisques(
                element.querySelector('.nom-caracteristiques-a-risques'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-caracteristiques-a-risques">vous êtes au 3e trimestre de votre grossesse.</b>'
            )
        })

        it('âge + grossesse = âge', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-caracteristiques-a-risques"></b>'

            var profil = new Profil('mes_infos', {
                age: 65,
                grossesse_3e_trimestre: true,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.caracteristiquesARisques(
                element.querySelector('.nom-caracteristiques-a-risques'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-caracteristiques-a-risques">vous êtes âgé·e de plus de 65&nbsp;ans.</b>'
            )
        })

        it('IMC', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-caracteristiques-a-risques"></b>'
            var profil = new Profil('mes_infos', {
                taille: 150,
                poids: 150,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.caracteristiquesARisques(
                element.querySelector('.nom-caracteristiques-a-risques'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-caracteristiques-a-risques">vous avez un IMC supérieur&nbsp;à&nbsp;30&nbsp;(67).</b>'
            )
        })

        it('âge + IMC', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-caracteristiques-a-risques"></b>'
            var profil = new Profil('mes_infos', {
                age: 65,
                taille: 150,
                poids: 150,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.caracteristiquesARisques(
                element.querySelector('.nom-caracteristiques-a-risques'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-caracteristiques-a-risques">vous êtes âgé·e de plus de 65&nbsp;ans et vous avez un IMC supérieur&nbsp;à&nbsp;30&nbsp;(67).</b>'
            )
        })

        it('grossesse + IMC', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-caracteristiques-a-risques"></b>'
            var profil = new Profil('mes_infos', {
                grossesse_3e_trimestre: true,
                taille: 150,
                poids: 150,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.caracteristiquesARisques(
                element.querySelector('.nom-caracteristiques-a-risques'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-caracteristiques-a-risques">vous êtes au 3e trimestre de votre grossesse et vous avez un IMC supérieur&nbsp;à&nbsp;30&nbsp;(67).</b>'
            )
        })
    })

    describe('Antécédents', function () {
        it('cardio', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-antecedents"></b>'
            var profil = new Profil('mes_infos', {
                antecedent_cardio: true,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.antecedents(
                element.querySelector('.nom-antecedents'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-antecedents">Vous avez des antécédents à risque.</b>'
            )
        })

        it('autres', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-antecedents"></b>'
            var profil = new Profil('mes_infos', {
                antecedent_chronique_autre: true,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.antecedents(
                element.querySelector('.nom-antecedents'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-antecedents">Vous avez une maladie chronique, un handicap ou vous prenez un traitement au long cours.</b>'
            )
        })

        it('cardio + autres', function () {
            var dom = new JSDOM(`<!DOCTYPE html><div></div>`)
            var element = dom.window.document.querySelector('div')
            element.innerHTML = '<b class="nom-antecedents"></b>'
            var profil = new Profil('mes_infos', {
                antecedent_cardio: true,
                antecedent_chronique_autre: true,
            })

            var algoOrientation = new AlgorithmeOrientation(profil)
            injection.antecedents(
                element.querySelector('.nom-antecedents'),
                algoOrientation
            )

            assert.strictEqual(
                element.innerHTML,
                '<b class="nom-antecedents">Vous avez des antécédents à risque et vous avez une maladie chronique, un handicap ou vous prenez un traitement au long cours.</b>'
            )
        })
    })

    it('Suivi répétition', function () {
        const dom = new JSDOM(`<!DOCTYPE html><div></div>`)
        const element = dom.window.document.querySelector('div')
        element.innerHTML = '<span class="suivi-repetition"></span>'
        const profil = new Profil('mes_infos')
        profil.suivi = [{ date: 1 }, { date: 2 }, { date: 3 }]
        injection.suiviRepetition(element.querySelector('.suivi-repetition'), profil)

        assert.strictEqual(element.innerHTML, '<span class="suivi-repetition">3</span>')
    })

    it('Suivi dernière fois', function () {
        const dom = new JSDOM(`<!DOCTYPE html><div></div>`)
        const element = dom.window.document.querySelector('div')
        element.innerHTML = '<span class="suivi-derniere-fois"></span>'
        const profil = new Profil('mes_infos')
        profil.suivi = [{}, {}, { date: new Date() }]
        injection.suiviDerniereFois(
            element.querySelector('.suivi-derniere-fois'),
            profil
        )

        assert.strictEqual(
            element.innerHTML,
            '<span class="suivi-derniere-fois">just now</span>'
        )
    })
})
Example #23
Source File: test.conseils.js    From mesconseilscovid with MIT License 4 votes vote down vote up
describe('Conseils personnels', function () {
    it('Je n’ai pas d’activité pro', function () {
        let dom = new JSDOM(`<!DOCTYPE html>
            <section id="conseils">
                <div id="conseils-personnels" class="conseils">
                    <ol>
                        <li id="isolement">Rester isolé</li>
                        <li id="arret-de-travail" class="seulement-si-activite-pro">Obtenir un arrêt de travail</li>
                    </ol>
                </div>
            </section>
        `)
        let element = dom.window.document.querySelector('#conseils')
        let profil = new Profil('mes_infos', {
            activite_pro: false,
        })
        cacherElementsConditionnels(element, profil)
        assert.isTrue(element.querySelector('#arret-de-travail').hidden)
    })

    it('J’ai une activité pro', function () {
        let dom = new JSDOM(`<!DOCTYPE html>
            <section id="conseils">
                <div id="conseils-personnels" class="conseils">
                    <ol>
                        <li id="isolement">Rester isolé</li>
                        <li id="arret-de-travail" class="seulement-si-activite-pro">Obtenir un arrêt de travail</li>
                    </ol>
                </div>
            </section>
        `)
        let element = dom.window.document.querySelector('#conseils')
        let profil = new Profil('mes_infos', {
            activite_pro: true,
        })
        cacherElementsConditionnels(element, profil)
        assert.isFalse(element.querySelector('#arret-de-travail').hidden)
    })

    it('Je vis seul', function () {
        let dom = new JSDOM(`<!DOCTYPE html>
            <section id="conseils">
                <div id="conseils-personnels" class="conseils">
                    <ol>
                        <li id="isolement">Rester isolé</li>
                        <li id="foyer" class="seulement-si-foyer">Manger tout seul</li>
                    </ol>
                </div>
            </section>
        `)
        let element = dom.window.document.querySelector('#conseils')
        let profil = new Profil('mes_infos', {
            foyer_autres_personnes: false,
        })
        cacherElementsConditionnels(element, profil)
        assert.isTrue(element.querySelector('#foyer').hidden)
    })

    it('Je partage mon foyer avec d’autres personnes', function () {
        let dom = new JSDOM(`<!DOCTYPE html>
            <section id="conseils">
                <div id="conseils-personnels" class="conseils">
                    <ol>
                        <li id="isolement">Rester isolé</li>
                        <li id="foyer" class="seulement-si-foyer">Manger tout seul</li>
                    </ol>
                </div>
            </section>
        `)
        let element = dom.window.document.querySelector('#conseils')
        let profil = new Profil('mes_infos', {
            foyer_autres_personnes: true,
        })
        cacherElementsConditionnels(element, profil)
        assert.isFalse(element.querySelector('#foyer').hidden)
    })

    it('Je suis éligible au Paxlovid', function () {
        let dom = new JSDOM(`<!DOCTYPE html>
            <section id="conseils">
                <div id="conseils-personnels" class="conseils">
                    <ol>
                        <li id="paxlovid" class="seulement-si-paxlovid">Prescription Paxlovid</li>
                    </ol>
                </div>
            </section>
        `)
        let element = dom.window.document.querySelector('#conseils')
        let profil = new Profil('mes_infos', {
            age: 65,
            antecedent_diabete: true,
        })
        profil.symptomes_start_date = joursAvant(4)
        cacherElementsConditionnels(element, profil)
        assert.isFalse(element.querySelector('#paxlovid').hidden)
    })
    it('Je ne suis pas éligible au Paxlovid', function () {
        let dom = new JSDOM(`<!DOCTYPE html>
            <section id="conseils">
                <div id="conseils-personnels" class="conseils">
                    <ol>
                        <li id="paxlovid" class="seulement-si-paxlovid">Prescription Paxlovid</li>
                    </ol>
                </div>
            </section>
        `)
        let element = dom.window.document.querySelector('#conseils')
        let profil = new Profil('mes_infos', {
            age: 65,
            antecedent_diabete: false,
        })
        profil.symptomes_start_date = joursAvant(4)
        cacherElementsConditionnels(element, profil)
        assert.isTrue(element.querySelector('#paxlovid').hidden)
    })
})