<commit_before>import Ember from 'ember';

import startApp from '../../tests/helpers/start-app';
import { test } from 'ember-qunit';

var App;

module('Cards - Integration', {

  setup: function() {
    App = startApp();
  },

  teardown: function() {
    Ember.run(App, 'destroy');
  }

});



test('Basic Card should have a title', function(assert) {
  visit('/cards').then(function() {
    var titleEle = find('#basic-card > .card-content span');

    assert.ok(titleEle.hasClass('card-title'));
    assert.equal(titleEle.text().trim(), 'Card Title');
  });
});

test('Image Card should have a title', function(assert) {
  visit('/cards').then(function() {
    var titleEle = find('#image-card > .card-content span');

    assert.ok(titleEle.hasClass('card-title'));
    assert.equal(titleEle.text().trim(), 'Card Title');
  });
});

test('Card Reveal should have a title', function(assert) {
  visit('/cards').then(function() {
    var titleEle = find('#card-reveal > .card-content span');

    assert.ok(titleEle.hasClass('card-title'));
    assert.equal(titleEle.text().trim(), 'Card Title');
  });
});



test('Basic Card should have content', function(assert) {
  visit('/cards').then(function() {
    var contentEle = find('#basic-card > .card-content');

    assert.ok(contentEle.hasClass('card-content'));

    var expected = "I am a very simple card. I am good at containing small bits of information.\n" +
        "                            " +
        "I am convenient because I require little markup to use effectively.";

    // skip over the span containing the card title and get just the card content text.
    var actual = contentEle.find('>span').next().text().trim();

    assert.equal(actual, expected);

  });
});

test('Image Card should have content', function(assert) {
  visit('/cards').then(function() {
    var contentEle = find('#image-card > .card-content');

    assert.ok(contentEle.hasClass('card-content'));

    var expected = "I am a very simple card. I am good at containing small bits of information.\n" +
      "                            " +
      "I am convenient because I require little markup to use effectively.";

    // skip over the span containing the card title and get just the card content text.
    var actual = contentEle.find('>span').next().text().trim();

    assert.equal(actual, expected);

  });
});

test('Card Reveal should have content', function(assert) {
  visit('/cards').then(function() {
    var contentEle = find('#card-reveal > .card-content');

    assert.ok(contentEle.hasClass('card-content'));

    // skip over the span containing the card title and get just the card content text.
    var actual = contentEle.find('>span').next().text().trim();

    assert.equal(actual, "This is a Link");

  });
});


test('Card Reveal should have content', function(assert) {
  visit('/cards').then(function() {
    var contentEle = find('#card-panel > span');

    assert.ok(contentEle.hasClass('white-text'));

    var expected = "I am a very simple card.\n" +
      "                      I am good at containing small bits of information.\n" +
      "                      I am convenient because I require little markup to use effectively.\n" +
      "                      I am similar to what is called a panel in other frameworks.";

    // skip over the span containing the card title and get just the card content text.
    var actual = contentEle.text().trim();

    assert.equal(actual, expected);

  });
});


test('Basic Card should have actions', function(assert) {
  visit('/cards').then(function() {
    var actionEle = find('#basic-card > .card-action');

    assert.ok(actionEle.hasClass('card-action'));
  });
});

test('Image Card should have actions', function(assert) {
  visit('/cards').then(function() {
    var actionEle = find('#image-card > .card-action');

    assert.ok(actionEle.hasClass('card-action'));
  });
});


test('Card Reveal should reveal and conceal content', function(assert) {
  visit('/cards').then(function() {

    var doneReveal = assert.async();
    var doneConceal = assert.async();

    var activatorEle = find('#card-reveal>.card-content>.activator');
    var revealEle = find('#card-reveal>.card-reveal');
    var concealEle = revealEle.find('>.card-title');
    var animationClass = 'velocity-animating';

    // click to reveal
    click(activatorEle).then(function() {
      // should be animating...
      assert.ok(revealEle.hasClass(animationClass));

      // wait for animation to complete
      setTimeout(function() {
        assert.ok(!revealEle.hasClass(animationClass));
        doneReveal();

        // click to conceal
        click(concealEle).then(function() {
          assert.ok(revealEle.hasClass(animationClass));

          // wait for animation to complete
          setTimeout(function() {
            assert.ok(!revealEle.hasClass(animationClass));
            doneConceal();
          }, 500);
        });
      }, 500);
    });

  });
});
<commit_msg>DRY up cards-test<commit_after>import Ember from 'ember';

