-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.coffee
92 lines (74 loc) · 2.9 KB
/
test.coffee
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
path = require 'path'
Roots = require 'roots'
fs = require 'fs'
compile_fixture = (fixture_name, done) ->
@public = path.join(_path, fixture_name, 'public')
h.project.compile(Roots, fixture_name).then -> done()
before (done) ->
h.project.remove_folders('**/public')
h.project.install_dependencies('*', done)
describe 'roots compile with inline-css', ->
before (done) -> compile_fixture.call(@, 'basic', done)
it 'compiles basic project', (done) ->
p = path.join(@public, 'index.html')
p.should.be.a.file()
fs.existsSync(p).should.be.ok
contents = fs.readFileSync(p, 'utf8')
contents.should.match /<p style="color: red; text-decoration: underline;">/
done()
describe 'roots multipass with inline-css', ->
before (done) ->
compile_fixture.call(@, 'multipass', done)
it 'compiles basic project', (done) ->
p = path.join(@public, 'index.html')
p.should.be.a.file()
fs.existsSync(p).should.be.ok
contents = fs.readFileSync(p, 'utf8')
contents.should.match(
/<p style="color: red; text-decoration: underline;">bar<\/p>/
)
done()
describe 'inline-css tested with options', ->
before (done) -> compile_fixture.call(@, 'options', done)
it 'compiles project with options', (done) ->
p = path.join(@public, 'index.html')
p.should.be.a.file()
fs.existsSync(p).should.be.ok
contents = fs.readFileSync(p, 'utf8')
contents.should.match(
/<body style="background: blue;"><p style="text-decoration: underline;">/
)
done()
describe 'inline-css tested with the file option', ->
before (done) -> compile_fixture.call(@, 'file_option', done)
it 'compiles project with the file option', (done) ->
test = path.join(@public,'test.html')
test.should.be.a.file()
fs.existsSync(test).should.be.ok
contents = fs.readFileSync(test, 'utf8')
contents.should.match /color: red; text-decoration: underline;/
done()
it 'compiles other files that should be matched',(done) ->
kittens = path.join(@public,'kittens.html')
kittens.should.be.a.file()
fs.existsSync(kittens).should.be.ok
contents = fs.readFileSync(kittens, 'utf8')
contents.should.match /color: red; text-decoration: underline;">Kittens/
done()
it 'will not inline files not included', (done) ->
p = path.join(@public,'index.html')
p.should.be.a.file()
fs.existsSync(p).should.be.ok
contents = fs.readFileSync(p, 'utf8')
contents.should.match /{ color: red; }/
done()
describe 'inline-css together with jade + roots-tumblr', ->
before (done) -> compile_fixture.call(@, 'tumblr', done)
it 'compiles the project', (done) ->
test = path.join(@public,'index.html')
test.should.be.a.file()
fs.existsSync(test).should.be.ok
contents = fs.readFileSync(test, 'utf8')
contents.should.match /<p style="color: red; text-decoration: underline;">/
contents.should.match(/<title>Untitled<\/title>/)
done()