From 38c4c61ba6b95d9047bde9eaebb64edee3346fe3 Mon Sep 17 00:00:00 2001 From: fraguada Date: Tue, 19 Nov 2024 14:00:00 +0100 Subject: [PATCH] Add delete tests for js --- tests/javascript/file3dm.LayerTable.test.js | 30 ++++++++++++++++++++ tests/javascript/file3dm.ObjectTable.test.js | 25 +++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/tests/javascript/file3dm.LayerTable.test.js b/tests/javascript/file3dm.LayerTable.test.js index 7eea6309..c14100cd 100644 --- a/tests/javascript/file3dm.LayerTable.test.js +++ b/tests/javascript/file3dm.LayerTable.test.js @@ -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) + }) \ No newline at end of file diff --git a/tests/javascript/file3dm.ObjectTable.test.js b/tests/javascript/file3dm.ObjectTable.test.js index 2c340c5a..ae1cb657 100644 --- a/tests/javascript/file3dm.ObjectTable.test.js +++ b/tests/javascript/file3dm.ObjectTable.test.js @@ -32,4 +32,27 @@ test('AddPolyline', async () => { expect((objqty === 2) && isCurve1 && isCurve2 && (id1 !== id2) ).toBe(true) -} ) \ No newline at end of file +} ) + +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) + +}) \ No newline at end of file