Skip to content
This repository has been archived by the owner on Sep 24, 2019. It is now read-only.

Notes on converting tests in the guideline branch

Kevin Miller edited this page Apr 1, 2014 · 1 revision

These are notes on how to convert quail tests to the new guideline branch.

Convert test signature

quail.myTest = function(quail, test, Case) {

Replace quail.html

Use test.get('$scope')

test.get('$scope').find('a').each(function() {

Find the potential elements that could be tested

test.get('$scope').find('my jquery selector').each(function() {
  //Enter logic to determine if element is not within scope to test
  if (myLogic === true) {
    var _case = Case({
      element : this
    });
    test.add(_case);
    _case.set({
      'status': 'notApplicable',
      expected: $(this).closest('.quail-test').data('expected')
    });
  }
});

Find element that failed or pass

Find all the elements that are in $applicableElements, a filter method is helpful here before iterating over the element list for certain tests.

$applicableElements.each(function() {
  var _case = Case({
    element: this,
    expected: $(this).closest('.quail-test').data('expected')
  });
  test.add(_case);
  // Do some logic to determine if the element failed
  if (test fails logic) {
    _case.set({
      'status': 'failed'
    });
  }
  // Otherwise, the element passed
  else {
    _case.set({
      'status': 'passed'
    });
  }
});