You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.3 KiB

  1. 'use strict';
  2. var grunt = require('grunt');
  3. var path = require('path');
  4. var fs = require('fs');
  5. var helper = require('./helper');
  6. var fixtures = helper.fixtures;
  7. function cleanUp() {
  8. helper.cleanUp([
  9. 'patterns/node_modules'
  10. ]);
  11. }
  12. exports.patterns = {
  13. setUp: function(done) {
  14. cleanUp();
  15. fs.symlinkSync(path.join(__dirname, '../../node_modules'), path.join(fixtures, 'patterns', 'node_modules'));
  16. done();
  17. },
  18. tearDown: function(done) {
  19. cleanUp();
  20. done();
  21. },
  22. negate: function(test) {
  23. test.expect(2);
  24. var cwd = path.resolve(fixtures, 'patterns');
  25. var assertWatch = helper.assertTask('watch', {cwd:cwd});
  26. assertWatch(function() {
  27. grunt.file.write(path.join(cwd, 'lib', 'sub', 'dontedit.js'), 'var dontedit = true;');
  28. setTimeout(function() {
  29. grunt.file.write(path.join(cwd, 'lib', 'edit.js'), 'var edit = true;');
  30. }, 3000);
  31. }, function(result) {
  32. helper.verboseLog(result);
  33. test.ok(result.indexOf('File "lib' + path.sep + 'edit.js" changed') !== -1, 'Watch should have been triggered when edit.js was edited.');
  34. test.ok(result.indexOf('File "lib' + path.sep + 'dontedit.js" changed') === -1, 'Watch should NOT have been triggered when dontedit.js was edited.');
  35. test.done();
  36. });
  37. },
  38. };