<commit_before>'use strict'

const test = require('ava')
const execa = require('execa')

const {
  CONSUMER_KEY,
  CONSUMER_SECRET,
  FANFOU_USERNAME,
  FANFOU_PASSWORD
} = process.env

test('nofan config', async t => {
  const {stdout} = await execa('./bin/nofan.js', ['config', CONSUMER_KEY, CONSUMER_SECRET])
  t.is(stdout, '')
})

test('nofan login', async t => {
  const {stdout} = await execa('./bin/nofan.js', ['login', FANFOU_USERNAME, FANFOU_PASSWORD])
  t.is(stdout, 'Login succeed!')
})

test('nofan switch', async t => {
  const {stdout} = await execa('./bin/nofan.js', ['switch', FANFOU_USERNAME])
  t.is(stdout, `Switch account to ${FANFOU_USERNAME}`)
})

test('nofan logout', async t => {<commit_msg>add 'pull request from forked' use case<commit_after>'use strict'

const test = require('ava')
const execa = require('execa')

const {
  CONSUMER_KEY,
  CONSUMER_SECRET,
  FANFOU_USERNAME,
  FANFOU_PASSWORD
} = process.env

const PULL_REQUEST_FROM_FORKED = !(CONSUMER_KEY && CONSUMER_SECRET && FANFOU_USERNAME && FANFOU_PASSWORD)

test('nofan config', async t => {
  const {stdout} = await execa('./bin/nofan.js', ['config', CONSUMER_KEY, CONSUMER_SECRET])
  t.is(stdout, '')
})

test('nofan login', async t => {
  const {stdout} = await execa('./bin/nofan.js', ['login', FANFOU_USERNAME, FANFOU_PASSWORD])
  PULL_REQUEST_FROM_FORKED ? t.is(stdout, 'Invalid consumer') : t.is(stdout, 'Login succeed!')
})

test('nofan switch', async t => {
  const {stdout} = await execa('./bin/nofan.js', ['switch', FANFOU_USERNAME])
  PULL_REQUEST_FROM_FORKED ? t.is(stdout, `${FANFOU_USERNAME} needs login`) : t.is(stdout, `Switch account to ${FANFOU_USERNAME}`)
})

test('nofan logout', async t => {
{'fraction_non_alphanumeric': 0.17225161669606115, 'fraction_numerical': 0.0, 'mean_word_length': 5.2344322344322345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '542479', 'n_tokens_mistral': 685, 'n_tokens_neox': 676, 'n_words': 139}