Ejemplo n.º 1
0
 it('should return a stream with one layout object', function (done) {
   var count = 0;
   opts.prefix = 'test';
   os.fromArray([{
       base: '/mock/fixtures/',
       height: 100,
       width: 100
     }, {
       base: '/mock/fixtures2/',
       height: 100,
       width: 100
     }])
     .pipe(layout(opts))
     .pipe(spy(function (res) {
       var l = res.layout;
       l.items.length.should.equal(2);
       l.should.have.property('width', 108);
       l.should.have.property('height', 216);
       count++;
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(1);
       done();
     });
 });
Ejemplo n.º 2
0
 it('should process layouts', function (done) {
   var count = 0;
   opts.processor = {
     process: function () {
       count++;
       return Promise.resolve('style');
     },
     isBeautifyable: function () {
       return false;
     },
     extension: function () {
       return 'css';
     }
   };
   os.fromArray([layouts])
     .pipe(style(opts))
     .pipe(spy(function (res) {
       if (res.style) {
         res.style.toString().should.equal('style');
       }
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(1);
       done();
     });
 });
Ejemplo n.º 3
0
 it('should return a stream with two sprite objects and the appropriate nameing of sprites', function (done) {
   var count = 0;
   opts.dimension = [{ratio: 1, dpi: 72}, {ratio: 2, dpi: 192}];
   mockLayouts.name = 'first';
   var l2 = layout('top-down');
   l2.addItem({height: 50, width: 50, meta: {}});
   var mockLayouts2 = {
     name: 'second',
     layout: mockLayout.export()
   };
   os.fromArray([mockLayouts, mockLayouts2])
     .pipe(sprite(opts))
     .pipe(spy(function (res) {
       res.sprites.length.should.equal(2);
       if (count === 0) {
         res.should.have.deep.property('sprites[0].name', 'sprite-first');
         res.should.have.deep.property('sprites[1].name', 'sprite-first@2x');
       }
       if (count === 1) {
         res.should.have.deep.property('sprites[0].name', 'sprite-second');
         res.should.have.deep.property('sprites[1].name', 'sprite-second@2x');
       }
       count++;
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(2);
       done();
     });
 });
Ejemplo n.º 4
0
 it('should return a stream of vinyl objects', function (done) {
   var count = 0;
   os.fromArray([sprites, style])
     .pipe(toVinyl(opts))
     .pipe(spy(function (res) {
       count++;
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(3);
       done();
     });
 });
Ejemplo n.º 5
0
 it('should return a stream with one style object', function (done) {
   var count = 0;
   os.fromArray([layouts])
     .pipe(style(opts))
     .pipe(spy(function (res) {
       if (res.style) {
         res.style.should.match(/.icon.*/);
         count++;
       }
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(1);
       done();
     });
 });
Ejemplo n.º 6
0
 it('should return a stream with one sprite object', function (done) {
   var count = 0;
   os.fromArray([mockLayouts])
     .pipe(sprite(opts))
     .pipe(spy(function (res) {
       res.sprites.length.should.equal(1);
       res.should.have.deep.property('sprites[0].name', 'sprite');
       res.sprites[0].url.should.not.match(/data\:image\/png;base64.*/);
       count++;
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(1);
       done();
     });
 });
Ejemplo n.º 7
0
 it('should return a url with cachebuster', function (done) {
   var count = 0;
   opts.cssPath = 'http://www.example.com/assets/';
   opts.cachebuster = true;
   os.fromArray([mockLayouts])
     .pipe(sprite(opts))
     .pipe(spy(function (res) {
       res.sprites[0].url.should.include('http://www.example.com/assets/sprite.png?');
       count++;
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(1);
       done();
     });
 });
Ejemplo n.º 8
0
 it('should load template and return a stream with one style object', function (done) {
   var count = 0;
   opts.template = '/test/template/template.hbs';
   os.fromArray([layouts])
     .pipe(style(opts))
     .pipe(spy(function (res) {
       if (res.style) {
         res.style.should.match(/.testClass.*/);
         count++;
       }
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(1);
       done();
     });
 });
Ejemplo n.º 9
0
 it('should return a stream with two sprite objects', function (done) {
   var count = 0;
   opts.dimension = [{ratio: 1, dpi: 72}, {ratio: 2, dpi: 192}];
   os.fromArray([mockLayouts])
     .pipe(sprite(opts))
     .pipe(spy(function (res) {
       res.sprites.length.should.equal(2);
       res.should.have.deep.property('sprites[0].dpi', null);
       res.should.have.deep.property('sprites[1].dpi', 192);
       res.should.have.deep.property('sprites[1].name', 'sprite@2x');
       count++;
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(1);
       done();
     });
 });
Ejemplo n.º 10
0
  it('should return a stream of vinyl objects and append file extension to style if not provided', function (done) {
    var count = 0;
    var cssCount = 0;
    opts.style = 'style';

    os.fromArray([sprites, style])
      .pipe(toVinyl(opts))
      .pipe(spy(function (res) {
        if (res.path === 'test/out/style.css') {
          cssCount++;
        }
        count++;
      }))
      .on('data', noop)
      .on('finish', function () {
        count.should.equal(3);
        cssCount.should.equal(1);
        done();
      });
  });
Ejemplo n.º 11
0
			gulp.task(taskName, function() {
				var processor;

				switch(type) {
					case "jade":
						processor = jade(/*{locals: require("./templateUtil")}*/);
						break;
					case "sass":
						processor = sass();
						break;
				}

				return gulp.src(subTask.source, {base: subTask.base})
					.pipe(plumber())
					.pipe(cache(taskName))
					.pipe(processor.on('error', gutil.log))
					.pipe(spy.obj(namedLog(taskName)))
					.pipe(remember(taskName))
					.pipe(gulp.dest(subTask.destination));
			});
Ejemplo n.º 12
0
 it('should css escaped sprite urls', function (done) {
   layouts.sprites.push({
     name: 'sprite@3x',
     url: '../images/tes"te/sprite@3x.png',
     type: 'png',
     dpi: 288,
     ratio: 3,
     width: 50,
     height: 300
   });
   os.fromArray([layouts])
     .pipe(style(opts))
     .pipe(spy(function (res) {
       if (res.style) {
         res.style.toString().should.include('tes%22te');
       }
     }))
     .on('data', noop)
     .on('finish', function () {
       done();
     });
 });
Ejemplo n.º 13
0
parsing.test('streaming', function (t) {
  
  var blockNum = 0;
  
  fs.createReadStream(TEST1_FILE_PATH)
    .pipe(split())
    .pipe(parser())
    .pipe(spy.obj(function (line) {
      
      t.ok(typeof line === 'object', 'type: ' + line.type);
      
      if (line.type === 'block') {
        blockNum += 1;
      }
    }))
    .pipe(concat({object: true}, function (lines) {
      
      t.equal(blockNum, 2, 'number of blocks');
      
      t.end();
    }));
});
Ejemplo n.º 14
0
 it('should return a stream with two layout objects, when folder splitting is activted', function (done) {
   var count = 0;
   opts.split = true;
   opts.orientation = 'left-right';
   require('object-stream').fromArray([{
       base: '/mock/fixtures/',
       height: 100,
       width: 100
     }, {
       base: '/mock/fixtures2/',
       height: 100,
       width: 100
     }])
     .pipe(layout(opts))
     .pipe(spy(function (res) {
       count++;
     }))
     .on('data', noop)
     .on('finish', function () {
       count.should.equal(2);
       done();
     });
 });
Ejemplo n.º 15
0
        .pipe(gulp.dest(buildDirectory))
        .pipe(cloneSink.tap())
        .pipe(plugins.gzip())
        .pipe(gulp.dest(buildDirectory));
    },

    assetsHtml(done) {
      const watch = isDevelopment();
      const {buildDirectory, htmlBuildDirectory = buildDirectory} = Assets.installOptions;
      let once = false;
      Assets.html({watch})
        .pipe(gulp.dest(htmlBuildDirectory))
        .pipe(spy.obj(function(chunk) {
          if (once) return;
          if (chunk.path.match(/index\.html/)) {
            once = true;
            done();
          }
        }));
    },

    assetsServer: require('./assets_server'),

    assetsConfig() {
      Assets.config().pipe(gulp.dest(Assets.installOptions.buildDirectory));
    }
  }
};

module.exports = Assets;