This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 827
Unit tests for new editor #3247
Merged
Merged
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
595dc82
unit test + fixes + comments + simplication for diffDeletion
bwindels 419c800
add tests for diffAtCaret
bwindels 9bfba9d
make PartCreator a bit more testable by not asking for deps of dep
bwindels a7259b3
first set of model tests
bwindels f8e1977
remove dead code
bwindels d6133ee
tests for non-editable parts
bwindels a474f53
more auto-complete tests
bwindels 7f5ba08
test typing in middle of pills
bwindels 94957fc
add more tests for empty lines
bwindels 08ff9e5
put mock code in separate file to reuse elsewhere
bwindels e8a31ed
test html to editor model deserialization
bwindels 0b92077
tests for turning caret position from model into dom position
bwindels b8a3c5e
test serialization only produces html messages when needed
bwindels 4b08bf0
add tests for removing multiple characters in edit
bwindels 44e4661
document return type
bwindels File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
Copyright 2019 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import expect from 'expect'; | ||
import {diffDeletion} from "../../src/editor/diff"; | ||
|
||
describe('editor/diff', function() { | ||
describe('diffDeletion', function() { | ||
it('at start of string', function() { | ||
const diff = diffDeletion("hello", "ello"); | ||
expect(diff.at).toBe(0); | ||
expect(diff.removed).toBe("h"); | ||
}); | ||
it('removing whole string', function() { | ||
const diff = diffDeletion("hello", ""); | ||
expect(diff.at).toBe(0); | ||
expect(diff.removed).toBe("hello"); | ||
}); | ||
it('in middle of string', function() { | ||
const diff = diffDeletion("hello", "hllo"); | ||
expect(diff.at).toBe(1); | ||
expect(diff.removed).toBe("e"); | ||
}); | ||
it('in middle of string with duplicate character', function() { | ||
const diff = diffDeletion("hello", "helo"); | ||
expect(diff.at).toBe(3); | ||
expect(diff.removed).toBe("l"); | ||
}); | ||
it('at end of string', function() { | ||
const diff = diffDeletion("hello", "hell"); | ||
expect(diff.at).toBe(4); | ||
expect(diff.removed).toBe("o"); | ||
}); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be good to have tests for multiple characters as well, just in case we've over-engineered it to work with single character diffs