Browse Source

Fix a typo, format

pull/6164/head
mohamedsalem401 2 years ago
parent
commit
7ea20b8a38
  1. 8
      packages/core/src/dom_components/index.ts
  2. 10
      packages/core/test/specs/dom_components/index.ts

8
packages/core/src/dom_components/index.ts

@ -847,12 +847,12 @@ export default class ComponentManager extends ItemManagerModule<DomComponentsCon
// Check if the target and source belong to the same root symbol
if (isSymbolComponent(target) && source instanceof Component && isSymbolComponent(source)) {
const targetRootSymbol = getSymbolTop(target);
const targetMain = isSymbolMain(targetRootSymbol) ? targetRootSymbol : getSymbolMain(targetRootSymbol)
const sourceRootSymbol = getSymbolTop(source as Component)
const sourceMain = isSymbolMain(sourceRootSymbol) ? sourceRootSymbol : getSymbolMain(sourceRootSymbol)
const targetMain = isSymbolMain(targetRootSymbol) ? targetRootSymbol : getSymbolMain(targetRootSymbol);
const sourceRootSymbol = getSymbolTop(source as Component);
const sourceMain = isSymbolMain(sourceRootSymbol) ? sourceRootSymbol : getSymbolMain(sourceRootSymbol);
const sameRoot = targetMain === sourceMain;
const differentInstance = targetRootSymbol !== sourceRootSymbol
const differentInstance = targetRootSymbol !== sourceRootSymbol;
if (sameRoot && differentInstance) return { ...result, reason: CanMoveReason.TargetReject };
}

10
packages/core/test/specs/dom_components/index.ts

@ -339,20 +339,20 @@ describe('DOM Components', () => {
const source = obj.addSymbol(mainSymbol) as Component;
expect(obj.canMove(mainSymbol, source)).toMatchObject({
result: false,
reason: CanMoveReason.TargetReject
reason: CanMoveReason.TargetReject,
});
expect(obj.canMove(target, source)).toMatchObject({
result: false,
reason: CanMoveReason.TargetReject
reason: CanMoveReason.TargetReject,
});
});
test('canMove returns true when source and target are in the same instance', () => {
test('canMove returns true when source and target are the same instance', () => {
const component = obj.addComponent('<div><p>child</p></div>') as Component;
const mainSymbol = obj.addSymbol(component) as Component;
const childSymbol = mainSymbol.components().at(0);
expect(obj.canMove(mainSymbol, childSymbol).result).toBe(true)
expect(obj.canMove(mainSymbol, childSymbol).result).toBe(true);
});
test('canMove returns false when source is not draggable in the target', () => {
@ -385,7 +385,7 @@ describe('DOM Components', () => {
expect(result.result).toBe(false);
expect(result.reason).toBe(CanMoveReason.TargetReject);
});
})
});
});
describe('Rendered components', () => {

Loading…
Cancel
Save