Browse Source

lint and test fixes

Alexander Rose 5 years ago
parent
commit
2c5253943c
3 changed files with 10 additions and 11 deletions
  1. 3 2
      src/mol-gl/_spec/renderable.spec.ts
  2. 6 8
      src/mol-state/state.ts
  3. 1 1
      src/mol-util/data-source.ts

+ 3 - 2
src/mol-gl/_spec/renderable.spec.ts

@@ -5,6 +5,7 @@
  */
 
 import { calculateBoundingSphere } from '../renderable/util';
+import { Vec3 } from '../../mol-math/linear-algebra';
 
 describe('renderable', () => {
     it('calculateBoundingSphere', () => {
@@ -34,7 +35,7 @@ describe('renderable', () => {
             transform, transform.length / 16
         )
 
-        expect(boundingSphere.radius).toBe(1.5)
-        expect(boundingSphere.center).toEqual([1.5, 0.0, 0.0])
+        expect(boundingSphere.radius).toBeCloseTo(1.58, 2)
+        expect(Vec3.equals(boundingSphere.center, Vec3.create(1.418367, 0, 0))).toBe(true)
     })
 })

+ 6 - 8
src/mol-state/state.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2020 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author David Sehnal <david.sehnal@gmail.com>
  */
@@ -154,13 +154,11 @@ class State {
                 }
                 if (isNested) throw e;
             } finally {
-                if (isNested) {
-                    return;
+                if (!isNested) {
+                    this.inTransaction = false;
+                    this.events.changed.next({ state: this, inTransaction: false });
+                    this.events.isUpdating.next(false);
                 }
-                
-                this.inTransaction = false;
-                this.events.changed.next({ state: this, inTransaction: false });
-                this.events.isUpdating.next(false);
             }
         });
     }
@@ -714,7 +712,7 @@ function resolveParams(ctx: UpdateContext, transform: StateTransform, src: State
     const prms = transform.transformer.definition.params;
     const definition = prms ? prms(src, ctx.parent.globalContext) : {};
     const defaultValues = ParamDefinition.getDefaultValues(definition);
-    (transform.params as any) = transform.params 
+    (transform.params as any) = transform.params
         ? assignIfUndefined(transform.params, defaultValues)
         : defaultValues;
     return { definition, values: transform.params };

+ 1 - 1
src/mol-util/data-source.ts

@@ -79,7 +79,7 @@ function genericError(isDownload: boolean) {
 }
 
 function readData<T extends XMLHttpRequest | FileReader>(ctx: RuntimeContext, action: string, data: T): Promise<T> {
-    return new Promise<T>((resolve, reject) => {        
+    return new Promise<T>((resolve, reject) => {
         // first check if data reading is already done
         if (isDone(data)) {
             const { error } = data as FileReader;