Skip to content

Commit

Permalink
fix(core): 🐛 fix route (object) resolution
Browse files Browse the repository at this point in the history
for a given object rule, if transition does not have that rule property, check is invalid
  • Loading branch information
thierrymichel committed Dec 12, 2019
1 parent 7eb8095 commit 1fb344f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions packages/core/__tests__/modules/store/store.check.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function runFunction(

// "strings" type

it('check inexisting "strings"', () => {
it('check valid for inexisting rule "strings"', () => {
const [rule] = store['_rules'].filter(r => r.name === 'namespace');
const expected = store['_check'](
{},
Expand Down Expand Up @@ -165,7 +165,7 @@ it('check array "strings" with "to"', () => {
});

// "object" type
it('check inexisting "object"', () => {
it('check valid for inexisting rule "object"', () => {
const [rule] = store['_rules'].filter(r => r.name === 'route');
const expected = store['_check'](
{},
Expand All @@ -178,7 +178,7 @@ it('check inexisting "object"', () => {
expect(match).toMatchObject({});
});

it('check non matching "object"', () => {
it('check invalid for non matching rule "object"', () => {
const transition = { route: 'r' };
const [rule] = store['_rules'].filter(r => r.name === 'route');
const data = { current: { route: null } as ISchemaPage };
Expand All @@ -189,7 +189,7 @@ it('check non matching "object"', () => {
match
);

expect(expected).toBeTruthy();
expect(expected).toBeFalsy();
expect(match).toMatchObject({});
});

Expand Down Expand Up @@ -243,7 +243,7 @@ it('check array "object" with "to"', () => {

// "function" type

it('check inexisting "function"', () => {
it('check valid for inexisting rule "function"', () => {
const [rule] = store['_rules'].filter(r => r.name === 'custom');
const expected = store['_check'](
{},
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/modules/Store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ export class Store {
if (names.indexOf(page[objRule].name) === -1) {
isValid = false;
}
} else {
isValid = false;
}
break;
}
Expand Down

0 comments on commit 1fb344f

Please sign in to comment.