8
0

tasks.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /**
  2. * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md.
  4. */
  5. /* global describe, it, sinon */
  6. 'use strict';
  7. const tasks = require( '../../tasks/test/tasks' )();
  8. const buildUtils = require( '../../tasks/build/utils' );
  9. const devTools = require( '../../tasks/dev/utils/tools' );
  10. const Vinyl = require( 'vinyl' );
  11. describe( 'test-node', () => {
  12. describe( 'skipManual', () => {
  13. it( 'should skip manual tests', ( done ) => {
  14. const stream = tasks.skipManual();
  15. const spy = sinon.spy();
  16. const stub = sinon.stub( devTools, 'isFile', ( file ) => {
  17. return file == 'file1.md';
  18. } );
  19. const unitTestFile = new Vinyl( {
  20. cwd: './',
  21. path: 'file2.js',
  22. contents: null
  23. } );
  24. const manualTestFile = new Vinyl( {
  25. cwd: './',
  26. path: 'file1.js',
  27. contents: null
  28. } );
  29. stream.pipe( buildUtils.noop( spy ) );
  30. stream.once( 'finish', () => {
  31. sinon.assert.calledOnce( spy );
  32. sinon.assert.calledWithExactly( spy, unitTestFile );
  33. done();
  34. } );
  35. stream.write( manualTestFile );
  36. stream.write( unitTestFile );
  37. stream.end();
  38. stub.restore();
  39. } );
  40. } );
  41. describe( 'skipIgnored', () => {
  42. it( 'should skip files marked to ignore', ( done ) => {
  43. const stream = tasks.skipIgnored();
  44. const spy = sinon.spy();
  45. const unitTestFile = new Vinyl( {
  46. cwd: './',
  47. path: 'file2.js',
  48. contents: new Buffer( '' )
  49. } );
  50. const manualTestFile = new Vinyl( {
  51. cwd: './',
  52. path: 'file1.js',
  53. contents: new Buffer( '/* bender-tags: tag, browser-only */' )
  54. } );
  55. const noop = buildUtils.noop( spy );
  56. noop.once( 'finish', () => {
  57. sinon.assert.calledOnce( spy );
  58. sinon.assert.calledWithExactly( spy, unitTestFile );
  59. done();
  60. } );
  61. stream.pipe( noop );
  62. stream.write( manualTestFile );
  63. stream.write( unitTestFile );
  64. stream.end();
  65. } );
  66. } );
  67. } );