<commit_before>module.exports = function() {
    console.log('CSS Steps Loaded');
    this.World = require('../support/world.js');
    var imageTest = require('../support/imagetest'),
        utils = require('../support/css-utils'),
        assert = require('assert'),
        selectors = require('../support/selectors.js');
    var shouldHavePropertyOfValue, windowSizeIs, shouldHavePropertyOfComparatorThanValue, shouldLookTheSameAsBefore;

    /* "<Then> the <element> should have <property> of <value>" */
    // Map the given name to the selector then find that element in the page
    // The measured value of the property should be the one we expect
    shouldHavePropertyOfValue = function(elementName, property, value, callback) {
        var elementSelector = selectors(elementName);
        var message = '"' + elementName + '" should have ' + property + ' of ' + value;
        if (utils.isColor(value)) {
            value = utils.toRgba(value);
        }
        this.getCssProperty(elementSelector, property, function(err, measuredValue) {
            if (err) {
                if (typeof err === "object") {
                    err = err.type + ': ' + err.orgStatusMessage + ': "' + elementSelector + '"';
                }
                // console.error("Hardy :: Failed to get CSS property, ", err);
                // console.error("Hardy :: Could not find element '%s'", elementSelector);
                return callback.fail(err);
            }

            message += ", measured: " + measuredValue;

            measuredValue = utils.normalizeString(measuredValue);

            try {
                assert.equal(measuredValue, value, message);
            } catch (e) {
                return callback.fail(e.message);
            }

            callback();
        });
    };
    this.Then(/^"([^"]*)" should have "([^"]*)" of "([^"]*)"$/, shouldHavePropertyOfValue);

    // "<Given> the window size is <width> by <height>"
    // Set the browser window size to the specified one
    windowSizeIs = function(width, height, callback) {
        width = parseInt(width, 10);
        height = parseInt(height, 10);
        this.setWindowSize(width, height, callback);
    };
    this.Given(/^the window size is "([^"]*)" by "([^"]*)"$/, windowSizeIs);

    //    "<Then> the <element> should have <property> of <comparator> than <value>"
    // Map the given name to the selector then find that element in the page
    // The measured value of the property should be more than or less than the one provided
    shouldHavePropertyOfComparatorThanValue = function(elementName, property, comparator, value, callback) {
        var elementSelector = selectors(elementName);


        var message = elementName + ' should have ' + property + ' of ' + comparator + ' than ' + value;

        value = parseInt(value, 10);

        // Special case for width and height which, if unset, default to auto
        // A few other things do as well but these are the most common.<commit_msg>A whole new step for exact offset position measurement.<commit_after>module.exports = function() {
    console.log('CSS Steps Loaded');
    this.World = require('../support/world.js');
    var imageTest = require('../support/imagetest'),
        utils = require('../support/css-utils'),
        assert = require('assert'),
        selectors = require('../support/selectors.js');
    var shouldHavePropertyOfValue, shouldHaveOffsetPropertyOfValue, shouldHavePropertyOfComparatorThanValue, shouldLookTheSameAsBefore;

    /* "<Then> the <element> should have <property> of <value>" */
    // Map the given name to the selector then find that element in the page
    // The measured value of the property should be the one we expect
    shouldHavePropertyOfValue = function(elementName, property, value, callback) {
        var elementSelector = selectors(elementName);
        var message = '"' + elementName + '" should have ' + property + ' of ' + value;
        if (utils.isColor(value)) {
            value = utils.toRgba(value);
        }
        this.getCssProperty(elementSelector, property, function(err, measuredValue) {
            if (err) {
                if (typeof err === "object") {
                    err = err.type + ': ' + err.orgStatusMessage + ': "' + elementSelector + '"';
                }
                // console.error("Hardy :: Failed to get CSS property, ", err);
                // console.error("Hardy :: Could not find element '%s'", elementSelector);
                return callback.fail(err);
            }

            message += ", measured: " + measuredValue;

            measuredValue = utils.normalizeString(measuredValue);

            try {
                assert.equal(measuredValue, value, message);
            } catch (e) {
                return callback.fail(e.message);
            }

            callback();
        });
    };
    this.Then(/^"([^"]*)" should have "([^"]*)" of "([^"]*)"$/, shouldHavePropertyOfValue);

    /* "<Then> <element> should have offset <top|left> of <value>" */
    // Calculates the exact offset of the element regardless of the specified styles
    shouldHaveOffsetPropertyOfValue = function(elementName, property, value, callback) {
        var elementSelector = selectors(elementName),
            message = '"' + elementName + '" should have offset ' + property + ' of ' + value,
            index = property==='top'?'y':'x',
            value = value.replace(/px/,'');

        this.getLocation(elementSelector, function(err, measuredValue) {
            if (err) {
                if (typeof err === "object") {
                    err = JSON.stringify(err);
                }
                console.error("Hardy :: Failed to execute script, ", err);
                return callback.fail(err);
            }

            message += ", measured: " + measuredValue[index];

            try {
                assert.equal(measuredValue[index], value, message);
            } catch (e) {
                return callback.fail(e.message);
            }

            callback();
        });
    };
    this.Then(/^"([^"]*)" should have offset "([^"]*)" of "([^"]*)"$/, shouldHaveOffsetPropertyOfValue);

    //    "<Then> the <element> should have <property> of <comparator> than <value>"
    // Map the given name to the selector then find that element in the page
    // The measured value of the property should be more than or less than the one provided
    shouldHavePropertyOfComparatorThanValue = function(elementName, property, comparator, value, callback) {
        var elementSelector = selectors(elementName);


        var message = elementName + ' should have ' + property + ' of ' + comparator + ' than ' + value;

        value = parseInt(value, 10);

        // Special case for width and height which, if unset, default to auto
        // A few other things do as well but these are the most common.
{'fraction_non_alphanumeric': 0.12900420350775474, 'fraction_numerical': 0.0011595883461371214, 'mean_word_length': 2.325301204819277, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '3723618', 'n_tokens_mistral': 1814, 'n_tokens_neox': 1741, 'n_words': 542}