utils/tests/path-events.spec.ts
ztimson d938996a66
Some checks failed
Build / Build NPM Project (push) Failing after 34s
Build / Publish Documentation (push) Has been skipped
Build / Tag Version (push) Has been skipped
+ Caching expiry strategies
+ Prefix PathEvents
2025-05-12 19:46:23 -04:00

44 lines
1.5 KiB
TypeScript

import {PathEvent} from '../src';
describe('Path Events', () => {
describe('malformed', () => {
test('starting slash', async () =>
expect(new PathEvent('/module').toString()).toEqual('module:*'));
test('trailing slash', async () =>
expect(new PathEvent('module/').toString()).toEqual('module:*'));
test('double slash', async () =>
expect(new PathEvent('module////path').toString()).toEqual('module/path:*'));
});
describe('methods', () => {
test('custom', async () => {
expect(new PathEvent('module:t').methods.includes('t')).toBeTruthy();
expect(new PathEvent('module:t').methods.includes('z')).toBeFalsy();
});
test('create', async () =>
expect(new PathEvent('module:crud').create).toBeTruthy());
test('read', async () =>
expect(new PathEvent('module:crud').read).toBeTruthy());
test('update', async () =>
expect(new PathEvent('module:crud').update).toBeTruthy());
test('delete', async () =>
expect(new PathEvent('module:crud').delete).toBeTruthy());
test('none', async () => {
const event = new PathEvent('module:n');
expect(event.none).toBeTruthy();
expect(event.create).toBeFalsy();
expect(event.read).toBeFalsy();
expect(event.update).toBeFalsy();
expect(event.delete).toBeFalsy()
});
test('wildcard', async () => {
const event = new PathEvent('module:*');
expect(event.none).toBeFalsy();
expect(event.create).toBeTruthy();
expect(event.read).toBeTruthy();
expect(event.update).toBeTruthy();
expect(event.delete).toBeTruthy()
});
});
});