open-nomad/ui/tests/unit/helpers/format-volume-name-test.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

45 lines
1.1 KiB
JavaScript
Raw Normal View History

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: MPL-2.0
*/
import { module, test } from 'qunit';
import { formatVolumeName } from 'nomad-ui/helpers/format-volume-name';
module('Unit | Helper | formatVolumeName', function () {
test('Returns source as string when isPerAlloc is false', function (assert) {
const expectation = 'my-volume-source';
assert.equal(
formatVolumeName(null, {
source: 'my-volume-source',
isPerAlloc: false,
volumeExtension: '[arbitrary]',
}),
expectation,
'false perAlloc'
);
assert.equal(
formatVolumeName(null, {
source: 'my-volume-source',
isPerAlloc: null,
volumeExtension: '[arbitrary]',
}),
expectation,
'null perAlloc'
);
});
test('Returns concatonated name when isPerAlloc is true', function (assert) {
const expectation = 'my-volume-source[1]';
assert.equal(
formatVolumeName(null, {
source: 'my-volume-source',
isPerAlloc: true,
volumeExtension: '[1]',
}),
expectation,
expectation
);
});
});