UNPKG

1.93 kBJavaScriptView Raw
1var gulp = require('gulp'),
2 assert = require("assert"),
3 runSequence = require('run-sequence'),
4 fs = require('fs'),
5 Path = require('path'),
6 basset = require('../index.js');
7
8
9var buildDir = "public/builds";
10
11describe("Basset", function() {
12
13 describe("build", function() {
14
15 beforeEach(function() {
16 var manifest = Path.join(buildDir, 'manifest.json')
17 if (fs.existsSync(manifest)) {
18 fs.unlinkSync(manifest);
19 }
20
21 basset.scan(require("./collections.json"));
22 })
23
24 it("should build manifest.json", function(done) {
25
26 runSequence('build:main', function() {
27 var collectionFile = Path.join(buildDir, 'manifest.json')
28
29 assert(fs.existsSync(collectionFile));
30
31 assert.equal(fs.readFileSync(collectionFile)+"", "{\n\
32 \"main\": {\n\
33 \"local\": {\n\
34 \"js\": {\n\
35 \"main/main.js\": \"main/main/main-c4238edcaf585158686a3ecf88f610d5d0246773.js\"\n\
36 },\n\
37 \"css\": {}\n\
38 }\n\
39 }\n\
40}");
41 done()
42 });
43 })
44
45 it("builds files with hashed names", function() {
46 var builtFile = Path.join(buildDir, "main/main/main-c4238edcaf585158686a3ecf88f610d5d0246773.js");
47
48 assert(fs.existsSync(builtFile));
49 })
50
51 it('ads angular dependency injection', function(done) {
52
53 basset.scan({
54 "collections": {
55 "ng": {
56 "js": [
57 "ng.js"
58 ]
59 }
60 }
61 });
62
63 runSequence('production', 'build:ng', function() {
64 var contents = fs.readFileSync(Path.join(buildDir, "ng-55b41af3002e11e864a74175e312a20217c6eaf4.js"));
65
66 assert.equal('var app=angular.module("ang",[]);app.controller("Controller",["$scope",function(){console.log("works")}]),app.config(["$rootScope",function(){console.log("works")}]),app.run(["$rootScope",function(){console.log("works")}]);', contents.toString());
67
68 done()
69 });
70 })
71
72 });
73});