boats
Version:
Beautiful Open / Async Template System - Write less yaml with BOATS and Nunjucks.
42 lines (41 loc) • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const Injector_1 = tslib_1.__importDefault(require("../Injector"));
describe('glob check', () => {
it('simple match', () => {
const currentPath = '/';
const paths = ['/'];
expect(Injector_1.default.globCheck(currentPath, paths, {}, 'GET')).toBe(true);
});
it('simple match', () => {
const currentPath = '/path/one';
const paths = ['/path/one'];
expect(Injector_1.default.globCheck(currentPath, paths, {}, 'GET')).toBe(true);
});
it('simple match on a specific method', () => {
const currentPath = '/path/one';
const paths = [{ path: '/path/one', methods: ['GET', 'POST'] }];
expect(Injector_1.default.globCheck(currentPath, paths, {}, 'GET')).toBe(true);
});
it('simple non-match on a specific method', () => {
const currentPath = '/path/one';
const paths = [{ path: '/path/one', methods: ['GET', 'POST'] }];
expect(Injector_1.default.globCheck(currentPath, paths, {}, 'PUT')).toBe(false);
});
it('wildcard', () => {
const currentPath = '/path/one/hello';
const paths = ['/path/one/*'];
expect(Injector_1.default.globCheck(currentPath, paths, {}, 'GET')).toBe(true);
});
it('simple match on a specific method', () => {
const currentPath = '/path/one/hello';
const paths = [{ path: '/path/one/*', methods: ['GET', 'POST'] }];
expect(Injector_1.default.globCheck(currentPath, paths, {}, 'GET')).toBe(true);
});
it('simple non-match on a specific method', () => {
const currentPath = '/path/one/hello';
const paths = [{ path: '/path/one/*', methods: ['GET', 'POST'] }];
expect(Injector_1.default.globCheck(currentPath, paths, {}, 'PUT')).toBe(false);
});
});