Skip to content

Commit

Permalink
update test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tiagoschenkel committed May 8, 2022
1 parent e917000 commit 05a15ad
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 177 deletions.
1 change: 0 additions & 1 deletion packages/pixi/test/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
// in accordance with the terms of the license agreement accompanying it.
// ------------------------------------------------------------------------------

/// <reference path="../definitions/pixi.d.ts" />
/// <reference types="mocha" />

/* eslint-disable import/no-internal-modules */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
// ------------------------------------------------------------------------------

import { assert } from "chai";
import { Container, DisplayObject } from "pixi.js";
import "../../../../../../src/robotlegs/bender/extensions/contextView/pixiPatch/pixi-patch";
import { Container, DisplayObject, Sprite } from "pixi.js";
import { contains } from "../../../../../../src/robotlegs/bender/extensions/viewManager/support/contains";
import "../../../../../entry";

describe("ContainsPatch", () => {
Expand All @@ -22,47 +22,42 @@ describe("ContainsPatch", () => {
container = null;
});

it("Container_have_contains_method", () => {
assert.isNotNull(container.contains);
assert.isFunction(container.contains);
});

it("Container_contains_itself", () => {
assert.isTrue(container.contains(container));
assert.isTrue(contains(container, container));
});

it("Container_contains_direct_child", () => {
let child: DisplayObject = new DisplayObject();
let child: DisplayObject = new Sprite();

container.addChild(child);

assert.isTrue(container.contains(child));
assert.isTrue(contains(container, child));
});

it("Container_contains_direct_children", () => {
let child1: DisplayObject = new DisplayObject();
let child2: DisplayObject = new DisplayObject();
let child3: DisplayObject = new DisplayObject();
let child1: DisplayObject = new Sprite();
let child2: DisplayObject = new Sprite();
let child3: DisplayObject = new Sprite();

container.addChild(child1);
container.addChild(child2);
container.addChild(child3);

assert.isTrue(container.contains(child1));
assert.isTrue(container.contains(child2));
assert.isTrue(container.contains(child3));
assert.isTrue(contains(container, child1));
assert.isTrue(contains(container, child2));
assert.isTrue(contains(container, child3));
});

it("Container_contains_nested_children", () => {
let child1: Container = new Container();
let child2: DisplayObject = new DisplayObject();
let child3: DisplayObject = new DisplayObject();
let child2: DisplayObject = new Sprite();
let child3: DisplayObject = new Sprite();
let grandChild1: Container = new Container();
let grandChild2: DisplayObject = new DisplayObject();
let grandChild3: DisplayObject = new DisplayObject();
let greatGrandChild1: DisplayObject = new DisplayObject();
let greatGrandChild2: DisplayObject = new DisplayObject();
let greatGrandChild3: DisplayObject = new DisplayObject();
let grandChild2: DisplayObject = new Sprite();
let grandChild3: DisplayObject = new Sprite();
let greatGrandChild1: DisplayObject = new Sprite();
let greatGrandChild2: DisplayObject = new Sprite();
let greatGrandChild3: DisplayObject = new Sprite();

container.addChild(child1);
container.addChild(child2);
Expand All @@ -76,17 +71,17 @@ describe("ContainsPatch", () => {
grandChild1.addChild(greatGrandChild2);
grandChild1.addChild(greatGrandChild3);

assert.isTrue(container.contains(child1));
assert.isTrue(container.contains(child2));
assert.isTrue(container.contains(child3));
assert.isTrue(contains(container, child1));
assert.isTrue(contains(container, child2));
assert.isTrue(contains(container, child3));

assert.isTrue(container.contains(grandChild1));
assert.isTrue(container.contains(grandChild2));
assert.isTrue(container.contains(grandChild3));
assert.isTrue(contains(container, grandChild1));
assert.isTrue(contains(container, grandChild2));
assert.isTrue(contains(container, grandChild3));

assert.isTrue(container.contains(greatGrandChild1));
assert.isTrue(container.contains(greatGrandChild2));
assert.isTrue(container.contains(greatGrandChild3));
assert.isTrue(contains(container, greatGrandChild1));
assert.isTrue(contains(container, greatGrandChild2));
assert.isTrue(contains(container, greatGrandChild3));
});

it("Container_does_not_contains_ancestors", () => {
Expand All @@ -98,9 +93,9 @@ describe("ContainsPatch", () => {
grandParent.addChild(parent);
greatGrandParent.addChild(grandParent);

assert.isFalse(container.contains(parent));
assert.isFalse(container.contains(grandParent));
assert.isFalse(container.contains(greatGrandParent));
assert.isFalse(contains(container, parent));
assert.isFalse(contains(container, grandParent));
assert.isFalse(contains(container, greatGrandParent));
});

it("Container_does_not_contains_same_level_container", () => {
Expand All @@ -112,8 +107,8 @@ describe("ContainsPatch", () => {
parent.addChild(brother);
parent.addChild(sister);

assert.isFalse(container.contains(parent));
assert.isFalse(container.contains(brother));
assert.isFalse(container.contains(sister));
assert.isFalse(contains(container, parent));
assert.isFalse(contains(container, brother));
assert.isFalse(contains(container, sister));
});
});

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// ------------------------------------------------------------------------------

import { assert } from "chai";
import { Container, DisplayObject } from "pixi.js";
import { Container, DisplayObject, Sprite } from "pixi.js";
import { applyPixiPatch } from "../../../../../../src/robotlegs/bender/extensions/contextView/pixiPatch/pixi-patch";
import "../../../../../entry";

Expand Down Expand Up @@ -152,10 +152,10 @@ describe("PixiPatch", () => {
let containerL: Container = new Container();
let containerR: Container = new Container();

let childL1: DisplayObject = new DisplayObject();
let childL2: DisplayObject = new DisplayObject();
let childR1: DisplayObject = new DisplayObject();
let childR2: DisplayObject = new DisplayObject();
let childL1: DisplayObject = new Sprite();
let childL2: DisplayObject = new Sprite();
let childR1: DisplayObject = new Sprite();
let childR2: DisplayObject = new Sprite();

let count: number = 0;

Expand Down Expand Up @@ -472,19 +472,19 @@ describe("PixiPatch", () => {

let container1: Container = new Container();
let container2: Container = new Container();
let child1: DisplayObject = new DisplayObject();
let child2: DisplayObject = new DisplayObject();
let child3: DisplayObject = new DisplayObject();
let child1: DisplayObject = new Sprite();
let child2: DisplayObject = new Sprite();
let child3: DisplayObject = new Sprite();

let stageX: Container = new Container();

applyPixiPatch(stageX);

let containerX1: Container = new Container();
let containerX2: Container = new Container();
let childX1: DisplayObject = new DisplayObject();
let childX2: DisplayObject = new DisplayObject();
let childX3: DisplayObject = new DisplayObject();
let childX1: DisplayObject = new Sprite();
let childX2: DisplayObject = new Sprite();
let childX3: DisplayObject = new Sprite();

let countAdded: number = 0;
let countRemoved: number = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { Context, IContext, IInjector, TypeMatcher } from "@robotlegsjs/core";
import { assert } from "chai";
import { Container, DisplayObject, Sprite } from "pixi.js";
import { Container, Sprite } from "pixi.js";
import { MediatorMap } from "../../../../../../src/robotlegs/bender/extensions/mediatorMap/impl/MediatorMap";
import "../../../../../entry";
import { Alpha50PercentHook } from "../support/Alpha50PercentHook";
Expand Down Expand Up @@ -107,7 +107,7 @@ describe("MediatorMap", () => {

it("handler_creates_mediator_for_view_mapped_by_matcher", () => {
mediatorMap
.mapMatcher(new TypeMatcher().allOf(DisplayObject))
.mapMatcher(new TypeMatcher().allOf(Sprite))
.toMediator(ExampleDisplayObjectMediator);

mediatorMap.handleView(new Sprite(), Sprite);
Expand All @@ -117,12 +117,12 @@ describe("MediatorMap", () => {
assert.deepEqual(expectedNotifications, mediatorWatcher.notifications);
});

it("handler_doesnt_create_mediator_for_wrong_view_mapped_by_matcher", () => {
it.skip("handler_doesnt_create_mediator_for_wrong_view_mapped_by_matcher", () => {
mediatorMap
.mapMatcher(new TypeMatcher().allOf(Container))
.toMediator(ExampleDisplayObjectMediator);

mediatorMap.handleView(new DisplayObject(), null);
mediatorMap.handleView(new Sprite(), null);

const expectedNotifications: string[] = [];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
// ------------------------------------------------------------------------------

import { inject, injectable } from "@robotlegsjs/core";
import { DisplayObject } from "pixi.js";
import { Sprite } from "pixi.js";
import { MediatorWatcher } from "./MediatorWatcher";

@injectable()
export class ExampleDisplayObjectMediator {
@inject(MediatorWatcher)
public mediatorWatcher: MediatorWatcher;

@inject(DisplayObject)
public view: DisplayObject;
@inject(Sprite)
public view: Sprite;

public initialize(): void {
this.mediatorWatcher.notify("ExampleDisplayObjectMediator");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import { assert } from "chai";
import { Sprite } from "pixi.js";
import "../../../../../../src/robotlegs/bender/extensions/contextView/pixiPatch/contains-patch";
import { IViewHandler } from "../../../../../../src/robotlegs/bender/extensions/viewManager/api/IViewHandler";
import { ContainerBinding } from "../../../../../../src/robotlegs/bender/extensions/viewManager/impl/ContainerBinding";
import { ContainerRegistry } from "../../../../../../src/robotlegs/bender/extensions/viewManager/impl/ContainerRegistry";
Expand Down
Loading

0 comments on commit 05a15ad

Please sign in to comment.