From 5b5c5ce2192755381a02514578ffb38ad8b4e2b4 Mon Sep 17 00:00:00 2001 From: tpoisseau <22891227+tpoisseau@users.noreply.github.com> Date: Mon, 27 Nov 2023 15:49:18 +0100 Subject: [PATCH] fix: complete coverage --- src/__tests__/distance_matrix/creation.test.js | 6 ++++++ src/__tests__/matrix/creation.test.js | 11 ++++++++++- src/__tests__/symmetric_matrix/creation.test.js | 9 ++++++++- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/__tests__/distance_matrix/creation.test.js b/src/__tests__/distance_matrix/creation.test.js index 45a8336..b52dff6 100644 --- a/src/__tests__/distance_matrix/creation.test.js +++ b/src/__tests__/distance_matrix/creation.test.js @@ -98,4 +98,10 @@ describe('DistanceMatrix creation', () => { [1, 1, 0], ]); }); + + it('clone', () => { + const matrix = DistanceMatrix.zeros(3); + const clone = matrix.clone(); + expect(clone).toBeInstanceOf(DistanceMatrix); + }); }); diff --git a/src/__tests__/matrix/creation.test.js b/src/__tests__/matrix/creation.test.js index 70d96f0..caee67f 100644 --- a/src/__tests__/matrix/creation.test.js +++ b/src/__tests__/matrix/creation.test.js @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; -import { Matrix, wrap } from '../..'; +import { DistanceMatrix, Matrix, SymmetricMatrix, wrap } from '../..'; import * as util from '../../../testUtils'; import MatrixTransposeView from '../../views/transpose'; @@ -243,4 +243,13 @@ describe('Matrix creation', () => { ); expect(JSON.stringify(transposeTwice)).toBe(json); }); + + it('construct from child class', () => { + const dMatrix = DistanceMatrix.zeros(3); + const sMatrix = new SymmetricMatrix(dMatrix); + const matrix = new Matrix(sMatrix); + expect(matrix).not.toBeInstanceOf(DistanceMatrix); + expect(matrix).not.toBeInstanceOf(SymmetricMatrix); + expect(matrix).toBeInstanceOf(Matrix); + }); }); diff --git a/src/__tests__/symmetric_matrix/creation.test.js b/src/__tests__/symmetric_matrix/creation.test.js index 06966e2..52554ac 100644 --- a/src/__tests__/symmetric_matrix/creation.test.js +++ b/src/__tests__/symmetric_matrix/creation.test.js @@ -1,6 +1,6 @@ import { describe, it, expect } from 'vitest'; -import { Matrix, SymmetricMatrix } from '../../index'; +import { DistanceMatrix, Matrix, SymmetricMatrix } from '../../index'; describe('SymmetricMatrix creation', () => { it('should create a new object', () => { @@ -159,4 +159,11 @@ describe('SymmetricMatrix creation', () => { expect(matrix).not.toBeInstanceOf(SymmetricMatrix); expect(matrix).toBeInstanceOf(Matrix); }); + + it('construct from child class', () => { + const dMatrix = DistanceMatrix.zeros(3); + const sMatrix = new SymmetricMatrix(dMatrix); + expect(sMatrix).not.toBeInstanceOf(DistanceMatrix); + expect(sMatrix).toBeInstanceOf(SymmetricMatrix); + }); });