-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.coffee
52 lines (39 loc) · 1.68 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
path = require 'path'
fs = require 'fs'
should = require 'should'
Roots = require 'roots'
_path = path.join(__dirname, 'fixtures')
RootsUtil = require 'roots-util'
h = new RootsUtil.Helpers(base: _path)
# setup, teardown, and utils
compile_fixture = (fixture_name, done) ->
@public = path.join(fixture_name, 'public')
h.project.compile(Roots, fixture_name).then(done)
before (done) ->
h.project.install_dependencies('*', done)
after ->
h.project.remove_folders('**/public')
# tests
describe 'basic setup', ->
before (done) -> compile_fixture.call(@, 'basic', -> done())
it 'compiles basic project', ->
p = path.join(@public, 'index.html')
h.file.exists(p).should.be.ok
it 'compiles the headers config file correctly', ->
compiled = path.join(@public, '_headers')
expected = path.join(@public, 'expected', '_headers')
h.file.matches_file(compiled, expected).should.be.true
it 'compiles the redirects config file correctly', ->
compiled = path.join(@public, '_redirects')
expected = path.join(@public, 'expected', '_redirects')
h.file.matches_file(compiled, expected).should.be.true
describe 'promises support', ->
before (done) -> compile_fixture.call(@, 'promises', -> done())
it 'compiles the headers config file using promises grep', ->
compiled = path.join(@public, '_headers')
expected = path.join(@public, 'expected', '_headers')
h.file.matches_file(compiled, expected).should.be.true
it 'compiles the redirects config file using promises', ->
compiled = path.join(@public, '_redirects')
expected = path.join(@public, 'expected', '_redirects')
h.file.matches_file(compiled, expected).should.be.true