-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding migration utility tests and some clean up
- Loading branch information
1 parent
3be7768
commit d418f91
Showing
6 changed files
with
215 additions
and
37 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
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
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
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
112 changes: 112 additions & 0 deletions
112
x-pack/plugins/cases/server/saved_object_types/migrations/utils.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,112 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { noneConnectorId } from '../../../common'; | ||
import { createJiraConnector } from '../../services/test_utils'; | ||
import { transformConnectorIdToReference } from './utils'; | ||
|
||
describe('migration utils', () => { | ||
describe('transformConnectorIdToReference', () => { | ||
it('returns the default none connector when the connector is undefined', () => { | ||
expect(transformConnectorIdToReference().transformedConnector).toMatchInlineSnapshot(` | ||
Object { | ||
"connector": Object { | ||
"fields": null, | ||
"name": "none", | ||
"type": ".none", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it('returns the default none connector when the id is undefined', () => { | ||
expect(transformConnectorIdToReference({ id: undefined }).transformedConnector) | ||
.toMatchInlineSnapshot(` | ||
Object { | ||
"connector": Object { | ||
"fields": null, | ||
"name": "none", | ||
"type": ".none", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it('returns the default none connector when the id is none', () => { | ||
expect(transformConnectorIdToReference({ id: noneConnectorId }).transformedConnector) | ||
.toMatchInlineSnapshot(` | ||
Object { | ||
"connector": Object { | ||
"fields": null, | ||
"name": "none", | ||
"type": ".none", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it('returns the default none connector when the id is none and other fields are defined', () => { | ||
expect( | ||
transformConnectorIdToReference({ ...createJiraConnector(), id: noneConnectorId }) | ||
.transformedConnector | ||
).toMatchInlineSnapshot(` | ||
Object { | ||
"connector": Object { | ||
"fields": null, | ||
"name": "none", | ||
"type": ".none", | ||
}, | ||
} | ||
`); | ||
}); | ||
|
||
it('returns an empty array of references when the connector is undefined', () => { | ||
expect(transformConnectorIdToReference().references.length).toBe(0); | ||
}); | ||
|
||
it('returns an empty array of references when the id is undefined', () => { | ||
expect(transformConnectorIdToReference({ id: undefined }).references.length).toBe(0); | ||
}); | ||
|
||
it('returns an empty array of references when the id is the none connector', () => { | ||
expect(transformConnectorIdToReference({ id: noneConnectorId }).references.length).toBe(0); | ||
}); | ||
|
||
it('returns an empty array of references when the id is the none connector and other fields are defined', () => { | ||
expect( | ||
transformConnectorIdToReference({ ...createJiraConnector(), id: noneConnectorId }) | ||
.references.length | ||
).toBe(0); | ||
}); | ||
|
||
it('returns a jira connector', () => { | ||
const transformedFields = transformConnectorIdToReference(createJiraConnector()); | ||
expect(transformedFields.transformedConnector).toMatchInlineSnapshot(` | ||
Object { | ||
"connector": Object { | ||
"fields": Object { | ||
"issueType": "bug", | ||
"parent": "2", | ||
"priority": "high", | ||
}, | ||
"name": ".jira", | ||
"type": ".jira", | ||
}, | ||
} | ||
`); | ||
expect(transformedFields.references).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"id": "1", | ||
"name": "connectorId", | ||
"type": "action", | ||
}, | ||
] | ||
`); | ||
}); | ||
}); | ||
}); |
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