<commit_before>/*global describe, it*/
var expect = require('../unexpected-with-plugins'),
    // sinon = require('sinon'),
    AssetGraph = require('../../lib');

// var rawSrc = new Buffer('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=', 'base64');

describe('assets/Image', function () {
    describe('fileName getter and setter', function () {
        it('should set the fileName based on constructor configuration', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            expect(img._fileName, 'to be', 'foo.png');
        });

        it('should get the fileName set in constructor configuration', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            expect(img.fileName, 'to be', 'foo.png');
        });

        it('should set the fileName correctly', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            img.fileName = 'bar.png';

            expect(img.fileName, 'to be', 'bar.png');
        });
    });

    describe('devicePixelRatio', function () {
        it('should have a default device pixel ratio of 1', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            expect(img.fileName, 'to be', 'foo.png');
            expect(img.devicePixelRatio, 'to be', 1);
        });

        it('should set device pixel ratio via constructor options', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png',
                devicePixelRatio: 2
            });

            expect(img.fileName, 'to be', 'foo.png');
            expect(img.devicePixelRatio, 'to be', 2);
        });

        it('should set device pixel ratio as a side effect of fileName via constructor options', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo@3x.png'
            });

            expect(img.fileName, 'to be', 'foo@3x.png');
            expect(img.devicePixelRatio, 'to be', 3);
        });

        it('should be able to set device pixel ratio via setter', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            img.devicePixelRatio = 2;

            expect(img.fileName, 'to be', 'foo.png');
            expect(img.devicePixelRatio, 'to be', 2);
        });

        it('should update device pixel ratio when settign fileName', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'<commit_msg>Test that changes in filename only affects device pixel ratio if the special syntax is part of the new name<commit_after>/*global describe, it*/
var expect = require('../unexpected-with-plugins'),
    // sinon = require('sinon'),
    AssetGraph = require('../../lib');

// var rawSrc = new Buffer('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=', 'base64');

describe('assets/Image', function () {
    describe('fileName getter and setter', function () {
        it('should set the fileName based on constructor configuration', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            expect(img._fileName, 'to be', 'foo.png');
        });

        it('should get the fileName set in constructor configuration', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            expect(img.fileName, 'to be', 'foo.png');
        });

        it('should set the fileName correctly', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            img.fileName = 'bar.png';

            expect(img.fileName, 'to be', 'bar.png');
        });
    });

    describe('devicePixelRatio', function () {
        it('should have a default device pixel ratio of 1', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            expect(img.fileName, 'to be', 'foo.png');
            expect(img.devicePixelRatio, 'to be', 1);
        });

        it('should set device pixel ratio via constructor options', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png',
                devicePixelRatio: 2
            });

            expect(img.fileName, 'to be', 'foo.png');
            expect(img.devicePixelRatio, 'to be', 2);
        });

        it('should set device pixel ratio as a side effect of fileName via constructor options', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo@3x.png'
            });

            expect(img.fileName, 'to be', 'foo@3x.png');
            expect(img.devicePixelRatio, 'to be', 3);
        });

        it('should be able to set device pixel ratio via setter', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
            });

            img.devicePixelRatio = 2;

            expect(img.fileName, 'to be', 'foo.png');
            expect(img.devicePixelRatio, 'to be', 2);
        });

        it('should keep its device pixel ratio even when a filname changes to no longer contain the ratio', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo@4x.png'
            });

            img.fileName = 'foo.png';

            expect(img.fileName, 'to be', 'foo.png');
            expect(img.devicePixelRatio, 'to be', 4);
        });

        it('should update device pixel ratio when settign fileName', function () {
            var img = new AssetGraph.Image({
                fileName: 'foo.png'
{'fraction_non_alphanumeric': 0.1305531914893617, 'fraction_numerical': 0.006127659574468085, 'mean_word_length': 1.8635477582846003, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 5, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5590815', 'n_tokens_mistral': 1643, 'n_tokens_neox': 1581, 'n_words': 452}