Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
view-container / dist / utils / test / styleNames.test.js
Size: Mime:
"use strict";
// @flow
Object.defineProperty(exports, "__esModule", { value: true });
const styleNames_1 = require("../styleNames");
describe('styleNames', () => {
    describe('addNameForId', () => {
        it('adds an id and a name to a given dictionary', () => {
            const names = Object.create(null);
            // $FlowFixMe
            names.test = Object.create(null);
            styleNames_1.addNameForId(names, 'test', 'testName');
            styleNames_1.addNameForId(names, 'test2', 'testName');
            expect(names).toEqual({
                test: { testName: true },
                test2: { testName: true },
            });
        });
    });
    describe('resetIdNames', () => {
        it('removes all names for an ID', () => {
            const names = { test: { test: true } };
            styleNames_1.resetIdNames(names, 'test');
            styleNames_1.resetIdNames(names, 'test2');
            expect(names).toEqual({ test: {}, test2: {} });
        });
    });
    describe('hasNameForId', () => {
        it('checks the existance of a name for an id', () => {
            const names = { test1: { a: true }, test2: {} };
            const _hasNameForId = styleNames_1.hasNameForId(names);
            expect(_hasNameForId('test1', 'a')).toBeTruthy();
            expect(_hasNameForId('test2', 'a')).toBeFalsy();
            expect(_hasNameForId('test3', 'a')).toBeFalsy();
        });
    });
    describe('stringifyNames', () => {
        it('lists out all known names as a continuous string', () => {
            const names = { test1: { a: true }, test2: { b: true } };
            expect(styleNames_1.stringifyNames(names)).toBe('a b');
        });
    });
    describe('cloneNames', () => {
        it('creates a deep clone of the names dictionary', () => {
            const names = { test1: { a: true }, test2: { b: true } };
            const clone = styleNames_1.cloneNames(names);
            clone.test1 = {};
            expect(names.test1).toEqual({ a: true });
            expect(clone.test1).toEqual({});
        });
    });
});
//# sourceMappingURL=styleNames.test.js.map