Vault Automation 366e77bac5
UI: Convert file policy-form to typescript (#11368) (#11434)
* convert file to typescript

* remove unused util

* add support for nested options

* move automation snippets outside of builder component

* update snippet utils

* Revert "remove unused util"

This reverts commit bcb53271e63dd1fc3d2f735d7f7fcc54e5e31988.

* render automation snippets for only acl policy types

* cleanup old args

* add default arg for formatEot

* make tfvp formatters easier to follow, maybe?

Co-authored-by: claire bontempo <68122737+hellobontempo@users.noreply.github.com>
2025-12-17 17:20:19 +00:00

61 lines
1.7 KiB
JavaScript

/**
* Copyright IBM Corp. 2016, 2025
* SPDX-License-Identifier: BUSL-1.1
*/
import { module, test } from 'qunit';
import { setupTest } from 'ember-qunit';
import { formatEot } from 'core/utils/code-generators/formatters';
module('Integration | Util | code-generators/formatters', function (hooks) {
setupTest(hooks);
test('formatEot: it wraps content in EOT heredoc block', async function (assert) {
const content = 'path "secret/*" {\n capabilities = ["read"]\n}';
const formatted = formatEot(content);
const expected = `<<EOT
path "secret/*" {
capabilities = ["read"]
}
EOT`;
assert.strictEqual(formatted, expected, 'it wraps content with line breaks "\n"');
});
test('formatEot: it handles single line content', async function (assert) {
const formatted = formatEot('single line content');
const expected = `<<EOT
single line content
EOT`;
assert.strictEqual(formatted, expected, 'it wraps single line');
});
test('formatEot: it handles empty content', async function (assert) {
const formatted = formatEot('');
const expected = `<<EOT
EOT`;
assert.strictEqual(formatted, expected, 'it wraps empty content');
});
test('formatEot: it handles multi-line content', async function (assert) {
const content = `line 1
line 2
line 3`;
const formatted = formatEot(content);
const expected = `<<EOT
line 1
line 2
line 3
EOT`;
assert.strictEqual(formatted, expected, 'it wraps multi-line content');
});
test('formatEot: it handles undefined args', async function (assert) {
const formatted = formatEot();
const expected = `<<EOT
EOT`;
assert.strictEqual(formatted, expected, 'it handles undefined args');
});
});