-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
728 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
x-pack/plugins/actions/server/builtin_action_types/connectors/transformers.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { informationCreated, informationUpdated, informationAdded, append } from './transformers'; | ||
|
||
describe('informationCreated', () => { | ||
test('transforms correctly', () => { | ||
const res = informationCreated({ | ||
value: 'a value', | ||
date: '2020-04-15T08:19:27.400Z', | ||
user: 'elastic', | ||
}); | ||
expect(res).toEqual({ value: 'a value (created at 2020-04-15T08:19:27.400Z by elastic)' }); | ||
}); | ||
|
||
test('transforms correctly without optional fields', () => { | ||
const res = informationCreated({ | ||
value: 'a value', | ||
}); | ||
expect(res).toEqual({ value: 'a value (created at by )' }); | ||
}); | ||
|
||
test('returns correctly rest fields', () => { | ||
const res = informationCreated({ | ||
value: 'a value', | ||
date: '2020-04-15T08:19:27.400Z', | ||
user: 'elastic', | ||
previousValue: 'previous value', | ||
}); | ||
expect(res).toEqual({ | ||
value: 'a value (created at 2020-04-15T08:19:27.400Z by elastic)', | ||
previousValue: 'previous value', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('informationUpdated', () => { | ||
test('transforms correctly', () => { | ||
const res = informationUpdated({ | ||
value: 'a value', | ||
date: '2020-04-15T08:19:27.400Z', | ||
user: 'elastic', | ||
}); | ||
expect(res).toEqual({ value: 'a value (updated at 2020-04-15T08:19:27.400Z by elastic)' }); | ||
}); | ||
|
||
test('transforms correctly without optional fields', () => { | ||
const res = informationUpdated({ | ||
value: 'a value', | ||
}); | ||
expect(res).toEqual({ value: 'a value (updated at by )' }); | ||
}); | ||
|
||
test('returns correctly rest fields', () => { | ||
const res = informationUpdated({ | ||
value: 'a value', | ||
date: '2020-04-15T08:19:27.400Z', | ||
user: 'elastic', | ||
previousValue: 'previous value', | ||
}); | ||
expect(res).toEqual({ | ||
value: 'a value (updated at 2020-04-15T08:19:27.400Z by elastic)', | ||
previousValue: 'previous value', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('informationAdded', () => { | ||
test('transforms correctly', () => { | ||
const res = informationAdded({ | ||
value: 'a value', | ||
date: '2020-04-15T08:19:27.400Z', | ||
user: 'elastic', | ||
}); | ||
expect(res).toEqual({ value: 'a value (added at 2020-04-15T08:19:27.400Z by elastic)' }); | ||
}); | ||
|
||
test('transforms correctly without optional fields', () => { | ||
const res = informationAdded({ | ||
value: 'a value', | ||
}); | ||
expect(res).toEqual({ value: 'a value (added at by )' }); | ||
}); | ||
|
||
test('returns correctly rest fields', () => { | ||
const res = informationAdded({ | ||
value: 'a value', | ||
date: '2020-04-15T08:19:27.400Z', | ||
user: 'elastic', | ||
previousValue: 'previous value', | ||
}); | ||
expect(res).toEqual({ | ||
value: 'a value (added at 2020-04-15T08:19:27.400Z by elastic)', | ||
previousValue: 'previous value', | ||
}); | ||
}); | ||
}); | ||
|
||
describe('append', () => { | ||
test('transforms correctly', () => { | ||
const res = append({ | ||
value: 'a value', | ||
previousValue: 'previous value', | ||
}); | ||
expect(res).toEqual({ value: 'previous value \r\na value' }); | ||
}); | ||
|
||
test('transforms correctly without optional fields', () => { | ||
const res = append({ | ||
value: 'a value', | ||
}); | ||
expect(res).toEqual({ value: 'a value' }); | ||
}); | ||
|
||
test('returns correctly rest fields', () => { | ||
const res = append({ | ||
value: 'a value', | ||
user: 'elastic', | ||
previousValue: 'previous value', | ||
}); | ||
expect(res).toEqual({ | ||
value: 'previous value \r\na value', | ||
user: 'elastic', | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.