Skip to content

Commit

Permalink
Fix jest tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
tealefristoe committed Dec 6, 2024
1 parent 749c6cd commit f6d64a5
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions v3/src/data-interactive/handlers/attribute-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ describe("DataInteractive AttributeHandler", () => {
expect(create(resources).success).toEqual(false)
expect(create({ dataContext }, { name: "noCollection" }).success).toEqual(false)

expect(dataContext.attributes.length).toBe(3)
expect(dataContext.attributes.length).toBe(4)
expect(c1.attributes.length).toBe(1)
const name1 = "test"
expect(create(resources, { name: name1 }).success).toEqual(true)
expect(dataContext.attributes.length).toBe(4)
expect(dataContext.attributes.length).toBe(5)
expect(c1.attributes.length).toBe(2)
const testAttr = c1.attributes[1]!
expect(testAttr.name).toBe(name1)
Expand All @@ -41,13 +41,13 @@ describe("DataInteractive AttributeHandler", () => {

const name2 = "test2"
expect(create(resources, [{ name: name2 }, {}]).success).toEqual(false)
expect(dataContext.attributes.length).toBe(4)
expect(dataContext.attributes.length).toBe(5)

const name3 = "test3"
const results = create(resources, [{ name: name2 }, { name: name3 }])
expect(results.success).toEqual(true)
expect((results.values as DIResultAttributes).attrs.length).toBe(2)
expect(dataContext.attributes.length).toBe(6)
expect(dataContext.attributes.length).toBe(7)
expect(c1.attributes[2]!.name).toBe(name2)
expect(c1.attributes[3]!.name).toBe(name3)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("DataInteractive AttributeLocationHandler", () => {

it("update works as expected", () => {
const { dataset, c1, c2, a1, a2 } = setupTestDataset()
const a4 = dataset.addAttribute({ name: "a4" }, { collection: c1.id })
const a4 = dataset.addAttribute({ name: "a4b" }, { collection: c1.id })
const a5 = dataset.addAttribute({ name: "a5" }, { collection: c2.id })
const a6 = dataset.addAttribute({ name: "a6" })
const dataContext = dataset
Expand All @@ -29,11 +29,11 @@ describe("DataInteractive AttributeLocationHandler", () => {

// Move attribute within the ungrouped collection
// Indexes snap to the end of the array
expect(dataset.childCollection.attributes[1]!.id).toBe(a6.id)
expect(dataset.childCollection.attributes[2]!.id).toBe(a6.id)
expect(handler.update?.({ attributeLocation: a6, dataContext }, { position: -1 }).success).toBe(true)
expect(dataset.childCollection.attributes[0]!.id).toBe(a6.id)
expect(handler.update?.({ attributeLocation: a6, dataContext }, { position: 10 }).success).toBe(true)
expect(dataset.childCollection.attributes[1]!.id).toBe(a6.id)
expect(dataset.childCollection.attributes[2]!.id).toBe(a6.id)

// Move attribute within a grouped collection
// If not specified, move the attribute to the far right
Expand All @@ -49,7 +49,7 @@ describe("DataInteractive AttributeLocationHandler", () => {
expect(handler.update?.({ attributeLocation: a6, dataContext }, { collection: c1.name, position: 1 }).success)
.toBe(true)
expect(collectionAttributes(c1)?.length).toBe(3)
expect(dataset.childCollection.attributes.length).toBe(1)
expect(dataset.childCollection.attributes.length).toBe(2)
expect(collectionAttributes(c1)?.[1]?.id).toBe(a6.id)
expect(collectionAttributes(c1)?.[2]?.id).toBe(a4.id)

Expand Down
6 changes: 3 additions & 3 deletions v3/src/data-interactive/handlers/collection-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ describe("DataInteractive CollectionHandler", () => {

// Add a right-most collection
// Add attributes with attributes field
const rightResult = handler.create?.({ dataContext }, { name: "right", attributes: [{ name: "a4" }] })
const rightResult = handler.create?.({ dataContext }, { name: "right", attributes: [{ name: "a4b" }] })
expect(rightResult?.success).toBe(true)
expect(dataset.collections.length).toBe(4)
expect(dataset.collections[3].name).toBe("right")
expect(dataset.collections[3].attributes.length).toBe(1)
expect(dataset.collections[3].attributes[0]?.name).toBe("a4")
expect(dataset.collections[3].attributes[0]?.name).toBe("a4b")

// Add a left-most collection
// Add attributes with attrs field
Expand Down Expand Up @@ -76,7 +76,7 @@ describe("DataInteractive CollectionHandler", () => {
const result = handler.delete?.({ dataContext, collection })
expect(result?.success).toBe(true)
expect((result?.values as DIDeleteCollectionResult).collections?.[0]).toBe(toV2Id(collectionId))
expect(dataContext.attributes.length).toBe(2)
expect(dataContext.attributes.length).toBe(3)
expect(dataContext.collections.length).toBe(2)
expect(dataContext.getCollection(collectionId)).toBeUndefined()
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("DataInteractive ItemByCaseIDHandler", () => {
expect(result.success).toBe(true)
const values = result.values as DIFullCase
expect(values.id).toBe(toV2Id(itemByCaseID.__id__))
expect(Object.keys(values.values!).length).toBe(3)
expect(Object.keys(values.values!).length).toBe(4)
expect(values.values?.a1).toBe(a1.value(0))
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("DataInteractive ItemByIDHandler", () => {
expect(result.success).toBe(true)
const values = result.values as DIFullCase
expect(values.id).toBe(toV2Id(itemByID.__id__))
expect(Object.keys(values.values!).length).toBe(3)
expect(Object.keys(values.values!).length).toBe(4)
expect(values.values?.a1).toBe(a1.value(0))
})

Expand Down
2 changes: 1 addition & 1 deletion v3/src/data-interactive/handlers/item-handler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe("DataInteractive ItemHandler", () => {
expect(result.success).toBe(true)
const values = result.values as DIFullCase
expect(values.id).toBe(toV2Id(item.__id__))
expect(Object.keys(values.values!).length).toBe(3)
expect(Object.keys(values.values!).length).toBe(4)
expect(values.values?.a1).toBe(a1.value(0))
})

Expand Down

0 comments on commit f6d64a5

Please sign in to comment.