Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rewrite the ‘url’ test suite into Mocha

  • Loading branch information...
commit fb46f7710a019681337fed00a5d974608fca7289 1 parent 04d5978
@Baggz authored
Showing with 76 additions and 0 deletions.
  1. +76 −0 tests/json/attributes/format/url.js
View
76 tests/json/attributes/format/url.js
@@ -0,0 +1,76 @@
+if (typeof module !== 'undefined' && module.exports) {
+ var expect = require('expect.js');
+ var Amanda = require('../../../../dist/latest.js');
+ var domains = require('../../../resources/domains.js');
+ var domainNames = require('../../../resources/domainNames.js');
+ var params = require('../../../resources/params.js');
+}
+
+/**
+ * Format
+ * --------------------
+ */
+suite('JSON/Attribute/format#url', function() {
+
+ var count = 0;
+
+ /**
+ * Schema
+ */
+ var schema = {
+ format: 'url'
+ };
+
+ /**
+ * Validator
+ */
+ var Validator = new Amanda('json');
+
+ test('should not return an error', function() {
+
+ domains.forEach(function(domain) {
+ domainNames.forEach(function(name) {
+
+ Validator.validate(name + domain, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+
+ params.forEach(function(param) {
+ Validator.validate(name + domain + param, schema, function(error) {
+ count += 1;
+ expect(error).to.not.be.ok();
+ });
+ });
+
+ });
+ });
+
+ });
+
+ test('should return an error', function() {
+ [
+ 'google.a',
+ 'google.rog',
+ 'google://google',
+ 'example',
+ 'http://ex.o',
+ 'www.ex.o',
+ 'pam.pam.pam',
+ 'go@gle',
+ 'g::gle',
+ '☺☻☹.com',
+ '☜☞☝☟'
+ ].forEach(function(input) {
+ Validator.validate(input, schema, function(error) {
+ count += 1;
+ expect(error).to.be.ok();
+ });
+ });
+ });
+
+ test('should run 18911 times', function() {
+ expect(count).to.be.eql(18911);
+ });
+
+});

0 comments on commit fb46f77

Please sign in to comment.
Something went wrong with that request. Please try again.