Skip to content

Commit

Permalink
adds images for tests and example
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmcgregor committed May 15, 2015
1 parent d21a58d commit 67cced0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 14 deletions.
7 changes: 5 additions & 2 deletions example/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@
})
.once('complete', animate)
.once('complete', display)
.load('../packed/test.bin');
.load('packs/pack.bin');

function display(keys) {
keys.forEach(function(name) {
document.body.appendChild(imagepack.getImage(name));
});
}

function animate(sequence) {
function animate(keys) {
var sequence = keys.filter(function(name) {
return name.slice(0, 6) === 'loader';
});
var img = new Image();
document.body.appendChild(img);
var i = 0;
Expand Down
3 changes: 3 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@

<title>imagepack</title>
<style type="text/css">
body {
background: #ddd;
}
h1, img {
display: block;
font-family: sans-serif;
Expand Down
Binary file added example/packs/pack.bin
Binary file not shown.
10 changes: 5 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
var gulp = require('gulp');
var imagepack = require('./');

var filename = 'test';
var filename = 'pack';

gulp.task('pack', function() {
// return gulp.src(['./images/**/*.{gif,jpg,png,webp}'])
return gulp.src(['./images/**/*'])
// return gulp.src(['./example/images/**/*'])
return gulp.src(['./example/images/**/*.{gif,jpg,png,webp}'])
.pipe(imagepack.pack({
name: filename,
verbose: true
}))
.pipe(gulp.dest('./packed'));
.pipe(gulp.dest('./example/packs'));
});

gulp.task('unpack', function() {
return gulp.src(['./packed/' + filename + '.bin'])
return gulp.src(['./example/packs/' + filename + '.bin'])
.pipe(imagepack.unpack({
verbose: true
}))
Expand Down
33 changes: 26 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,27 @@ describe('packer', function() {
stream.on('end', cb);

stream.write(new gutil.File({
path: __dirname + '/images/ecosys-a000.jpg',
contents: fs.readFileSync('./images/ecosys-a000.jpg')
path: __dirname + '/example/images/graff.jpg',
contents: fs.readFileSync('./example/images/graff.jpg')
}));

stream.end();
});

it('should pack png', function (cb) {
var stream = imagepack.pack({
verbose: true
});

stream.once('data', function (file) {
assert(file.contents.length > 0);
});

stream.on('end', cb);

stream.write(new gutil.File({
path: __dirname + '/example/images/loader_b0001.png',
contents: fs.readFileSync('./example/images/loader_b0001.png')
}));

stream.end();
Expand All @@ -40,8 +59,8 @@ describe('packer', function() {
stream.on('end', cb);

stream.write(new gutil.File({
path: __dirname + '/images/ecosys-a000.jpg',
contents: fs.readFileSync('./images/ecosys-a000.jpg')
path: __dirname + '/example/images/graff.jpg',
contents: fs.readFileSync('./example/images/graff.jpg')
}));

stream.end();
Expand All @@ -59,7 +78,7 @@ describe('packer', function() {
});

unpackStream.once('data', function (file) {
assert.strictEqual(path.basename(file.path), 'ecosys-a000.jpg');
assert.strictEqual(path.basename(file.path), 'graff.jpg');
});

unpackStream.on('end', cb);
Expand All @@ -70,8 +89,8 @@ describe('packer', function() {
});

stream.write(new gutil.File({
path: __dirname + '/images/ecosys-a000.jpg',
contents: fs.readFileSync('./images/ecosys-a000.jpg')
path: __dirname + '/example/images/graff.jpg',
contents: fs.readFileSync('./example/images/graff.jpg')
}));

stream.end();
Expand Down

0 comments on commit 67cced0

Please sign in to comment.