Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
import { createReset, Reset } from "features/reset";
|
2024-02-13 14:25:32 +00:00
|
|
|
import {
|
Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
branchedResetPropagation,
|
2024-02-13 14:25:32 +00:00
|
|
|
createTree,
|
|
|
|
createTreeNode,
|
|
|
|
defaultResetPropagation,
|
Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
invertedResetPropagation
|
2024-02-13 14:25:32 +00:00
|
|
|
} from "features/trees/tree";
|
Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
import { beforeAll, beforeEach, describe, expect, test } from "vitest";
|
|
|
|
import { Ref, ref } from "vue";
|
|
|
|
import "../utils";
|
2024-02-13 14:25:32 +00:00
|
|
|
|
|
|
|
describe("Reset propagation", () => {
|
|
|
|
let shouldReset: Ref<boolean>, shouldNotReset: Ref<boolean>;
|
Feature rewrite
- Removed `jsx()` and `JSXFunction`. You can now use `JSX.Element` like any other `Computable` value
- `joinJSX` now always requires a joiner. Just pass the array of elements or wrap them in `<>` and `</>` if there's no joiner
- Removed `coerceComponent`, `computeComponent`, and `computeOptionalComponent`; just use the `render` function now
- It's recommended to now do `<MyComponent />` instead of `<component :is="myComponent" />`
- All features no longer take the options as a type parameter, and all generic forms have been removed as a result
- Fixed `forceHideGoBack` not being respected
- Removed `deepUnref` as now things don't get unreffed before being passed into vue components by default
- Moved MarkNode to new wrapper, and removed existing `mark` properties
- Moved Tooltip to new wrapper, and made it take an options function instead of raw object
- VueFeature component now wraps all vue features, and applies styling, classes, and visibility in the wrapping div. It also adds the Node component so features don't need to
- `mergeAdjacent` now works with grids (perhaps should've used scss to reduce the amount of css this took)
- `CoercableComponent` renamed to `Renderable` since it should be used with `render`
- Replaced `isCoercableComponent` with `isJSXElement`
- Replaced `Computable` and `ProcessedComputable` with the vue built-ins `MaybeRefOrGetter` and `MaybeRef`
- `convertComputable` renamed to `processGetter`
- Also removed `GetComputableTypeWithDefault` and `GetComputableType`, which can similarly be replaced
- `dontMerge` is now a property on rows and columns rather than an undocumented css class you'd have to include on every feature within the row or column
- Fixed saves manager not being imported in addiction warning component
- Created `vueFeatureMixin` for simplifying the vue specific parts of a feature. Passes the component's properties in explicitly and directly from the feature itself
- All features should now return an object that includes props typed to omit the options object and satisfies the feature. This will ensure type correctness and pass-through custom properties. (see existing features for more thorough examples of changes)
- Replaced decorators with mixins, which won't require casting. Bonus amount decorators converted into generic bonus amount mixin. Removed effect decorator
- All `render` functions now return `JSX.Element`. The `JSX` variants (e.g. `renderJSX`) (except `joinJSX`) have been removed
- Moved all features that use the clickable component into the clickable folder
- Removed `small` property from clickable, since its a single css rule (`min-height: unset`) (you could add a small css class and pass small to any vue feature's classes property, though)
- Upgrades now use the clickable component
- Added ConversionType symbol
- Removed setDefault, just use `??=`
- Added isType function that uses a type symbol to check
- General cleanup
2024-11-19 14:32:45 +00:00
|
|
|
let goodReset: Reset, badReset: Reset;
|
2024-02-13 14:25:32 +00:00
|
|
|
beforeAll(() => {
|
|
|
|
shouldReset = ref(false);
|
|
|
|
shouldNotReset = ref(false);
|
|
|
|
goodReset = createReset(() => ({
|
|
|
|
thingsToReset: [],
|
|
|
|
onReset() {
|
|
|
|
shouldReset.value = true;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
badReset = createReset(() => ({
|
|
|
|
thingsToReset: [],
|
|
|
|
onReset() {
|
|
|
|
shouldNotReset.value = true;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
});
|
|
|
|
beforeEach(() => {
|
|
|
|
shouldReset.value = false;
|
|
|
|
shouldNotReset.value = false;
|
|
|
|
});
|
|
|
|
test("No resets", () => {
|
|
|
|
expect(() => {
|
|
|
|
const a = createTreeNode(() => ({}));
|
|
|
|
const b = createTreeNode(() => ({}));
|
|
|
|
const c = createTreeNode(() => ({}));
|
|
|
|
const tree = createTree(() => ({
|
|
|
|
nodes: [[a], [b], [c]]
|
|
|
|
}));
|
|
|
|
tree.reset(a);
|
|
|
|
}).not.toThrowError();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Do not propagate resets", () => {
|
|
|
|
const a = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const b = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const c = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const tree = createTree(() => ({
|
|
|
|
nodes: [[a], [b], [c]]
|
|
|
|
}));
|
|
|
|
tree.reset(b);
|
|
|
|
expect(shouldNotReset.value).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Default propagation", () => {
|
|
|
|
const a = createTreeNode(() => ({ reset: goodReset }));
|
|
|
|
const b = createTreeNode(() => ({}));
|
|
|
|
const c = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const tree = createTree(() => ({
|
|
|
|
nodes: [[a], [b], [c]],
|
|
|
|
resetPropagation: defaultResetPropagation
|
|
|
|
}));
|
|
|
|
tree.reset(b);
|
|
|
|
expect(shouldReset.value).toBe(true);
|
|
|
|
expect(shouldNotReset.value).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Inverted propagation", () => {
|
|
|
|
const a = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const b = createTreeNode(() => ({}));
|
|
|
|
const c = createTreeNode(() => ({ reset: goodReset }));
|
|
|
|
const tree = createTree(() => ({
|
|
|
|
nodes: [[a], [b], [c]],
|
|
|
|
resetPropagation: invertedResetPropagation
|
|
|
|
}));
|
|
|
|
tree.reset(b);
|
|
|
|
expect(shouldReset.value).toBe(true);
|
|
|
|
expect(shouldNotReset.value).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Branched propagation", () => {
|
|
|
|
const a = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const b = createTreeNode(() => ({}));
|
|
|
|
const c = createTreeNode(() => ({ reset: goodReset }));
|
|
|
|
const tree = createTree(() => ({
|
|
|
|
nodes: [[a, b, c]],
|
|
|
|
resetPropagation: branchedResetPropagation,
|
|
|
|
branches: [{ startNode: b, endNode: c }]
|
|
|
|
}));
|
|
|
|
tree.reset(b);
|
|
|
|
expect(shouldReset.value).toBe(true);
|
|
|
|
expect(shouldNotReset.value).toBe(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
test("Branched propagation not bi-directional", () => {
|
|
|
|
const a = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const b = createTreeNode(() => ({}));
|
|
|
|
const c = createTreeNode(() => ({ reset: badReset }));
|
|
|
|
const tree = createTree(() => ({
|
|
|
|
nodes: [[a, b, c]],
|
|
|
|
resetPropagation: branchedResetPropagation,
|
|
|
|
branches: [{ startNode: c, endNode: b }]
|
|
|
|
}));
|
|
|
|
tree.reset(b);
|
|
|
|
expect(shouldNotReset.value).toBe(false);
|
|
|
|
});
|
|
|
|
});
|