Skip to content

Fixes: #586 - fix failing tests #604

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

Closed
wants to merge 1 commit into from
Closed
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: 0 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ jobs:
npx standard
npm ci
npm run build --if-present
# TODO: Remove the next line when #539 is fixed.
rm Linear-Algebra/test/test.js String/LevenshteinDistance.test.js
npm test
env:
CI: true
5 changes: 4 additions & 1 deletion Linear-Algebra/src/la_lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
The namespace LinearAlgebra contains useful classes and functions for dealing with
linear algebra under JavaScript.
*/
var LinearAlgebra;
let LinearAlgebra = {};

(function (LinearAlgebra) {
/*
class: Vector
Expand Down Expand Up @@ -309,3 +310,5 @@ var LinearAlgebra;
}()) // end of class Matrix
LinearAlgebra.Matrix = Matrix
})(LinearAlgebra || (LinearAlgebra = {})) // end of namespace LinearAlgebra

export default LinearAlgebra
2 changes: 1 addition & 1 deletion Linear-Algebra/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var assert = require('assert')
var fs = require('fs')

// file is included here
eval(fs.readFileSync('src/la_lib.js') + '')
import LinearAlgebra from '../src/la_lib.js';
// Tests goes here

// creating some vectors
Expand Down
2 changes: 1 addition & 1 deletion String/LevenshteinDistance.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ const levenshteinDistance = (a, b) => {
return distanceMatrix[b.length][a.length]
}

export { levenshteinDistance }
export default levenshteinDistance
8 changes: 4 additions & 4 deletions String/LevenshteinDistance.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import levenshteinDistance from './LevenshteinDistance'
import levenshteinDistance from './LevenshteinDistance.js'

describe('levenshteinDistance', () => {
it('should calculate edit distance between two strings', () => {
Expand All @@ -14,13 +14,13 @@ describe('levenshteinDistance', () => {
// Should just substitute i with o, m with g and insert e at end
expect(levenshteinDistance('firm', 'forge')).toBe(3)

// Should just substitute i with s, g with i, h with t and delete f from front
expect(levenshteinDistance('fighting', 'sitting')).toBe(4)
// Should just substitute f with s, g with t and delete h
expect(levenshteinDistance('fighting', 'sitting')).toBe(3)

// Should add 4 letters b, a, s and e at the beginning.
expect(levenshteinDistance('ball', 'baseball')).toBe(4)

// Should delete 4 letters b, a, s and e at the beginning.
expect(levenshteinDistance('baseball', 'foot')).toBe(4)
expect(levenshteinDistance('baseball', 'ball')).toBe(4)
})
})