-
Notifications
You must be signed in to change notification settings - Fork 1
/
rehab_test.coffee
66 lines (48 loc) · 2 KB
/
rehab_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
require 'source-map-support'
Rehab = require '../src/rehab'
describe "rehab", ->
describe "normalizeFilePath", ->
describe "should return a graph", ->
it "normalized file path", ->
#given
files = [["fileA", "fileB"], ["./fileB", "fileC"]]
#when
rehab = new Rehab()
sorted = rehab.normalizeFilename '.', files
#then
sorted.should.eql [["fileA.coffee", "fileB.coffee"], ["fileB.coffee", "fileC.coffee"]]
it "normalized relative file path", ->
#given
files = [["src/model/mode1", "../repo/repo1"], ["src/view/view1", "../model/model1"]]
#when
rehab = new Rehab()
sorted = rehab.normalizeFilename '.', files
#then
sorted.should.eql [["src/model/mode1.coffee", "src/repo/repo1.coffee"], ["src/view/view1.coffee", "src/model/model1.coffee"]]
it "normalized relative file path", ->
#given
files = [["src/model/mode1", "../repo/repo1"], ["src/view/view1", "../model/model1"]]
#when
rehab = new Rehab()
sorted = rehab.normalizeFilename './project/', files
#then
sorted.should.eql [["project/src/model/mode1.coffee", "project/src/repo/repo1.coffee"], ["project/src/view/view1.coffee", "project/src/model/model1.coffee"]]
describe "processDependencyList", ->
describe "should return a ordered list when", ->
it "sequence dependence", ->
#given
files = [["fileA", "fileB"], ["fileB", "fileC"], ["fileC", "fileD"]]
#when
rehab = new Rehab()
sorted = rehab.processDependencyList files
#then
sorted.should.eql [ 'fileA', 'fileB', 'fileC', 'fileD' ]
it "only one dependence informed", ->
REQ_MAIN_NODE = "__MAIN__"
#given
files = [[REQ_MAIN_NODE, "fileB"], ["fileB", "fileC"], [REQ_MAIN_NODE, "fileC"]]
#when
rehab = new Rehab()
sorted = rehab.processDependencyList files
#then
sorted.should.eql [ 'fileB', 'fileC' ]