33const Promise = require ( 'bluebird' ) ;
44
55const ActionsBuilder = require ( 'lib/tests-api/actions-builder' ) ;
6+ const StateError = require ( 'lib/errors/state-error' ) ;
67const util = require ( '../../util' ) ;
78
89describe ( 'tests-api/actions-builder' , ( ) => {
@@ -25,14 +26,10 @@ describe('tests-api/actions-builder', () => {
2526
2627 describe ( 'changeOrientation' , ( ) => {
2728 beforeEach ( ( ) => {
28- sandbox . stub ( browser , 'getOrientation' ) . returns ( Promise . resolve ( ) ) ;
29- sandbox . stub ( browser , 'setOrientation' ) . returns ( Promise . resolve ( ) ) ;
30- } ) ;
31-
32- it ( 'should throw in case of passed arguments' , ( ) => {
33- const fn = ( ) => mkActionsBuilder ( ) . changeOrientation ( 'awesome argument' ) ;
34-
35- assert . throws ( fn , TypeError , / \. c h a n g e O r i e n t a t i o n \( \) d o e s n o t a c c e p t a n y a r g u m e n t s / ) ;
29+ sandbox . stub ( browser , 'getOrientation' ) . resolves ( ) ;
30+ sandbox . stub ( browser , 'setOrientation' ) . resolves ( ) ;
31+ sandbox . stub ( browser , 'evalScript' ) . resolves ( ) ;
32+ sandbox . stub ( browser , 'waitFor' ) . resolves ( ) ;
3633 } ) ;
3734
3835 it ( 'should return ActionsBuilder instance' , ( ) => {
@@ -76,6 +73,35 @@ describe('tests-api/actions-builder', () => {
7673
7774 return assert . isRejected ( changeOrientation ( ) , / a w e s o m e e r r o r / ) ;
7875 } ) ;
76+
77+ it ( 'should wait for orientation change' , ( ) => {
78+ const changeOrientation = mkAction ( 'changeOrientation' , browser ) ;
79+
80+ return changeOrientation ( )
81+ . then ( ( ) => assert . callOrder ( browser . setOrientation , browser . waitFor ) ) ;
82+ } ) ;
83+
84+ it ( 'should wait for orientation change using the default timeout' , ( ) => {
85+ const changeOrientation = mkAction ( 'changeOrientation' , browser ) ;
86+
87+ return changeOrientation ( )
88+ . then ( ( ) => assert . calledWith ( browser . waitFor , sinon . match . any , 2500 ) ) ;
89+ } ) ;
90+
91+ it ( 'should wait for orientation change using the passed timeout' , ( ) => {
92+ const changeOrientation = mkAction ( 'changeOrientation' , browser ) ;
93+
94+ return changeOrientation ( { timeout : 100500 } )
95+ . then ( ( ) => assert . calledWith ( browser . waitFor , sinon . match . any , 100500 ) ) ;
96+ } ) ;
97+
98+ it ( 'should be rejected if orientation did not changed in passed timeout' , ( ) => {
99+ browser . waitFor . rejects ( ) ;
100+
101+ const changeOrientation = mkAction ( 'changeOrientation' , browser ) ;
102+
103+ return assert . isRejected ( changeOrientation ( ) , StateError ) ;
104+ } ) ;
79105 } ) ;
80106
81107 describe ( 'mouse actions' , ( ) => {
0 commit comments