<commit_before>_ = require 'underscore'
benv = require 'benv'
Backbone = require 'backbone'
sinon = require 'sinon'
{ resolve } = require 'path'
{ fabricate } = require 'antigravity'
FeatureNavigationView = benv.requireWithJadeify resolve(__dirname, '../../client/feature_navigation'), ['template']

describe 'FeatureNavigationView', ->
  before (done) ->
    benv.setup =>
      benv.expose $: benv.require 'jquery'
      Backbone.$ = $
      $.support.transition = end: 'transitionend'
      $.fn.emulateTransitionEnd = -> @trigger $.support.transition.end
      done()

  after ->
    benv.teardown()

  it 'renders when there is a feature', ->
    feature = new Backbone.Model(fabricate 'feature')
    view = new FeatureNavigationView model: feature, kind: 'feature'
    html = view.$el.html()
    html.should.containEql '<a href="/feature/bitty-the-cat">Work offered by<br>A Feature all about the greatest cat'
    html.should.containEql 'Go to feature'

  it 'renders when there is a valid fair', ->
    fair = new Backbone.Model(fabricate 'fair')
    view = new FeatureNavigationView model: fair, kind: 'fair'
    html = view.$el.html()
    html.should.containEql '<a href="/the-armory-show">Work offered by<br>Armory Show 2013'
    html.should.containEql 'Go to fair'

  it 'does not render when there is a invalid fair', ->
    fair = new Backbone.Model(fabricate 'fair')
    fair.unset 'organizer'<commit_msg>update specs<commit_after>_ = require 'underscore'
benv = require 'benv'
Backbone = require 'backbone'
sinon = require 'sinon'
{ resolve } = require 'path'
{ fabricate } = require 'antigravity'
FeatureNavigationView = benv.requireWithJadeify resolve(__dirname, '../../client/feature_navigation'), ['template']

describe 'FeatureNavigationView', ->
  before (done) ->
    benv.setup =>
      benv.expose $: benv.require 'jquery'
      Backbone.$ = $
      $.support.transition = end: 'transitionend'
      $.fn.emulateTransitionEnd = -> @trigger $.support.transition.end
      done()

  after ->
    benv.teardown()

  it 'renders when there is a feature', ->
    feature = new Backbone.Model(fabricate 'feature')
    view = new FeatureNavigationView model: feature, kind: 'feature'
    html = view.$el.html()
    html.should.containEql '<a href="/feature/bitty-the-cat">Work offered by<br>A Feature all about the greatest cat'
    html.should.containEql 'Go to feature'

  it 'renders when there is a published fair', ->
    fair = new Backbone.Model(fabricate 'fair')
    fair.set 'published', true
    view = new FeatureNavigationView model: fair, kind: 'fair'
    html = view.$el.html()
    html.should.containEql '<a href="/the-armory-show">Work offered by<br>Armory Show 2013'
    html.should.containEql 'Go to fair'

  it 'does not render when there is a unpublished fair', ->
    fair = new Backbone.Model(fabricate 'fair')
{'fraction_non_alphanumeric': 0.13232713232713234, 'fraction_numerical': 0.002808002808002808, 'mean_word_length': 3.6492659053833605, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '5930098', 'n_tokens_mistral': 905, 'n_tokens_neox': 874, 'n_words': 249}