import startApp from '../../tests/helpers/start-app';
import { test } from 'ember-qunit';

var App;

module('Cards - Integration', {

  setup: function() {
    App = startApp();
  },

  teardown: function() {
    Ember.run(App, 'destroy');
  }

});


function checkCardTitle (cardType, cardId) {
  test(`${cardType} should have a title`, function(assert) {
    visit('/cards').then(function() {
      var titleEle = find(`#${cardId} > .card-content span`);

      assert.ok(titleEle.hasClass('card-title'));
      assert.equal(titleEle.text().trim(), 'Card Title');
    });
  });
}

function checkCardContent (cardType, cardId) {
  test(`${cardType} should have content`, function(assert) {
    visit('/cards').then(function() {
      var contentEle = find(`#${cardId} > .card-content`);

      assert.ok(contentEle.hasClass('card-content'));

      var expected = "I am a very simple card. I am good at containing small bits of information.\n" +
          "                            " +
          "I am convenient because I require little markup to use effectively.";

      // skip over the span containing the card title and get just the card content text.
      var actual = contentEle.find('>span').next().text().trim();

      assert.equal(actual, expected);

    });
  });
}

function checkCardActions (cardType, cardId) {
  test(`${cardType} should have actions`, function(assert) {
    visit('/cards').then(function() {
      var actionEle = find(`#${cardId} > .card-action`);

      assert.ok(actionEle.hasClass('card-action'));
    });
  });
}

var cardFlavors = [
  {type: 'Basic Card', id: 'basic-card'},
  {type: 'Image Card', id: 'image-card'},
  {type: 'Card Reveal', id: 'card-reveal'}
];

for (var i = 0; i < cardFlavors.length; i++) {
  checkCardTitle(cardFlavors[i].type, cardFlavors[i].id);
}
checkCardContent(cardFlavors[0].type, cardFlavors[0].id);
checkCardContent(cardFlavors[1].type, cardFlavors[1].id);
checkCardActions(cardFlavors[0].type, cardFlavors[0].id);
checkCardActions(cardFlavors[1].type, cardFlavors[1].id);

test('Card Reveal should have content', function(assert) {
  visit('/cards').then(function() {
    var contentEle = find('#card-reveal > .card-content');

    assert.ok(contentEle.hasClass('card-content'));

    // skip over the span containing the card title and get just the card content text.
    var actual = contentEle.find('>span').next().text().trim();

    assert.equal(actual, "This is a Link");

  });
});


test('Card Reveal should have content', function(assert) {
  visit('/cards').then(function() {
    var contentEle = find('#card-panel > span');

    assert.ok(contentEle.hasClass('white-text'));

    var expected = "I am a very simple card.\n" +
      "                      I am good at containing small bits of information.\n" +
      "                      I am convenient because I require little markup to use effectively.\n" +
      "                      I am similar to what is called a panel in other frameworks.";

    // skip over the span containing the card title and get just the card content text.
    var actual = contentEle.text().trim();

    assert.equal(actual, expected);

  });
});




test('Card Reveal should reveal and conceal content', function(assert) {
  visit('/cards').then(function() {

    var doneReveal = assert.async();
    var doneConceal = assert.async();

    var activatorEle = find('#card-reveal>.card-content>.activator');
    var revealEle = find('#card-reveal>.card-reveal');
    var concealEle = revealEle.find('>.card-title');
    var animationClass = 'velocity-animating';

    // click to reveal
    click(activatorEle).then(function() {
      // should be animating...
      assert.ok(revealEle.hasClass(animationClass));

      // wait for animation to complete
      setTimeout(function() {
        assert.ok(!revealEle.hasClass(animationClass));
        doneReveal();

        // click to conceal
        click(concealEle).then(function() {
          assert.ok(revealEle.hasClass(animationClass));

          // wait for animation to complete
          setTimeout(function() {
            assert.ok(!revealEle.hasClass(animationClass));
            doneConceal();
          }, 500);
        });
      }, 500);
    });

  });
});

{'fraction_non_alphanumeric': 0.1570123589468028, 'fraction_numerical': 0.0022568511552928535, 'mean_word_length': 2.9888555507929704, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3080706', 'n_tokens_mistral': 2842, 'n_tokens_neox': 2659, 'n_words': 707}