Skip to content

Commit

Permalink
moves MML character parsing tests to their proper package
Browse files Browse the repository at this point in the history
  • Loading branch information
TheCodeTherapy committed Feb 1, 2024
1 parent 97ced57 commit ba9f3a2
Show file tree
Hide file tree
Showing 8 changed files with 254 additions and 20 deletions.
3 changes: 1 addition & 2 deletions example/web-avatar-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
"iterate": "tsx ./build.ts --watch",
"type-check": "tsc --noEmit",
"lint": "eslint \"./{src,test}/**/*.{js,jsx,ts,tsx}\" --max-warnings 0",
"lint-fix": "eslint \"./{src,test}/**/*.{js,jsx,ts,tsx}\" --fix",
"test": "jest"
"lint-fix": "eslint \"./{src,test}/**/*.{js,jsx,ts,tsx}\" --fix"
},
"dependencies": {
"@mml-io/3d-web-client-core": "^0.11.0",
Expand Down
6 changes: 3 additions & 3 deletions example/web-avatar-client/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
"noEmit": true,
"baseUrl": ".",
"incremental": true,
"skipLibCheck": true
"skipLibCheck": true,
},
"include": ["src/**/*", "test/**/*", "./build.ts"],
"exclude": ["**/build/*", "types-src"]
"include": ["src/**/*", "./build.ts"],
"exclude": ["**/build/*", "types-src"],
}
File renamed without changes.
3 changes: 2 additions & 1 deletion packages/3d-web-avatar/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"start": "NODE_ENV=production node build/index.js 2>error.log",
"type-check": "tsc --noEmit",
"lint": "eslint \"./{src,test}/**/*.{js,jsx,ts,tsx}\" --max-warnings 0",
"lint-fix": "eslint \"./{src,test}/**/*.{js,jsx,ts,tsx}\" --fix"
"lint-fix": "eslint \"./{src,test}/**/*.{js,jsx,ts,tsx}\" --fix",
"test": "jest"
},
"dependencies": {
"react": "^18.2.0",
Expand Down
77 changes: 77 additions & 0 deletions packages/3d-web-avatar/test/collection.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{
"fullBody": [
{
"name": "Full Body 1",
"asset": "/assets/avatar/parts/SK_Outfit_Body_Male.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Body_Male.jpg"
}
],
"head": [
{
"name": "Dude Head 1",
"asset": "/assets/avatar/parts/SK_Outfit_Hat_02.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Hat_02.jpg"
},
{
"name": "Dude Head 2",
"asset": "/assets/avatar/parts/SK_Outfit_Hat_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Hat_01.jpg"
},
{
"name": "Dude Head 3",
"asset": "/assets/avatar/parts/SK_Outfit_Hat_03.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Hat_03.jpg"
}
],
"upperBody": [
{
"name": "Dude Upper Body 1",
"asset": "/assets/avatar/parts/SK_Outfit_One_Hoody_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_One_Hoody_01.jpg"
},
{
"name": "Dude Upper Body 2",
"asset": "/assets/avatar/parts/SK_Outfit_Two_Long_Coat_with_Collared_Shirt_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Two_Long_Coat_with_Collared_Shirt_01.jpg"
},
{
"name": "Dude Upper Body 3",
"asset": "/assets/avatar/parts/SK_Outfit_Three_Flanel_Shirt_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Three_Flanel_Shirt_01.jpg"
}
],
"lowerBody": [
{
"name": "Dude Lower Body 1",
"asset": "/assets/avatar/parts/SK_Outfit_Two_Tight_Joggers_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Two_Tight_Joggers_01.jpg"
},
{
"name": "Dude Lower Body 2",
"asset": "/assets/avatar/parts/SK_Outfit_Three_Tight_Jeans_with_Chain_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Three_Tight_Jeans_with_Chain_01.jpg"
},
{
"name": "Dude Lower Body 3",
"asset": "/assets/avatar/parts/SK_Outfit_One_Cargo_Shorts_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_One_Cargo_Shorts_01.jpg"
}
],
"feet": [
{
"name": "Dude Feet 1",
"asset": "/assets/avatar/parts/SK_Outfit_One_High_Tops_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_One_High_Tops_01.jpg"
},
{
"name": "Dude Feet 2",
"asset": "/assets/avatar/parts/SK_Outfit_Three_Mid_Tops_01.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Three_Mid_Tops_01.jpg"
},
{
"name": "Dude Feet 3",
"asset": "/assets/avatar/parts/SK_Outfit_Three_Mid_Tops_02.glb",
"thumb": "/assets/avatar/thumbs/SK_Outfit_Three_Mid_Tops_02.jpg"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
import { parseMMLDescription } from "@mml-io/3d-web-avatar/src/helpers/parseMMLDescription";
import { findAssetsInCollection } from "@mml-io/3d-web-avatar-editor-ui/src/findAssetsInCollection";

import collectionData from "../src/collection.json";

import collectionData from "./collection.json";
import {
semanticallyInvalidString,
threeNestedMCharacters,
Expand All @@ -20,12 +19,20 @@ import {
twoRedundantMCharacterswithThreeMModelsEach,
twoRedundantMCharacterswithThreeMModelsEachExpectedData,
validMCharacter,
validMCharacterWithSocketAttributes,
validMCharacterWithSocketAttributesExpectedData,
validMCharacterWithOneInvalidMModel,
validMCharacterWithRedundantMCharacterClosingTag,
validMCharacterWithRedundantMCharacterClosingTagExpectedData,
validMCharacterWithRedundantMModelClosingTag,
validMCharacterWithRedundantMModelClosingTagExpectedData,
validMCharacterWithTwoInvalidMModels,
validMCharacterWithSocketAndPosition,
validMCharacterWithSocketAndPositionExpectedData,
validMCharacterWithSocketAndRotationInOneAxis,
validMCharacterWithSocketAndRotationInOneAxisExpectedData,
validMCharacterWithNoSocket,
validMCharacterWithNoSocketExpectedData,
} from "./test-data";
import { extractNumberFromErrorMessage } from "./test-utils";

Expand Down Expand Up @@ -154,3 +161,28 @@ describe("Check <m-character> against collection", () => {
expect(checkCollection.accumulatedErrors).toHaveLength(2);
});
});

describe("Check <m-character> with socketed <m-model> objects", () => {
test("valid <m-character> tag with <m-model> socket attributes", async () => {
const [parsedData, errors] = parseMMLDescription(validMCharacterWithSocketAttributes);
expect(errors).toHaveLength(0);
expect(parsedData).toStrictEqual(validMCharacterWithSocketAttributesExpectedData);
});
test("valid <m-character> with only position attributes", async () => {
const [parsedData, errors] = parseMMLDescription(validMCharacterWithSocketAndPosition);
expect(errors).toHaveLength(0);
expect(parsedData).toStrictEqual(validMCharacterWithSocketAndPositionExpectedData);
});

test("valid <m-character> with rotation in only one axis", async () => {
const [parsedData, errors] = parseMMLDescription(validMCharacterWithSocketAndRotationInOneAxis);
expect(errors).toHaveLength(0);
expect(parsedData).toStrictEqual(validMCharacterWithSocketAndRotationInOneAxisExpectedData);
});

test("valid <m-character> with no socket attribute", async () => {
const [parsedData, errors] = parseMMLDescription(validMCharacterWithNoSocket);
expect(errors).toHaveLength(0);
expect(parsedData).toStrictEqual(validMCharacterWithNoSocketExpectedData);
});
});
Loading

0 comments on commit ba9f3a2

Please sign in to comment.