<commit_before>/* eslint-env mocha, browser */
/* global planktos */

const assert = require('assert')
const parseTorrent = require('parse-torrent-file')

localStorage.debug = 'planktos*'

describe('sanity check', function () {
  this.timeout(20000)

  const base = '/base/test/www/'
  let iframe = null

  before(function () {
    return loadIframe(base)
    .then(elem => {
      // register the service worker in the iframe and wait for it to activate
      iframe = elem
      iframe.contentWindow.navigator.serviceWorker.register(base + 'planktos.sw.min.js')
      return iframe.contentWindow.navigator.serviceWorker.ready
    })
    .then(() => new Promise(function (resolve) {
      // refresh the iframe and wait for the page to be loaded
      // This ensures the service worker is controlling the page
      iframe.onload = function () {
        resolve()
      }
      iframe.contentWindow.location.reload()
    }))
  })

  it('service worker controls page', function () {
    assert.notEqual(iframe.contentWindow.navigator.serviceWorker.controller, null)
  })

  it('getManifest()', function () {
    return planktos.getManifest()
    .then(manifest => assert('index.html' in manifest))
  })

  it('getTorrentMeta()', function () {
    return planktos.getTorrentMeta()
    .then(torrentMeta => parseTorrent.encode(torrentMeta))<commit_msg>Fix 404 warning message in karma tests<commit_after>/* eslint-env mocha, browser */
/* global planktos */

const assert = require('assert')
const parseTorrent = require('parse-torrent-file')

localStorage.debug = 'planktos*'

describe('sanity check', function () {
  this.timeout(20000)

  const base = '/base/test/www/'
  let iframe = null

  before(function () {
    return loadIframe(base + 'index.html')
    .then(elem => {
      // register the service worker in the iframe and wait for it to activate
      iframe = elem
      iframe.contentWindow.navigator.serviceWorker.register(base + 'planktos.sw.min.js')
      return iframe.contentWindow.navigator.serviceWorker.ready
    })
    .then(() => new Promise(function (resolve) {
      // refresh the iframe and wait for the page to be loaded
      // This ensures the service worker is controlling the page
      iframe.onload = function () {
        resolve()
      }
      iframe.contentWindow.location.reload()
    }))
  })

  it('service worker controls page', function () {
    assert.notEqual(iframe.contentWindow.navigator.serviceWorker.controller, null)
  })

  it('getManifest()', function () {
    return planktos.getManifest()
    .then(manifest => assert('index.html' in manifest))
  })

  it('getTorrentMeta()', function () {
    return planktos.getTorrentMeta()
    .then(torrentMeta => parseTorrent.encode(torrentMeta))
{'fraction_non_alphanumeric': 0.1276440554339898, 'fraction_numerical': 0.004741064916119621, 'mean_word_length': 3.353968253968254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3771850', 'n_tokens_mistral': 844, 'n_tokens_neox': 806, 'n_words': 198}