test-base.js 939 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* global describe, it, afterEach */
  2. var watch = require('..');
  3. var path = require('path');
  4. var touch = require('./util/touch');
  5. require('should');
  6. function fixtures(glob) {
  7. return path.join(__dirname, 'fixtures', glob);
  8. }
  9. describe('base', function () {
  10. var w;
  11. afterEach(function (done) {
  12. w.on('end', done);
  13. w.close();
  14. });
  15. it('should be determined by glob', function (done) {
  16. w = watch(fixtures('**/*.js'), function (file) {
  17. file.relative.should.eql(path.normalize('folder/index.js'));
  18. file.base.should.eql(fixtures(''));
  19. done();
  20. }).on('ready', touch(fixtures('folder/index.js')));
  21. });
  22. it('should be overridden by option', function (done) {
  23. var explicitBase = fixtures('folder');
  24. w = watch(fixtures('**/*.js'), {base: explicitBase}, function (file) {
  25. file.relative.should.eql('index.js');
  26. file.base.should.eql(explicitBase);
  27. done();
  28. }).on('ready', touch(fixtures('folder/index.js')));
  29. });
  30. });