You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ra...@apache.org on 2019/11/21 10:49:46 UTC

[cordova-plugin-screen-orientation] branch master updated: test: let Jasmine handle promises (#57)

This is an automated email from the ASF dual-hosted git repository.

raphinesse pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-plugin-screen-orientation.git


The following commit(s) were added to refs/heads/master by this push:
     new 464ab85  test: let Jasmine handle promises (#57)
464ab85 is described below

commit 464ab8541ce96553214fd1f5201dad31d0d2af80
Author: Raphael von der GrĂ¼n <ra...@gmail.com>
AuthorDate: Thu Nov 21 11:49:39 2019 +0100

    test: let Jasmine handle promises (#57)
    
    * test: let Jasmine handle promises
    
    Last in line for apache/cordova#169
    
    * lock in portrait mode to avoid trouble on CI
    
    cordova-paramedic runs the SauceLabs CI tests in portrait mode. For
    the Android 7.0 target, it seemed as our locking to landscape interferes
    with the Appium driver trying to set the app to portrait orientation.
    The result is a failure to connect to the device and finally a timeout.
    To avoid that, we are locking the app into portrait mode instead.
    
    * test: verify orientation after locking
---
 tests/tests.js | 24 +++++-------------------
 1 file changed, 5 insertions(+), 19 deletions(-)

diff --git a/tests/tests.js b/tests/tests.js
index 42b5aff..f722964 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -117,25 +117,11 @@ exports.defineAutoTests = function() {
     // test onchange works
     describe('window.screen.orientation', function() {
 
-        it('should successfully lock and unlock screen orientation, lock should return a promise', function(done) {
-
-            try {
-                var promise = window.screen.orientation.lock('landscape');
-                expect(promise).toBeDefined();
-                expect(typeof promise.then).toBe('function');
-                promise.then(function() {
-                    expect(window.screen.orientation.unlock).not.toThrow();
-                    done();
-                }, function(err) {
-                    expect(err).toBeDefined();
-                    fail(err);
-                    done();
-                });
-            } catch (err) {
-                fail(err);
-                done();
-            }
-
+        it('should successfully lock and unlock screen orientation', function() {
+            return window.screen.orientation.lock('portrait').then(function() {
+                expect(window.screen.orientation.type).toMatch(/^portrait-/);
+                expect(window.screen.orientation.unlock).not.toThrow();
+            });
         });
     });
 };


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org