-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from tidbcloud/refactor/unit-test
Refactor/unit test
- Loading branch information
Showing
12 changed files
with
485 additions
and
412 deletions.
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 |
---|---|---|
@@ -1,26 +1,36 @@ | ||
import { createSQLEditorInstance, EditorCache } from '..' | ||
|
||
test('editor instance cache works fine', () => { | ||
describe('editor instance cache works fine', () => { | ||
const cache = new EditorCache() | ||
const editorInst = createSQLEditorInstance({ | ||
editorId: '111', | ||
doc: 'select * from test;' | ||
}) | ||
|
||
expect(cache.getEditor('111')).toBe(undefined) | ||
test('no cache added', () => { | ||
expect(cache.getEditor('111')).toBe(undefined) | ||
}) | ||
|
||
cache.addEditor('111', editorInst) | ||
expect(cache.getEditor('111')).toBe(editorInst) | ||
test('add one instance 111 to cache', () => { | ||
cache.addEditor('111', editorInst) | ||
expect(cache.getEditor('111')).toBe(editorInst) | ||
}) | ||
|
||
cache.deleteEditor('222') | ||
expect(cache.getEditor('111')).toBe(editorInst) | ||
test('remove instance 222 from cache', () => { | ||
cache.deleteEditor('222') | ||
expect(cache.getEditor('111')).toBe(editorInst) | ||
}) | ||
|
||
cache.deleteEditor('111') | ||
expect(cache.getEditor('111')).toBe(undefined) | ||
test('remove instance 111 from cache', () => { | ||
cache.deleteEditor('111') | ||
expect(cache.getEditor('111')).toBe(undefined) | ||
}) | ||
|
||
cache.addEditor('111', editorInst) | ||
expect(cache.getEditor('111')).toBe(editorInst) | ||
test('clear cache', () => { | ||
cache.addEditor('111', editorInst) | ||
expect(cache.getEditor('111')).toBe(editorInst) | ||
|
||
cache.clearEditors() | ||
expect(cache.getEditor('111')).toBe(undefined) | ||
cache.clearEditors() | ||
expect(cache.getEditor('111')).toBe(undefined) | ||
}) | ||
}) |
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
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
Oops, something went wrong.