Permalink
Browse files

[test] updated tests, included library tests for npm test

  • Loading branch information...
blakmatrix committed Mar 15, 2013
1 parent e3ece90 commit c19102f90d9bd415a48cab9d76ad74d0c9cf3ff1
Showing with 124 additions and 6 deletions.
  1. +1 −1 package.json
  2. +123 −5 test/lib/package-test.js
View
@@ -50,7 +50,7 @@
},
"main": "./lib/jitsu",
"scripts": {
- "test": "vows test/commands/*-test.js --spec -i"
+ "test": "vows test/commands/*-test.js test/lib/*-test.js --spec -i"
},
"engines": {
"node": ">= 0.6.0"
View
@@ -9,10 +9,14 @@ var assert = require('assert'),
fs = require('fs'),
path = require('path'),
vows = require('vows'),
- jitsu = require('../../lib/jitsu');
+ jitsu = require('../../lib/jitsu'),
+ macros = require('../helpers/macros');
var mainDirectory = process.cwd();
+jitsu.init();
+//jitsu.log.loggers.default.remove(app.log.loggers.default.transports.console); // make silent
+
function setupPackage (options) {
options = options || {};
return {
@@ -45,7 +49,7 @@ function isValid(property, value) {
return false;
}
-var suite = vows.describe('jitsu/package').addBatch({
+var suite = vows.describe('jitsu/lib/package').addBatch({
'name': {
'starting with .': {
topic: setupPackage({ name: '.example-app' }),
@@ -57,8 +61,8 @@ var suite = vows.describe('jitsu/package').addBatch({
'starting with _': {
topic: setupPackage({ name: '_example-app' }),
- 'should be invalid': function (topic) {
- assert.ok(!isValid('name', topic.name));
+ 'should be valid': function (topic) {

This comment has been minimized.

Show comment Hide comment
@julianduque

julianduque Mar 15, 2013

Contributor

According to npm docs the name can't start with an underscore.

The name ends up being part of a URL, an argument on the command line, and a folder name. Any name with non-url-safe characters will be rejected. Also, it can't start with a dot or an underscore.
@julianduque

julianduque Mar 15, 2013

Contributor

According to npm docs the name can't start with an underscore.

The name ends up being part of a URL, an argument on the command line, and a folder name. Any name with non-url-safe characters will be rejected. Also, it can't start with a dot or an underscore.
+ assert.ok(isValid('name', topic.name));
}
},
'containing -': {
@@ -75,7 +79,7 @@ var suite = vows.describe('jitsu/package').addBatch({
assert.ok(!isValid('name', topic.name));
}
},
- 'containing .': {
+ 'containing interior .': {
topic: setupPackage({ name: 'example.app' }),
'should be valid': function (topic) {
@@ -102,6 +106,120 @@ var suite = vows.describe('jitsu/package').addBatch({
'should be invalid': function (topic) {
assert.ok(!isValid('name', topic.name));
}
+ },
+ 'containing +': {
+ topic: setupPackage({ name: 'example+app' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('name', topic.name));
+ }
+ },
+ 'containing /': {
+ topic: setupPackage({ name: 'example/app' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('name', topic.name));
+ }
+ },
+ 'node_modules': {
+ topic: setupPackage({ name: 'node_modules' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('name', topic.name));
+ }
+ },
+ 'favicon.ico': {
+ topic: setupPackage({ name: 'favicon.ico' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('name', topic.name));
+ }
+ },
+ 'containing unicode(๛ಠ_ಠ☠☃❤⁂⍨⋙‽)': {
+ topic: setupPackage({ name: '๛ಠ_ಠ☠☃❤⁂⍨⋙‽' }),
+
+ 'should be valid': function (topic) {
+ assert.ok(isValid('name', topic.name));
+ }
+ }
+ },
+ 'subdomain': {
+ 'starting with 9': {
+ topic: setupPackage({ subdomain: '9example' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'starting with _': {
+ topic: setupPackage({ subdomain: '_example' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'containing -': {
+ topic: setupPackage(),
+
+ 'should be valid': function (topic) {
+ assert.ok(isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'containing spaces': {
+ topic: setupPackage({ subdomain: 'example domain' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'containing .': { //will become invalid soon
+ topic: setupPackage({ subdomain: 'example.domain' }),
+
+ 'should be valid': function (topic) {
+ assert.ok(isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'containing %': {
+ topic: setupPackage({ subdomain: 'example%domain' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'containing @': {
+ topic: setupPackage({ subdomain: 'example@domain' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'containing :': {
+ topic: setupPackage({ subdomain: 'example:domain' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'end with number': {
+ topic: setupPackage({ subdomain: 'c9' }),
+
+ 'should be valid': function (topic) {
+ assert.ok(isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'end with -': {
+ topic: setupPackage({ subdomain: 'c9-' }),
+
+ 'should be invalid': function (topic) {
+ assert.ok(!isValid('subdomain', topic.subdomain));
+ }
+ },
+ 'containing unicode(๛ಠ_ಠ☠☃❤⁂⍨⋙‽)': {
+ topic: setupPackage({ subdomain: '๛ಠ_ಠ☠☃❤⁂⍨⋙‽' }),
+
+ 'should be valid': function (topic) {
+ assert.ok(isValid('subdomain', topic.subdomain));
+ }
}
}
});

0 comments on commit c19102f

Please sign in to comment.