Sha256: 6b056f07e095c7893c9727450666c21f98216ba2acae4cc4b203961f5763133d

Contents?: true

Size: 1.64 KB

Versions: 70

Compression:

Stored size: 1.64 KB

Contents

describe('Filter:keyValueToString', function() {
    var keyValues, keyValueFilter;

    beforeEach(module('Bastion.components.formatters'));

    beforeEach(inject(function($filter) {
        keyValues = [
            {keyname: 'keyOne', value: 'valueOne'},
            {keyname: 'keyTwo', value: 'valueTwo'},
            {keyname: 'keyThree', value: 'valueThree'},
        ];
        keyValueFilter = $filter('keyValueToString');
    }));

    it("transforms an array of key, values to a string.", function() {
        expect(keyValueFilter(keyValues)).
            toBe('keyOne: valueOne, keyTwo: valueTwo, keyThree: valueThree');
    });

    it("ensures transform value is an array before proceeding", function() {
        expect(keyValueFilter({keyname: 'key', value: 'value'})).toBe('key: value');
    });

    describe("allows overriding default defaults.", function() {
        var options;
        beforeEach(function() {
            options = {};
        });

        it("by providing a custom separator", function() {
            options.separator = '='
            expect(keyValueFilter(keyValues, options)).
                toBe('keyOne=valueOne, keyTwo=valueTwo, keyThree=valueThree');
        });

        it('by providing a custom key name', function() {
            options.keyName = 'key';
            expect(keyValueFilter({key: 'key', value: 'value'}, options)).
                toBe('key: value');
        });

        it('by providing a custom value name', function() {
            options.valueName = 'valueeee';
            expect(keyValueFilter({keyname: 'key', valueeee: 'value'}, options)).
                toBe('key: value');
        });
    });
});

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
bastion-6.1.23 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.22 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.21 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.20 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.19 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.18 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.17 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.16 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.15 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.14 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.13 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.12 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.11 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.10 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.9 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.8 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.7 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.6 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.5 test/components/formatters/key-value-to-string.filter.test.js
bastion-6.1.4 test/components/formatters/key-value-to-string.filter.test.js