forked from yeoman/yeoman
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test-bower.js
96 lines (80 loc) · 2.81 KB
/
test-bower.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*globals describe, it, before, after, beforeEach, afterEach */
var fs = require('fs'),
path = require('path'),
grunt = require('grunt'),
assert = require('assert'),
helpers = require('./helpers'),
bower = require('bower').commands;
// bower components to test out
var components = ['jquery', 'backbone'];
// var components = ['jquery', 'backbone', 'ember', 'angular', 'canjs'];
describe('Bower install packages', function() {
before(helpers.directory('.test'));
before(helpers.gruntfile({
foo: {
bar: '<config.baz>'
}
}));
before(function(done) {
var yeoman = helpers.run('init --force');
yeoman
// enter '\n' for both prompts, and grunt confirm
.prompt(/would you like/i)
.prompt(/Do you need to make any changes to the above before continuing?/)
// check exit code
.expect(0)
// run and done
.end(done);
});
components.forEach(function(name) {
it('should install ' + name + ' with yeoman install ' + name, function(done) {
console.log();
helpers.run('install ' + name, { redirect: true })
.expect(0)
.end(done);
});
it('should have copied resolved components to app/scripts/vendor', function(done) {
var ctx = this;
bower.list({ map: true })
.on('error', done)
.on('data', function(results) {
ctx.results = results;
var pkg = results[name];
var source = ctx[name] = pkg.source.main;
var vendor = source.replace(/^components/, 'app/scripts/vendor');
fs.stat(vendor, done);
});
});
});
// These tests are failing, and specifically testing out some current issues
// we might have.
/* * /
describe('should not override non "components" files in app/scripts/vendor', function(done) {
['esprima.js', 'hm.js', 'jquery.min.js', 'modernizr.min.js', 'require.js'].forEach(function(file) {
it('like ' + file, function(done) {
fs.stat(path.join('app/scripts/vendor', file), done);
});
});
});
/* */
/* * /
describe('should have updated the RequireJS configuration for paths', function() {
before(function() {
this.main = grunt.file.read('app/scripts/main.js');
});
components.forEach(function(name) {
it('configuration for ' + name + ' is updated', function() {
var source = this[name];
// map the bower resolved package to be within vendor/
var pathname = source.replace(/^components/, 'vendor').replace(path.extname(source), '');
// assert string against lines, to gain diff output
var pathline = this.main.split('\n').filter(function(line) {
return line.indexOf(name + ':') !== -1;
})[0];
var pattern = name + ": '" + pathname + "',";
assert.equal(pathline.trim(), pattern);
});
});
});
/* */
});