fleet/frontend/components/forms/fields/SelectTargetsDropdown/helpers.tests.js
Mike Stone 8bb2a39d86 Improves re-usability of the SelectTargetsDropdown (#518)
* Improves re-usability of the SelectTargetsDropdown
2016-11-21 10:38:23 -05:00

24 lines
660 B
JavaScript

import expect from 'expect';
import helpers from './helpers';
const label1 = { id: 1, target_type: 'labels' };
const label2 = { id: 2, target_type: 'labels' };
const host1 = { id: 6, target_type: 'hosts' };
const host2 = { id: 5, target_type: 'hosts' };
describe('SelectTargetsDropdown - helpers', () => {
describe('#formatSelectedTargetsForApi', () => {
const { formatSelectedTargetsForApi } = helpers;
it('splits targets into labels and hosts', () => {
const targets = [host1, host2, label1, label2];
expect(formatSelectedTargetsForApi(targets)).toEqual({
hosts: [6, 5],
labels: [1, 2],
});
});
});
});