main.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var replaceExt = require('../');
  2. var path = require('path');
  3. var should = require('should');
  4. require('mocha');
  5. describe('replace-ext', function() {
  6. it('should return a valid replaced extension on nested', function(done) {
  7. var fname = path.join(__dirname, './fixtures/test.coffee');
  8. var expected = path.join(__dirname, './fixtures/test.js');
  9. var nu = replaceExt(fname, '.js');
  10. should.exist(nu);
  11. nu.should.equal(expected);
  12. done();
  13. });
  14. it('should return a valid replaced extension on flat', function(done) {
  15. var fname = 'test.coffee';
  16. var expected = 'test.js';
  17. var nu = replaceExt(fname, '.js');
  18. should.exist(nu);
  19. nu.should.equal(expected);
  20. done();
  21. });
  22. it('should not return a valid replaced extension on empty string', function(done) {
  23. var fname = '';
  24. var expected = '';
  25. var nu = replaceExt(fname, '.js');
  26. should.exist(nu);
  27. nu.should.equal(expected);
  28. done();
  29. });
  30. it('should return a valid removed extension on nested', function(done) {
  31. var fname = path.join(__dirname, './fixtures/test.coffee');
  32. var expected = path.join(__dirname, './fixtures/test');
  33. var nu = replaceExt(fname, '');
  34. should.exist(nu);
  35. nu.should.equal(expected);
  36. done();
  37. });
  38. it('should return a valid added extension on nested', function(done) {
  39. var fname = path.join(__dirname, './fixtures/test');
  40. var expected = path.join(__dirname, './fixtures/test.js');
  41. var nu = replaceExt(fname, '.js');
  42. should.exist(nu);
  43. nu.should.equal(expected);
  44. done();
  45. });
  46. });