produce.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Created by Herby on 31. 5. 2014.
  3. */
  4. var builder = require('../lib/config-builder'),
  5. assert = require('assert'),
  6. path = require('path');
  7. function fixture(fixturePath) {
  8. return path.join(__dirname, fixturePath);
  9. }
  10. describe('#produceConfigObject merging', function () {
  11. it('should include local.amd.json if none other is present', function (done) {
  12. builder.produceConfigObject(fixture('single-local'), function (err, result) {
  13. assert.ifError(err);
  14. assert.deepEqual(result, {
  15. config: {foo: {foo: "bar"}}
  16. });
  17. done();
  18. });
  19. });
  20. it('should fail if foo.amd.json is present and there is no foo', function (done) {
  21. builder.produceConfigObject(fixture('local-and-missing'), function (err, result) {
  22. assert.ok(err);
  23. done();
  24. });
  25. });
  26. it('should fail if there is no applicable file', function (done) {
  27. builder.produceConfigObject(fixture('nothing'), function (err, result) {
  28. assert.ok(err);
  29. done();
  30. });
  31. });
  32. it('should include deep local.amd.json if none other is present', function (done) {
  33. builder.produceConfigObject(fixture('single-deep-local'), function (err, result) {
  34. assert.ifError(err);
  35. assert.deepEqual(result, {
  36. config: {fooDeep: {foo: "bar"}}
  37. });
  38. done();
  39. });
  40. });
  41. it('should include both local.amd.json if root and deep are present', function (done) {
  42. builder.produceConfigObject(fixture('two-locals'), function (err, result) {
  43. assert.ifError(err);
  44. assert.deepEqual(result, {
  45. config: {foo: {foo: "bar"}, fooDeep: {foo: "bar"}}
  46. });
  47. done();
  48. });
  49. });
  50. it('should include {root,deep}/local.amd.json first and {foo,bar}.amd.json afterwards given {foo,bar} dir is present', function (done) {
  51. builder.produceConfigObject(fixture('two-locals-two-others'), function (err, result) {
  52. assert.ifError(err);
  53. assert.deepEqual(result, {
  54. config: {a:2, b:2, c:2, d:2, e:1, f:1}
  55. });
  56. done();
  57. });
  58. });
  59. });