<commit_before>Browsers = require('../lib/browsers')
Prefixes = require('../lib/prefixes')
info     = require('../lib/info')

data =
  browsers: require('caniuse-db/data.json').agents
  prefixes:
    a:
      browsers: ['firefox 21', 'firefox 20', 'chrome 30']
      transition: true
    b:
      browsers: ['ie 6', 'firefox 20']
      props:    ['a', '*']
    c:
      browsers: ['firefox 21']
      props:    ['c']
    d:
      browsers: ['firefox 21']
      selector:   true
    '@keyframes':
      browsers: ['firefox 21']
    transition:
      browsers: ['firefox 21']

describe 'info', ->

  it 'returns selected browsers and prefixes', ->
    browsers = new Browsers(data.browsers,
      ['chrome 30', 'firefox 21', 'firefox 20', 'ie 6'])
    prefixes = new Prefixes(data.prefixes, browsers)

    info(prefixes).should.eql "Browsers:\n" +
                              "  Chrome: 30\n" +
                              "  Firefox: 21, 20\n" +
                              "  IE: 6\n" +
                              "\n" +
                              "These browsers account for 0.13% " +
                                "of all users globally\n" +
                              "\n" +
                              "At-Rules:\n" +
                              "  @keyframes: moz\n" +
                              "\n" +
                              "Selectors:\n" +
                              "  d: moz\n" +
                              "\n" +
                              "Properties:\n" +
                              "  a: webkit, moz\n" +
                              "  transition: moz\n" +
                              "\n" +
                              "Values:\n" +
                              "  b: moz, ms\n" +
                              "  c: moz\n"

  it "doesn't show transitions unless they are necessary", ->
    browsers = new Browsers(data.browsers, ['chrome 30', 'firefox 20', 'ie 6'])
    prefixes = new Prefixes(data.prefixes, browsers)

    info(prefixes).should.eql "Browsers:\n" +
                              "  Chrome: 30\n" +
                              "  Firefox: 20\n" +
                              "  IE: 6\n" +
                              "\n" +
                              "These browsers account for 0.09% " +
                                "of all users globally\n" +
                              "\n" +
                              "Properties:\n" +
                              "  a: webkit, moz\n" +
                              "\n" +
                              "Values:\n" +
                              "  b: moz, ms\n"

  it 'returns string for empty prefixes', ->
    browsers = new Browsers(data.browsers, ['ie 7'])
    prefixes = new Prefixes(data.prefixes, browsers)

    info(prefixes).should.match(/remove Autoprefixer/)

  it 'returns string for empty browsers', ->
    browsers = new Browsers(data.browsers, [])
    prefixes = new Prefixes(data.prefixes, browsers)

    info(prefixes).should.eql "No browsers selected"<commit_msg>Make tests independent from browsers statistics update<commit_after>browserslist = require('browserslist')
Browsers     = require('../lib/browsers')
Prefixes     = require('../lib/prefixes')
info         = require('../lib/info')

data =
  browsers: require('caniuse-db/data.json').agents
  prefixes:
    a:
      browsers: ['firefox 21', 'firefox 20', 'chrome 30']
      transition: true
    b:
      browsers: ['ie 6', 'firefox 20']
      props:    ['a', '*']
    c:
      browsers: ['firefox 21']
      props:    ['c']
    d:
      browsers: ['firefox 21']
      selector:   true
    '@keyframes':
      browsers: ['firefox 21']
    transition:
      browsers: ['firefox 21']

describe 'info', ->

  it 'returns selected browsers and prefixes', ->
    browsers = new Browsers(data.browsers,
      ['chrome 30', 'firefox 21', 'firefox 20', 'ie 6'])
    prefixes = new Prefixes(data.prefixes, browsers)

    coverage = browserslist.coverage(
      ['chrome 30', 'firefox 21', 'firefox 20', 'ie 6'])
    round = Math.round(coverage * 100) / 100.0

    info(prefixes).should.eql "Browsers:\n" +
                              "  Chrome: 30\n" +
                              "  Firefox: 21, 20\n" +
                              "  IE: 6\n" +
                              "\n" +
                              "These browsers account for #{round}% " +
                                "of all users globally\n" +
                              "\n" +
                              "At-Rules:\n" +
                              "  @keyframes: moz\n" +
                              "\n" +
                              "Selectors:\n" +
                              "  d: moz\n" +
                              "\n" +
                              "Properties:\n" +
                              "  a: webkit, moz\n" +
                              "  transition: moz\n" +
                              "\n" +
                              "Values:\n" +
                              "  b: moz, ms\n" +
                              "  c: moz\n"

  it "doesn't show transitions unless they are necessary", ->
    browsers = new Browsers(data.browsers, ['chrome 30', 'firefox 20', 'ie 6'])
    prefixes = new Prefixes(data.prefixes, browsers)

    coverage = browserslist.coverage(['chrome 30', 'firefox 20', 'ie 6'])
    round    = Math.round(coverage * 100) / 100.0

    info(prefixes).should.eql "Browsers:\n" +
                              "  Chrome: 30\n" +
                              "  Firefox: 20\n" +
                              "  IE: 6\n" +
                              "\n" +
                              "These browsers account for #{ round }% " +
                                "of all users globally\n" +
                              "\n" +
                              "Properties:\n" +
                              "  a: webkit, moz\n" +
                              "\n" +
                              "Values:\n" +
                              "  b: moz, ms\n"

  it 'returns string for empty prefixes', ->
    browsers = new Browsers(data.browsers, ['ie 7'])
    prefixes = new Prefixes(data.prefixes, browsers)

    info(prefixes).should.match(/remove Autoprefixer/)

  it 'returns string for empty browsers', ->
    browsers = new Browsers(data.browsers, [])
    prefixes = new Prefixes(data.prefixes, browsers)

    info(prefixes).should.eql "No browsers selected"
{'fraction_non_alphanumeric': 0.12897196261682242, 'fraction_numerical': 0.01806853582554517, 'mean_word_length': 1.0983660130718955, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4071764', 'n_tokens_mistral': 1982, 'n_tokens_neox': 1843, 'n_words': 422}