mirror of
https://github.com/empayre/fleet.git
synced 2024-11-07 09:18:59 +00:00
8567cc458c
* Adds campaigns to redux state * Update campaign with web socket data * Destroy the current campaign when creating a new one * close the socket when leaving the page or creating a new campaign * Allow stopping a running query * Update campaign with query results * Adds QueryResultsTable * Display flash message if campaign can't be created * Allow filtering query results * Adds filter icon * Prevent query text updates when the query is running
62 lines
1.8 KiB
JavaScript
62 lines
1.8 KiB
JavaScript
import expect from 'expect';
|
|
|
|
import helpers from 'kolide/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('Kolide API - helpers', () => {
|
|
describe('#labelSlug', () => {
|
|
it('creates a slug for the label', () => {
|
|
expect(helpers.labelSlug({ display_text: 'All Hosts' })).toEqual('all-hosts');
|
|
expect(helpers.labelSlug({ display_text: 'windows' })).toEqual('windows');
|
|
});
|
|
});
|
|
|
|
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],
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('#setupData', () => {
|
|
const formData = {
|
|
email: 'hi@gnar.dog',
|
|
name: 'Gnar Dog',
|
|
kolide_server_url: 'https://gnar.kolide.co',
|
|
org_logo_url: 'https://thegnar.co/assets/logo.png',
|
|
org_name: 'The Gnar Co.',
|
|
password: 'p@ssw0rd',
|
|
password_confirmation: 'p@ssw0rd',
|
|
username: 'gnardog',
|
|
};
|
|
|
|
it('formats the form data to send to the server', () => {
|
|
expect(helpers.setupData(formData)).toEqual({
|
|
kolide_server_url: 'https://gnar.kolide.co',
|
|
org_info: {
|
|
org_logo_url: 'https://thegnar.co/assets/logo.png',
|
|
org_name: 'The Gnar Co.',
|
|
},
|
|
admin: {
|
|
admin: true,
|
|
email: 'hi@gnar.dog',
|
|
name: 'Gnar Dog',
|
|
password: 'p@ssw0rd',
|
|
password_confirmation: 'p@ssw0rd',
|
|
username: 'gnardog',
|
|
},
|
|
});
|
|
});
|
|
});
|
|
});
|