Skip to content

Commit

Permalink
Add delete tests for js
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Nov 19, 2024
1 parent 2719712 commit 38c4c61
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
30 changes: 30 additions & 0 deletions tests/javascript/file3dm.LayerTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,34 @@ test('CreateFileWithLayers', async () => {

expect(qtyLayers === 2 && qtyLayers2 === 2).toBe(true)

})

test('DeleteLayer', async () => {

const file3dm = new rhino.File3dm()
file3dm.applicationName = 'rhino3dm.js'
file3dm.applicationDetails = 'rhino3dm-tests-layerTable-deleteLayer'
file3dm.applicationUrl = 'https://rhino3d.com'

//create layers
const layer1 = new rhino.Layer()
layer1.Name = 'layer1'
layer1.Color = { r: 255, g: 0, b: 255, a: 255 }

const layer2 = new rhino.Layer()
layer2.Name = 'layer2'

const index1 = file3dm.layers().add(layer1)
const index2 = file3dm.layers().add(layer2)

const qtyLayers = file3dm.layers().count

const id1 = file3dm.layers().findIndex(index1).id

file3dm.layers().delete(id1)

const qtyLayers2 = file3dm.layers().count

expect(qtyLayers === 2 && qtyLayers2 === 1).toBe(true)

})
25 changes: 24 additions & 1 deletion tests/javascript/file3dm.ObjectTable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,27 @@ test('AddPolyline', async () => {

expect((objqty === 2) && isCurve1 && isCurve2 && (id1 !== id2) ).toBe(true)

} )
} )

test('DeleteObject', async () => {

const file3dm = new rhino.File3dm()
file3dm.applicationName = 'rhino3dm.js'
file3dm.applicationDetails = 'rhino3dm-tests-objectTable-deleteObject'
file3dm.applicationUrl = 'https://rhino3d.com'

const circle1 = new file3dm.Circle(5);
const circle2 = new file3dm.Circle(50);

const id1 = file3dm.objects().addCircle(circle1)
const id2 = file3dm.objects().addCircle(circle2)

const qtyObjects = file3dm.objects().count

file3dm.objects().delete(id1)

const qtyObjects2 = file3dm.objects().count

expect(qtyObjects === 2 && qtyObjects2 === 1).toBe(true)

})

0 comments on commit 38c4c61

Please sign in to comment.