Skip to content

Commit

Permalink
ACS-6252 Unit tests for changes for app rules
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksanderSklorz committed Nov 21, 2023
1 parent 1b5e261 commit ac5889f
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions projects/aca-shared/rules/src/app.rules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,72 @@ describe('app.evaluators', () => {
expect(app.canManagePermissions(context)).toBe(true);
});
});

describe('areTagsEnabled', () => {
it('should call context.appConfig.get with correct parameters', () => {
const context: any = {
appConfig: {
get: jasmine.createSpy()
}
};

app.areTagsEnabled(context);
expect(context.appConfig.get).toHaveBeenCalledWith('plugins.tags', true);
});

it('should return true if get from appConfig returns true', () => {
expect(
app.areTagsEnabled({
appConfig: {
get: () => true
}
} as any)
).toBeTrue();
});

it('should return false if get from appConfig returns false', () => {
expect(
app.areTagsEnabled({
appConfig: {
get: () => false
}
} as any)
).toBeFalse();
});
});

describe('areCategoriesEnabled', () => {
it('should call context.appConfig.get with correct parameters', () => {
const context: any = {
appConfig: {
get: jasmine.createSpy()
}
};

app.areCategoriesEnabled(context);
expect(context.appConfig.get).toHaveBeenCalledWith('plugins.categories', true);
});

it('should return true if get from appConfig returns true', () => {
expect(
app.areCategoriesEnabled({
appConfig: {
get: () => true
}
} as any)
).toBeTrue();
});

it('should return false if get from appConfig returns false', () => {
expect(
app.areCategoriesEnabled({
appConfig: {
get: () => false
}
} as any)
).toBeFalse();
});
});
});

function createTestContext(): TestRuleContext {
Expand Down

0 comments on commit ac5889f

Please sign in to comment.