Permalink
Browse files

First commit.

  • Loading branch information...
0 parents commit f59efaf9d10c575588dcc0b287f10c1200997311 @jakubpawlowicz committed Mar 20, 2011
Showing with 63 additions and 0 deletions.
  1. 0 History.md
  2. +9 −0 Makefile
  3. 0 Readme.md
  4. +1 −0 index.js
  5. +19 −0 lib/assets.js
  6. 0 package.json
  7. +34 −0 test/assets-test.js
  8. 0 test/data/1.css
No changes.
@@ -0,0 +1,9 @@
+TEST_DIR = test
+
+all: test
+
+test:
+ @@echo "Running all tests via vows"
+ @@vows ${TEST_DIR}/*-test.js
+
+.PHONY: all test
No changes.
@@ -0,0 +1 @@
+module.exports = require("./lib/assets");
@@ -0,0 +1,19 @@
+var fs = require('fs'),
+ path = require('path');
+
+var Assets = {
+ expand: function(group, options) {
+ var assets = [];
+ options = options || {};
+
+ group.split(' ').forEach(function(asset) {
+ if (asset.length == 0) return;
+
+ assets.push(path.join(options.root, asset));
+ });
+
+ return assets;
+ }
+};
+
+module.exports = Assets;
No changes.
@@ -0,0 +1,34 @@
+var vows = require('vows'),
+ assert = require('assert'),
+ assets = require('../index');
+
+var rootPath = process.cwd() + '/test/data/';
+
+function fullPathTo(assetName) {
+ return rootPath + assetName;
+};
+
+function expand(list) {
+ return assets.expand(list, { root: rootPath });
+};
+
+vows.describe('expanding assets').addBatch({
+ 'expand empty': {
+ topic: expand(''),
+ 'should get array': function(expanded) {
+ assert.isArray(expanded)
+ },
+ 'should get empty list': function(expanded) {
+ assert.isEmpty(expanded);
+ }
+ },
+ 'expand single file': {
+ topic: expand('1.css'),
+ 'should get array with one element': function(expanded) {
+ assert.length(expanded, 1);
+ },
+ 'should get full path to 1.css': function(expanded) {
+ assert.equal(expanded[0], fullPathTo('1.css'));
+ }
+ }
+}).export(module);
No changes.

0 comments on commit f59efaf

Please sign in to comment.