<commit_before>import { module, test } from 'qunit'
import { setupPBUnitTest, setupLoggedUser } from '../../helpers/utils'
import { fakeUser } from '../../helpers/mocks'

module('Unit | Service | storage', function(hooks) {
  let service
  setupPBUnitTest(hooks)
  setupLoggedUser(hooks)

  hooks.beforeEach(function() {
    service = this.owner.lookup('service:storage')
  })

  test('should get localstorage data', function(assert) {
    assert.deepEqual(service.getUser(), fakeUser)
  })

  test('should return null when data not exist', function(assert) {
    localStorage.clear()
    assert.deepEqual(service.getUser(), null)
  })

  test('on fails should redirect to /clear', function(assert) {
    brokeStorageData()
    service.getUser()
    assert.ok(service.router.transitionTo.calledWith('clear'))
  })

  function brokeStorageData() {
    localStorage.setItem(service.USER_KEY, "123{ASD")
  }
})

<commit_msg>Test: Storage:SimpleRead<commit_after>import { module, test } from 'qunit'
import { setupPBUnitTest, setupLoggedUser } from '../../helpers/utils'
import { fakeUser } from '../../helpers/mocks'
import { setupTest } from 'ember-qunit';

module('Unit | Service | storage', function(hooks) {
  let service
  setupPBUnitTest(hooks)
  setupLoggedUser(hooks)

  hooks.beforeEach(function() {
    service = this.owner.lookup('service:storage')
  })

  test('should get localstorage data', function(assert) {
    assert.deepEqual(service.getUser(), fakeUser)
  })

  test('should return null when data not exist', function(assert) {
    localStorage.clear()
    assert.deepEqual(service.getUser(), null)
  })

  test('on fails should redirect to /clear', function(assert) {
    brokeStorageData()
    service.getUser()
    assert.ok(service.router.transitionTo.calledWith('clear'))
  })

  function brokeStorageData() {
    localStorage.setItem(service.USER_KEY, "123{ASD")
  }
})

module('Unit | Service | storage | SimpleRead', function(hooks) {
  let service
  setupTest(hooks);

  hooks.beforeEach(function() {
    service = this.owner.lookup('service:storage')
  })

  test('By default simple read mode is disabled', function (assert) {
    assert.notOk(service.getUseSimpleRead())
  })

  test('Enabled simple read mode', function (assert) {
    service.toggleSimpleRead()
    assert.ok(service.getUseSimpleRead())
  })
})

{'fraction_non_alphanumeric': 0.14395557454079452, 'fraction_numerical': 0.0025630072618539087, 'mean_word_length': 4.334851936218679, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2746621', 'n_tokens_mistral': 715, 'n_tokens_neox': 718, 'n_words': 148}