UNPKG

4.15 kBtext/coffeescriptView Raw
1path = require 'path'
2fs = require 'fs'
3should = require 'should'
4Roots = require 'roots'
5_path = path.join(__dirname, 'fixtures')
6RootsUtil = require 'roots-util'
7h = new RootsUtil.Helpers(base: _path)
8
9# setup, teardown, and utils
10
11compile_fixture = (fixture_name, done) ->
12 @public = path.join(fixture_name, 'public')
13 h.project.compile(Roots, fixture_name, done)
14
15before (done) ->
16 h.project.install_dependencies('*', done)
17
18after ->
19 h.project.remove_folders('**/public')
20
21# tests
22
23describe 'development', ->
24
25 before (done) -> compile_fixture.call(@, 'development', -> done())
26
27 it 'css function should output a tag for each file', ->
28 p = path.join(@public, 'index.html')
29 h.file.contains(p, 'test.css').should.be.ok
30 h.file.contains(p, 'wow.css').should.be.ok
31
32 it 'files should have correct content', ->
33 p1 = path.join(@public, 'css/test.css')
34 p2 = path.join(@public, 'css/wow.css')
35 h.file.exists(p1).should.be.ok
36 h.file.contains(p1, 'color: #f00;').should.be.ok
37 h.file.exists(p2).should.be.ok
38 h.file.contains(p2, 'background: #008000;').should.be.ok
39
40describe 'concat', ->
41
42 before (done) -> compile_fixture.call(@, 'concat', -> done())
43
44 it 'css function should output a tag for the build file', ->
45 p = path.join(@public, 'index.html')
46 h.file.contains(p, 'build.css').should.be.ok
47
48 it 'build file should have correct content', ->
49 p = path.join(@public, 'css/build.css')
50 h.file.exists(p).should.be.ok
51 h.file.contains(p, 'color: #f00;').should.be.ok
52 h.file.contains(p, 'background: #008000;').should.be.ok
53
54describe 'concat-minify', ->
55
56 before (done) -> compile_fixture.call(@, 'concat-minify', -> done())
57
58 it 'css function should output a tag for the build file', ->
59 p = path.join(@public, 'index.html')
60 h.file.contains(p, 'build.min.css').should.be.ok
61
62 it 'build file should have correct content', ->
63 p = path.join(@public, 'css/build.min.css')
64 h.file.exists(p).should.be.ok
65 h.file.contains(p, '.wow{background:green}').should.be.ok
66 h.file.contains(p, 'p{color:red}').should.be.ok
67
68describe 'hash', ->
69
70 before (done) -> compile_fixture.call(@, 'hash', -> done())
71
72 it 'css function should output a tag for the hashed build file', ->
73 p = path.join(@public, 'index.html')
74 filename = fs.readdirSync(path.join(_path, @public, 'css'))[0]
75 h.file.contains(p, filename).should.be.ok
76
77describe 'manifest', ->
78
79 before (done) -> compile_fixture.call(@, 'manifest', -> done())
80
81 it 'css function should output a tag for each file', ->
82 p = path.join(@public, 'index.html')
83 h.file.contains(p, 'b-strizzle.css').should.be.ok
84 h.file.contains(p, 't-nizzle.css').should.be.ok
85 h.file.contains(p, 'test.css').should.be.ok
86 h.file.contains(p, 'wow.css').should.be.ok
87
88 it 'files should have correct content', ->
89 p1 = path.join(@public, 'css/test.css')
90 p2 = path.join(@public, 'css/wow.css')
91 p3 = path.join(@public, 'css/b-strizzy/b-strizzle.css')
92 p4 = path.join(@public, 'css/b-strizzy/t-nizzle.css')
93 h.file.exists(p1).should.be.ok
94 h.file.contains(p1, "color: #f00").should.be.ok
95 h.file.exists(p2).should.be.ok
96 h.file.contains(p2, 'background: #008000').should.be.ok
97 h.file.exists(p3).should.be.ok
98 h.file.contains(p3, "color: blue").should.be.ok
99 h.file.exists(p4).should.be.ok
100 h.file.contains(p4, 'content: "tizzle wizzle fizzle lizzle"').should.be.ok
101
102 it 'manifest file should be ignored from output', ->
103 h.file.doesnt_exist(path.join(@public, 'css/manifest.yml')).should.be.ok
104
105describe 'concat-manifest', ->
106
107 before (done) -> compile_fixture.call(@, 'concat-manifest', -> done())
108
109 it 'css function should output a tag for the build file', ->
110 p = path.join(@public, 'index.html')
111 h.file.contains(p, 'build.css').should.be.ok
112
113 it 'build file should have correct content', ->
114 p = path.join(@public, 'css/build.css')
115 h.file.exists(p).should.be.ok
116 h.file.contains(p, '.bootstripe {\n color: blue;\n}\nbody:after {\n content: "tizzle wizzle fizzle lizzle"\n}\n.wow {\n background: #008000;\n}\np {\n color: #f00;\n}\n').should.be.ok