Sha256: 08a3cbaf3db312e98f49dba4793cf234444a589234c93934c4403d79ae6818f1

Contents?: true

Size: 1.92 KB

Versions: 8

Compression:

Stored size: 1.92 KB

Contents

require(['backbone_apps/school_selector'], function(plugin) {
  var SchoolSelectorView = plugin($);

  module("School Selector Tests");

  test("SchoolSelectorView loaded", function() {
    ok(SchoolSelectorView, "SchoolSelectorView defined");

    var ssv = new SchoolSelectorView({
      el : $('#profile-school').get(),
      audienceField : $('#profile_audience_id')
    });
    ok(ssv, "SchoolSelectorView instantiable");
    ok(ssv.newSchoolForm, "SchoolSelectorView#newSchoolForm accessible");
    ok(ssv.stateDefs, "SchoolSelectorView#stateDefs accessible");
  });

  test("zipcode validation", function() {
    var audienceField = $('#profile_audience_id');
    var ssv = new SchoolSelectorView({
      el : $('#profile-school').get(),
      audienceField : audienceField
    });

    // School field only shows up when audience is set to Educator
    var educatorOption = $('#profile_audience_id option:contains(Educator)');
    audienceField.val(educatorOption.val()).trigger('refreshCustomValidityRules');
    audienceField.change();

    var zipcode = $("#school-select-zipcode");
    ok(zipcode, "Found zipcode DOM element");
    ok(zipcode.prop("required"), "zipcode should be required");

    zipcode.val("").trigger('refreshCustomValidityRules');
    ok(!zipcode.prop('validity').valid, "empty zipcode should not be valid");

    zipcode.val("123").trigger('refreshCustomValidityRules');
    ok(!zipcode.prop('validity').valid, "too short");

    zipcode.val("12345").trigger('refreshCustomValidityRules');
    ok(zipcode.checkValidity(), "good format, correct length (checkValidity)");
    ok(zipcode.prop('validity').valid, "good format, correct length");

    zipcode.val("abcde").trigger('refreshCustomValidityRules');
    ok(!zipcode.checkValidity(), "bad format (checkValidity)");
    ok(!zipcode.prop('validity').valid, "bad format");
    equals(zipcode.prop('validationMessage'), "Invalid zipcode", "custom error message shows");
  });

});

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
scidea-schools-1.1 qunit/tests/backbone_apps/school_selector.js
scidea-schools-1.0.6 qunit/tests/backbone_apps/school_selector.js
scidea-schools-1.0.5 qunit/tests/backbone_apps/school_selector.js
scidea-schools-1.0.4 qunit/tests/backbone_apps/school_selector.js
scidea-schools-1.0.3 qunit/tests/backbone_apps/school_selector.js
scidea-schools-1.0.2 qunit/tests/backbone_apps/school_selector.js
scidea-schools-1.0.1 qunit/tests/backbone_apps/school_selector.js
scidea-schools-1.0.0 qunit/tests/backbone_apps/school_selector.js