<commit_before>// @flow

import Update from './update'
import PluginsUpdate from './plugins/update'

const version = '1.0.0'
const channel = 'stable'

const mockManifest = {}

jest.mock('./plugins/update', () => {
  return class {
    static run = jest.fn()
  }
})

const mockUpdate = jest.fn()

jest.mock('../updater', () => {
  return class {
    fetchManifest () { return mockManifest }
    update = mockUpdate
  }
})

describe.skip('with no update available', () => {
  test('updates plugins only', async () => {
    mockManifest.version = '1.0.0'
    const cmd = await Update.run([], {mock: true, version, channel})
    expect(cmd.stdout.output).toEqual('')
    expect(cmd.stderr.output).toEqual(`cli-engine-command: Updating CLI...
cli-engine-command: Updating CLI... already on latest version: 1.0.0
`)
    expect(PluginsUpdate.run).toBeCalled()
  })
})

describe.skip('with update available', () => {
  test('updates CLI and plugins', async () => {
    mockManifest.version = '1.0.1'
    const cmd = await Update.run([], {mock: true, version, channel})
    expect(cmd.stdout.output).toEqual('')
    expect(cmd.stderr.output).toEqual(`cli-engine-command: Updating CLI...
cli-engine-command: Updating CLI to 1.0.1...
cli-engine-command: Updating CLI to 1.0.1... done
`)
    expect(mockUpdate).toBeCalled()
    expect(PluginsUpdate.run).toBeCalled()
  })
})<commit_msg>do not skip<commit_after>// @flow

import Update from './update'
import PluginsUpdate from './plugins/update'

const version = '1.0.0'
const channel = 'stable'

const mockManifest = {}

jest.mock('./plugins/update', () => {
  return class {
    static run = jest.fn()
  }
})

const mockUpdate = jest.fn()

jest.mock('../updater', () => {
  return class {
    fetchManifest () { return mockManifest }
    update = mockUpdate
  }
})

describe('with no update available', () => {
  test('updates plugins only', async () => {
    mockManifest.version = '1.0.0'
    const cmd = await Update.run([], {mock: true, version, channel})
    expect(cmd.stdout.output).toEqual('')
    expect(cmd.stderr.output).toEqual(`cli-engine-command: Updating CLI...
cli-engine-command: Updating CLI... already on latest version: 1.0.0
`)
    expect(PluginsUpdate.run).toBeCalled()
  })
})

describe('with update available', () => {
  test('updates CLI and plugins', async () => {
    mockManifest.version = '1.0.1'
    const cmd = await Update.run([], {mock: true, version, channel})
    expect(cmd.stdout.output).toEqual('')
    expect(cmd.stderr.output).toEqual(`cli-engine-command: Updating CLI...
cli-engine-command: Updating CLI to 1.0.1...
cli-engine-command: Updating CLI to 1.0.1... done
`)
    expect(mockUpdate).toBeCalled()
    expect(PluginsUpdate.run).toBeCalled()
  })
})
{'fraction_non_alphanumeric': 0.1783625730994152, 'fraction_numerical': 0.013157894736842105, 'mean_word_length': 3.538971807628524, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '3367691', 'n_tokens_mistral': 895, 'n_tokens_neox': 894, 'n_words': 204}