import {Image, load, getHash, refreshTmpDir, tmpDir, getSquare} from '../common';

describe('save to disk', function () {

    beforeEach(refreshTmpDir);
    afterEach(refreshTmpDir);

    it('load then save', function () {
        return load('format/rgba32.png').then(function (img) {
            let sha = getHash(img);
            return img.save(tmpDir + '/img1.png').then(function () {
                // reload the new file to check that the image is identical
                return Image.load(tmpDir + '/img1.png').then(function (img) {
                    getHash(img).should.equal(sha);
                });
            });
        });
    });

    it.skip('load then save (jpg)', function () {
        return load('format/rgba32.png').then(function (img) {
            return img.save(tmpDir + '/img1.jpg', {format: 'jpeg'});
        });
    });

    it.skip('new then save', function () {
        let img = getSquare();
        return img.save(tmpDir + '/img2.png');
    });

});

@@ -240,35 +240,34 @@
 load('format/rgb
-a3
 2
+4
 .png').then(func
@@ -299,25 +299,32 @@
 let 
-sha = getHash(img
+dataURL = img.toDataURL(
 );%0A 
@@ -569,19 +569,22 @@
     
-getHash(img
+img.toDataURL(
 ).sh
@@ -598,11 +598,15 @@
 ual(
-sha
+dataURL
 );%0A 

use image without alpha for load then save