"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const assert_1 = __importDefault(require("assert")); const stringEnumPolicy_js_1 = require("../policies/stringEnumPolicy.js"); const types_js_1 = require("../policies/types.js"); suite('StringEnumPolicy', () => { const mockCategory = { key: 'test.category', name: { value: 'Category1', key: 'test.category' }, }; const mockPolicy = { key: 'test.stringenum.policy', name: 'TestStringEnumPolicy', category: 'Category1', minimumVersion: '1.0', type: 'string', localization: { description: { key: 'test.policy.description', value: 'Test policy description' }, enumDescriptions: [ { key: 'test.option.one', value: 'Option One' }, { key: 'test.option.two', value: 'Option Two' }, { key: 'test.option.three', value: 'Option Three' } ] }, enum: ['auto', 'manual', 'disabled'] }; test('should create StringEnumPolicy from factory method', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); assert_1.default.strictEqual(policy.name, 'TestStringEnumPolicy'); assert_1.default.strictEqual(policy.minimumVersion, '1.0'); assert_1.default.strictEqual(policy.category.name.nlsKey, mockCategory.name.key); assert_1.default.strictEqual(policy.category.name.value, mockCategory.name.value); assert_1.default.strictEqual(policy.type, types_js_1.PolicyType.StringEnum); }); test('should render ADMX elements correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const admx = policy.renderADMX('TestKey'); assert_1.default.deepStrictEqual(admx, [ '', '\t', '\t', '\t', '', '\tauto', '\tmanual', '\tdisabled', '', '\t', '' ]); }); test('should render ADML strings correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const admlStrings = policy.renderADMLStrings(); assert_1.default.deepStrictEqual(admlStrings, [ 'TestStringEnumPolicy', 'Test policy description', 'Option One', 'Option Two', 'Option Three' ]); }); test('should render ADML strings with translations', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const translations = { '': { 'test.policy.description': 'Translated description', 'test.option.one': 'Translated Option One', 'test.option.two': 'Translated Option Two' } }; const admlStrings = policy.renderADMLStrings(translations); assert_1.default.deepStrictEqual(admlStrings, [ 'TestStringEnumPolicy', 'Translated description', 'Translated Option One', 'Translated Option Two', 'Option Three' ]); }); test('should render ADML presentation correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const presentation = policy.renderADMLPresentation(); assert_1.default.strictEqual(presentation, ''); }); test('should render JSON value correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const jsonValue = policy.renderJsonValue(); assert_1.default.strictEqual(jsonValue, 'auto'); }); test('should render profile value correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const profileValue = policy.renderProfileValue(); assert_1.default.strictEqual(profileValue, 'auto'); }); test('should render profile correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const profile = policy.renderProfile(); assert_1.default.strictEqual(profile.length, 2); assert_1.default.strictEqual(profile[0], 'TestStringEnumPolicy'); assert_1.default.strictEqual(profile[1], 'auto'); }); test('should render profile manifest value correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const manifestValue = policy.renderProfileManifestValue(); assert_1.default.strictEqual(manifestValue, 'pfm_default\nauto\npfm_description\nTest policy description\npfm_name\nTestStringEnumPolicy\npfm_title\nTestStringEnumPolicy\npfm_type\nstring\npfm_range_list\n\n\tauto\n\tmanual\n\tdisabled\n'); }); test('should render profile manifest value with translations', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const translations = { '': { 'test.policy.description': 'Translated manifest description' } }; const manifestValue = policy.renderProfileManifestValue(translations); assert_1.default.strictEqual(manifestValue, 'pfm_default\nauto\npfm_description\nTranslated manifest description\npfm_name\nTestStringEnumPolicy\npfm_title\nTestStringEnumPolicy\npfm_type\nstring\npfm_range_list\n\n\tauto\n\tmanual\n\tdisabled\n'); }); test('should render profile manifest correctly', () => { const policy = stringEnumPolicy_js_1.StringEnumPolicy.from(mockCategory, mockPolicy); assert_1.default.ok(policy); const manifest = policy.renderProfileManifest(); assert_1.default.strictEqual(manifest, '\npfm_default\nauto\npfm_description\nTest policy description\npfm_name\nTestStringEnumPolicy\npfm_title\nTestStringEnumPolicy\npfm_type\nstring\npfm_range_list\n\n\tauto\n\tmanual\n\tdisabled\n\n'); }); }); //# sourceMappingURL=stringEnumPolicy.test.js.map