Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(taxonomy): failing total endpoint [NONE] #2413

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"test:cover-integration": "./node_modules/.bin/nyc --reporter=lcov --reporter=text --reporter=clover --report-dir=coverage/integration npm run test:integration",
"test:unit": "BABEL_ENV=test babel-node --extensions .ts --extensions .js ./node_modules/.bin/mocha './test/unit/**/*-test.[tj]s' --config mocharc.js --require @babel/register --reporter mocha-junit-reporter --reporter-options mochaFile=reports/unit-results.xml",
"test:unit-watch": "BABEL_ENV=test babel-node --extensions .ts --extensions .js ./node_modules/.bin/mocha './test/unit/**/*-test.[tj]s' --config mocharc.js --watch --require @babel/register",
"test:integration": "BABEL_ENV=test babel-node --extensions .ts --extensions .js ./node_modules/.bin/mocha './test/integration/*.[tj]s' --config mocharc.js --require @babel/register --reporter mocha-junit-reporter --reporter-options mochaFile=reports/integration-results.xml",
"test:integration": "BABEL_ENV=test babel-node --extensions .ts --extensions .js ./node_modules/.bin/mocha './test/integration/taxonomy-integration.ts' --config mocharc.js --require @babel/register",
"test:integration-watch": "BABEL_ENV=test babel-node --extensions .ts --extensions .js ./node_modules/.bin/mocha './test/integration/*.[tj]s' --config mocharc.js --watch --require @babel/register",
"test:browser": "BABEL_ENV=test karma start karma.conf.local.js --log-level info",
"test:version": "grep -r \"0.0.0-determined-by-semantic-release\" ./dist > /dev/null && echo \"version 0.0.0-determined-by-semantic-release found in output\" && exit 1 || exit 0",
Expand Down
124 changes: 60 additions & 64 deletions test/integration/taxonomy-integration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,38 @@ describe('Taxonomy Integration', () => {
organizationId: getTestOrganizationId(),
})

async function createTestConcepts(count = 3) {
return Promise.all(
Array(count)
.fill(null)
.map(async (_, index) => {
const concept: CreateConceptProps = {
prefLabel: {
'en-US': `Test Concept ${index}`,
},
}
const result = await client.concept.create({}, concept)
conceptsToDelete.push(result)
})
)
}

async function createTestConceptSchemes(count = 3) {
return Promise.all(
Array(count)
.fill(null)
.map(async (_, index) => {
const concept: CreateConceptSchemeProps = {
prefLabel: {
'en-US': `Test Concept Scheme ${index}`,
},
}
const result = await client.conceptScheme.create({}, concept)
conceptSchemesToDelete.push(result)
})
)
}

beforeEach(() => {
conceptsToDelete = []
conceptSchemesToDelete = []
Expand All @@ -22,20 +54,28 @@ describe('Taxonomy Integration', () => {
const conceptToBeDeleted = await client.concept.get({
conceptId: concept.sys.id,
})
await client.concept.delete({
conceptId: conceptToBeDeleted.sys.id,
version: conceptToBeDeleted.sys.version,
})
try {
await client.concept.delete({
conceptId: conceptToBeDeleted.sys.id,
version: conceptToBeDeleted.sys.version,
})
} catch (e) {
console.log(e)
}
}

for (const conceptScheme of conceptSchemesToDelete) {
const conceptSchemeToBeDeleted = await client.conceptScheme.get({
conceptSchemeId: conceptScheme.sys.id,
})
await client.conceptScheme.delete({
conceptSchemeId: conceptSchemeToBeDeleted.sys.id,
version: conceptSchemeToBeDeleted.sys.version,
})
try {
await client.conceptScheme.delete({
conceptSchemeId: conceptSchemeToBeDeleted.sys.id,
version: conceptSchemeToBeDeleted.sys.version,
})
} catch (e) {
console.log(e)
}
}
})

Expand Down Expand Up @@ -140,41 +180,20 @@ describe('Taxonomy Integration', () => {
})

test('concept getTotal', async () => {
await Promise.all(
Array(3)
.fill(null)
.map(async (i) => {
const concept: CreateConceptProps = {
prefLabel: {
'en-US': `Test Concept ${i}`,
},
}
const { items: testItems } = await client.conceptScheme.getMany({})
expect(testItems.length).to.eq(0)

const result = await client.concept.create({}, concept)
conceptsToDelete.push(result)
})
)
// await createTestConcepts(3)

const { total: total } = await client.concept.getTotal({})
// const { items } = await client.concept.getMany({})
const { total } = await client.concept.getTotal({})

expect(total).to.eq(3)
// expect(items.length).to.eq(3)
expect(total).to.eq(0)
})

test('get list of all concepts', async () => {
await Promise.all(
Array(3)
.fill(null)
.map(async (i) => {
const concept: CreateConceptProps = {
prefLabel: {
'en-US': `Test Concept ${i}`,
},
}

const result = await client.concept.create({}, concept)
conceptsToDelete.push(result)
})
)
await createTestConcepts(3)

const { items } = await client.concept.getMany({})
expect(items.length).to.eq(3)
Expand Down Expand Up @@ -344,41 +363,18 @@ describe('Taxonomy Integration', () => {
})

test('conceptScheme getTotal', async () => {
await Promise.all(
Array(3)
.fill(null)
.map(async (i) => {
const conceptScheme: CreateConceptSchemeProps = {
prefLabel: {
'en-US': `Test ConceptScheme ${i}`,
},
}
const { items: testItems } = await client.conceptScheme.getMany({})
expect(testItems.length).to.eq(0)

const result = await client.conceptScheme.create({}, conceptScheme)
conceptSchemesToDelete.push(result)
})
)
await createTestConceptSchemes(3)

const { total: total } = await client.conceptScheme.getTotal({})

expect(total).to.eq(3)
})

test('get list of all conceptsSchemes', async () => {
await Promise.all(
Array(3)
.fill(null)
.map(async (i) => {
const conceptScheme: CreateConceptSchemeProps = {
prefLabel: {
'en-US': `Test Concept ${i}`,
},
}

const result = await client.conceptScheme.create({}, conceptScheme)
conceptSchemesToDelete.push(result)
})
)
await createTestConceptSchemes(3)

const { items } = await client.conceptScheme.getMany({})
expect(items.length).to.eq(3)
Expand Down