Skip to content

Commit

Permalink
fix MIG-154 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ala Hawash authored and alahawash committed Feb 5, 2024
1 parent 00595ac commit 81de633
Showing 1 changed file with 26 additions and 57 deletions.
83 changes: 26 additions & 57 deletions packages/mdctl-axon-tools/__tests__/MIG-154/MIG-154.test.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,44 @@
const { privatesAccessor } = require('@medable/mdctl-core-utils/privates'),
StudyManifestTools = require('../../lib/StudyManifestTools')

describe('MIG-154 - Check new methods', () => {
const orgObjects = [
{
name: 'c_fault',
uniqueKey: 'c_key'
},
{
name: 'c_group',
uniqueKey: 'c_key'
},
{
name: 'c_task',
uniqueKey: 'c_key'
},
{
name: 'c_visit',
uniqueKey: ''
}
],
manifestTools = new StudyManifestTools()

privatesAccessor(manifestTools).orgObjects = orgObjects


afterEach(() => {
jest.clearAllMocks()
})

beforeEach(() => {
/*
Resets the module registry - the cache of all required modules
Needed to isolate modules where local state might conflict between
tests (privateAccessor in this case)
*/
jest.resetModules()
})

it('Test getExportableObjects', async() => {
const orgObjects = [
{
name: 'c_fault',
uniqueKey: 'c_key'
},
{
name: 'c_group',
uniqueKey: 'c_key'
},
{
name: 'c_task',
uniqueKey: 'c_key'
},
{
name: 'c_visit',
uniqueKey: ''
}
]

jest.mock('@medable/mdctl-core-utils/privates', () => ({ privatesAccessor: () => ({ orgObjects }) }))
// eslint-disable-next-line global-require
const StudyManifestTools = require('../../lib/StudyManifestTools'),
manifestTools = new StudyManifestTools({}),
exportableObjects = await manifestTools.getExportableObjects(),
const exportableObjects = await manifestTools.getExportableObjects(),
expectedObject = orgObjects.filter(({ uniqueKey }) => uniqueKey && uniqueKey !== 'mig__key').map(({ name }) => name)

expect(exportableObjects)
.toStrictEqual(expectedObject)
})

it('Test getKeyName', async() => {
const orgObjects = [
{
name: 'c_fault',
uniqueKey: 'c_key'
},
{
name: 'c_group',
uniqueKey: 'c_key'
},
{
name: 'c_task',
uniqueKey: 'c_key'
},
{
name: 'c_visit',
uniqueKey: ''
}
]

jest.mock('@medable/mdctl-core-utils/privates', () => ({ privatesAccessor: () => ({ orgObjects }) }))
// eslint-disable-next-line global-require
const StudyManifestTools = require('../../lib/StudyManifestTools'),
manifestTools = new StudyManifestTools({}),
key = 'c_task',
const key = 'c_task',
keyName = await manifestTools.getKeyName(key)

expect(keyName)
Expand Down

0 comments on commit 81de633

Please sign in to comment.