<commit_before>var expect = require('expect.js'),
    Property = require('../../lib/index.js').Property;

/* global describe, it */
describe('Property', function () {
    describe('sanity', function () {
        it('initializes successfully', function () {
            expect((new Property()) instanceof Property).to.be.ok();
        });
        it('allows a description to be set', function () {
            var prop = new Property();
            expect(prop.describe).to.be.a('function');
            expect(prop.describe.bind(prop)).withArgs('Hello Postman').to.not.throwException();
            expect(prop.description).to.be.ok();
            expect(prop.description.toString()).to.be('Hello Postman');
            expect(prop.description.type).to.be('text/plain');
        });
    });

    describe('variable resolution', function () {
        it('must resolve variables accurately', function () {
            var unresolvedRequest = {
                    method: 'POST',
                    url: '{{host}}:{{port}}/{{path}}',
                    header: [{ key: '{{headerName}}', value: 'application/json' }],
                    body: {
                        mode: 'urlencoded',
                        urlencoded: [{ key: '{{greeting}}', value: '{{greeting_value}}' }]
                    }
                },
                expectedResolution = {
                    method: 'POST',<commit_msg>test(unit): Added Property unit tests :white_check_mark:<commit_after>var expect = require('expect.js'),
    sdk = require('../../lib/index.js'),
    VariableList = sdk.VariableList,
    Property = sdk.Property;

/* global describe, it */
describe('Property', function () {
    describe('sanity', function () {
        it('initializes successfully', function () {
            expect((new Property()) instanceof Property).to.be.ok();
        });
        it('allows a description to be set', function () {
            var prop = new Property();
            expect(prop.describe).to.be.a('function');
            expect(prop.describe.bind(prop)).withArgs('Hello Postman').to.not.throwException();
            expect(prop.description).to.be.ok();
            expect(prop.description.toString()).to.be('Hello Postman');
            expect(prop.description.type).to.be('text/plain');
        });
    });

    describe('.describe', function () {
        it('should use an existing Description instance when available', function () {
            var property = new Property({ description: 'Sample description' });

            property.describe('New description');
            expect(property.description).to.eql({ content: 'New description', type: 'text/plain' });
        });
    });

    describe('.toObjectResolved', function () {
        it('should throw an error for invalid arguments', function () {
            var property = new Property();

            expect(property.toObjectResolved.bind(property)).to.throwError();
        });

        it('should resolve properties correctly', function () {
            var property = new Property(),
                parent = new Property();

            parent.variables = new VariableList();
            property.variables = new VariableList({}, [{ key: 'alpha', value: 'foo' }, { key: 'beta', value: 'bar' }]);

            property.setParent(parent);
            expect(property.toObjectResolved()).to.eql({
                variable: [
                    { type: 'any', value: 'foo', key: 'alpha' },
                    { type: 'any', value: 'bar', key: 'beta' }
                ]
            });
        });
    });

    describe('.replaceSubstitutions', function () {
        it('should bail out if a non-string argument is passed', function () {
            expect(Property.replaceSubstitutions(['random'])).to.eql(['random']);
        });
    });

    describe('.replaceSubstitutionsIn', function () {
        it('should bail out if a non-object argument is passed', function () {
            expect(Property.replaceSubstitutionsIn('random')).to.be('random');
        });
    });

    describe('variable resolution', function () {
        it('must resolve variables accurately', function () {
            var unresolvedRequest = {
                    method: 'POST',
                    url: '{{host}}:{{port}}/{{path}}',
                    header: [{ key: '{{headerName}}', value: 'application/json' }],
                    body: {
                        mode: 'urlencoded',
                        urlencoded: [{ key: '{{greeting}}', value: '{{greeting_value}}' }]
                    }
                },
                expectedResolution = {
                    method: 'POST',
{'fraction_non_alphanumeric': 0.16077586206896552, 'fraction_numerical': 0.0, 'mean_word_length': 1.9961265332472562, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1177323', 'n_tokens_mistral': 1183, 'n_tokens_neox': 1126, 'n_words': 250}