@@ -181,6 +181,67 @@ describe( 'Editor', () => {
181181 } ) ;
182182 } ) ;
183183
184+ describe ( 'state' , ( ) => {
185+ it ( 'is `initializing` initially' , ( ) => {
186+ const editor = new Editor ( ) ;
187+
188+ expect ( editor . state ) . to . equal ( 'initializing' ) ;
189+ } ) ;
190+
191+ it ( 'is `ready` after initialization chain' , ( ) => {
192+ return Editor . create ( ) . then ( editor => {
193+ expect ( editor . state ) . to . equal ( 'ready' ) ;
194+
195+ return editor . destroy ( ) ;
196+ } ) ;
197+ } ) ;
198+
199+ it ( 'is `destroyed` after editor destroy' , ( ) => {
200+ const editor = new Editor ( ) ;
201+
202+ return editor . destroy ( ) . then ( ( ) => {
203+ expect ( editor . state ) . to . equal ( 'destroyed' ) ;
204+ } ) ;
205+ } ) ;
206+
207+ it ( 'is observable' , ( ) => {
208+ const editor = new Editor ( ) ;
209+ const spy = sinon . spy ( ) ;
210+
211+ editor . on ( 'change:state' , spy ) ;
212+
213+ editor . state = 'ready' ;
214+
215+ sinon . assert . calledOnce ( spy ) ;
216+ } ) ;
217+
218+ it ( 'reacts on #ready event' , done => {
219+ const editor = new Editor ( ) ;
220+
221+ expect ( editor . state ) . to . equal ( 'initializing' ) ;
222+
223+ editor . on ( 'ready' , ( ) => {
224+ expect ( editor . state ) . to . equal ( 'ready' ) ;
225+ done ( ) ;
226+ } ) ;
227+
228+ editor . fire ( 'ready' ) ;
229+ } ) ;
230+
231+ it ( 'reacts on #destroy event' , done => {
232+ const editor = new Editor ( ) ;
233+
234+ expect ( editor . state ) . to . equal ( 'initializing' ) ;
235+
236+ editor . on ( 'destroy' , ( ) => {
237+ expect ( editor . state ) . to . equal ( 'destroyed' ) ;
238+ done ( ) ;
239+ } ) ;
240+
241+ editor . fire ( 'destroy' ) ;
242+ } ) ;
243+ } ) ;
244+
184245 describe ( 'isReadOnly' , ( ) => {
185246 it ( 'is false initially' , ( ) => {
186247 const editor = new Editor ( ) ;
0 commit comments