Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

test.coffee 1.7KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. DepGraph = require('../lib/dep-graph.js')
  2. depGraph = new DepGraph
  3. exports['Direct dependencies are chained in original order'] = (test) ->
  4. depGraph.add '0', '1'
  5. depGraph.add '0', '2'
  6. depGraph.add '0', '3'
  7. test.deepEqual depGraph.getChain('0'), ['1', '2', '3']
  8. test.done()
  9. exports['Indirect dependencies are chained before their dependents'] = (test) ->
  10. depGraph.add '2', 'A'
  11. depGraph.add '2', 'B'
  12. test.deepEqual depGraph.getChain('0'), ['1', 'A', 'B', '2', '3']
  13. test.done()
  14. exports['getChain can safely be called for unknown resources'] = (test) ->
  15. test.doesNotThrow -> depGraph.getChain('Z')
  16. test.deepEqual depGraph.getChain('Z'), []
  17. test.done()
  18. exports['Cyclic dependencies are detected'] = (test) ->
  19. depGraph.add 'yin', 'yang'
  20. depGraph.add 'yang', 'yin'
  21. test.throws -> depGraph.getChain 'yin'
  22. test.throws -> depGraph.getChain 'yang'
  23. test.done()
  24. exports['Arc direction is taken into account (issue #1)'] = (test) ->
  25. depGraph.add 'MAIN', 'One'
  26. depGraph.add 'MAIN', 'Three'
  27. depGraph.add 'One', 'Two'
  28. depGraph.add 'Two', 'Three'
  29. test.deepEqual depGraph.getChain('MAIN'), ['Three', 'Two', 'One']
  30. test.done()
  31. exports['Dependency ordering is consistent (issue #2)'] = (test) ->
  32. depGraph.add 'Head', 'Neck'
  33. depGraph.add 'Head', 'Heart'
  34. depGraph.add 'Heart', 'Neck'
  35. depGraph.add 'Neck', 'Shoulders'
  36. test.deepEqual depGraph.getChain('Head'), ['Shoulders', 'Neck', 'Heart']
  37. test.done()
  38. exports['Nodes with same dependencies do not depend on each other (issue #6)'] = (test) ->
  39. depGraph.add 'Java', 'JVM'
  40. depGraph.add 'JRuby', 'JVM'
  41. test.deepEqual depGraph.getChain('Java'), ['JVM']
  42. test.deepEqual depGraph.getChain('JRuby'), ['JVM']
  43. test.done()