tasks.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 Vinyl = require( 'vinyl' );
  8. const tasks = require( '../../tasks/test/tasks' )();
  9. const { build, tools } = require( 'ckeditor5-dev-utils' );
  10. describe( 'test-node', () => {
  11. describe( 'skipManual', () => {
  12. it( 'should skip manual tests', ( done ) => {
  13. const stream = tasks.skipManual();
  14. const spy = sinon.spy();
  15. const stub = sinon.stub( tools, 'isFile', ( file ) => {
  16. return file == 'file1.md';
  17. } );
  18. const unitTestFile = new Vinyl( {
  19. cwd: './',
  20. path: 'file2.js',
  21. contents: null
  22. } );
  23. const manualTestFile = new Vinyl( {
  24. cwd: './',
  25. path: 'file1.js',
  26. contents: null
  27. } );
  28. stream.pipe( build.noop( spy ) );
  29. stream.once( 'finish', () => {
  30. sinon.assert.calledOnce( spy );
  31. sinon.assert.calledWithExactly( spy, unitTestFile );
  32. done();
  33. } );
  34. stream.write( manualTestFile );
  35. stream.write( unitTestFile );
  36. stream.end();
  37. stub.restore();
  38. } );
  39. } );
  40. describe( 'skipIgnored', () => {
  41. it( 'should skip files marked to ignore', ( done ) => {
  42. const stream = tasks.skipIgnored();
  43. const spy = sinon.spy();
  44. const unitTestFile = new Vinyl( {
  45. cwd: './',
  46. path: 'file2.js',
  47. contents: new Buffer( '' )
  48. } );
  49. const manualTestFile = new Vinyl( {
  50. cwd: './',
  51. path: 'file1.js',
  52. contents: new Buffer( '/* bender-tags: tag, browser-only */' )
  53. } );
  54. const noop = build.noop( spy );
  55. noop.once( 'finish', () => {
  56. sinon.assert.calledOnce( spy );
  57. sinon.assert.calledWithExactly( spy, unitTestFile );
  58. done();
  59. } );
  60. stream.pipe( noop );
  61. stream.write( manualTestFile );
  62. stream.write( unitTestFile );
  63. stream.end();
  64. } );
  65. } );
  66. } );