-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix readOnly.isEnabled getter (#1831)
* Fix readOnly.isEnabled getter * Add tests * Update CHANGELOG.md Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
- Loading branch information
Showing
3 changed files
with
58 additions
and
2 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
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,50 @@ | ||
import EditorJS, { EditorConfig } from '../../../types'; | ||
|
||
describe('ReadOnly API spec', () => { | ||
function createEditor(config?: EditorConfig): void { | ||
const editorConfig = Object.assign({}, config || {}); | ||
|
||
cy.createEditor(editorConfig).as('editorInstance'); | ||
} | ||
|
||
it('should return correct value for readOnly.isEnabled when editor initialized in normal mode', () => { | ||
createEditor(); | ||
|
||
cy | ||
.get<EditorJS>('@editorInstance') | ||
.then(editor => { | ||
expect(editor.readOnly.isEnabled).to.be.false; | ||
}); | ||
}); | ||
|
||
it('should return correct value for readOnly.isEnabled when editor initialized in read-only mode', () => { | ||
createEditor({ | ||
readOnly: true, | ||
}); | ||
|
||
cy | ||
.get<EditorJS>('@editorInstance') | ||
.then(editor => { | ||
expect(editor.readOnly.isEnabled).to.be.true; | ||
}); | ||
}); | ||
|
||
it('should return correct value for readOnly.isEnabled when read-only mode toggled', () => { | ||
createEditor(); | ||
|
||
cy | ||
.get<EditorJS>('@editorInstance') | ||
.then(async editor => { | ||
expect(editor.readOnly.isEnabled).to.be.false; | ||
|
||
editor.readOnly.toggle() | ||
.then(() => { | ||
expect(editor.readOnly.isEnabled).to.be.true; | ||
}) | ||
.then(() => editor.readOnly.toggle()) | ||
.then(() => { | ||
expect(editor.readOnly.isEnabled).to.be.false; | ||
}); | ||
}); | ||
}); | ||
}); |