UNPKG

boats

Version:

Beautiful Open / Async Template System - Write less yaml with BOATS and Nunjucks.

70 lines (69 loc) 3.78 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const buildIndexFromPath_1 = tslib_1.__importDefault(require("../../utils/buildIndexFromPath")); describe('glob check', () => { it('it does dumb pluralization without trim', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'university/model.yml' })).toEqual('UniversityModel'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'university/models.yml' })).toEqual('UniversityModels'); }); it('it does dumb pluralization with trim', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'university/model.yml', autoComponentIndexerOptions: 'Model' })).toEqual('University'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'university/models.yml', autoComponentIndexerOptions: 'Model' })).toEqual('Universitys'); }); it('it does dumb pluralization and only replaces last trim occurence ', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'model-code/model.yml', autoComponentIndexerOptions: 'Model' })).toEqual('ModelCode'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'model-code/models.yml', autoComponentIndexerOptions: 'Model' })).toEqual('ModelCodes'); }); it('it does fancy pluralization with trim', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'university/model.yml', autoComponentIndexerOptions: 'Model', enableFancyPluralization: true })).toEqual('University'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'university/models.yml', autoComponentIndexerOptions: 'Model', enableFancyPluralization: true })).toEqual('Universities'); }); it('it does fancy pluralization with trim, adding an extra "s" when needed', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'sheep/model.yml', autoComponentIndexerOptions: 'Model', enableFancyPluralization: true })).toEqual('Sheep'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'sheep/models.yml', autoComponentIndexerOptions: 'Model', enableFancyPluralization: true })).toEqual('Sheeps'); }); it('it does fancy pluralization with trim when name ends with "s"', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'address/model.yml', autoComponentIndexerOptions: 'Model', enableFancyPluralization: true })).toEqual('Address'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'address/models.yml', autoComponentIndexerOptions: 'Model', enableFancyPluralization: true })).toEqual('Addresses'); }); it('it does fancy pluralization and only replaces last trim occurence ', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'model-code/model.yml', autoComponentIndexerOptions: 'Model' })).toEqual('ModelCode'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'model-code/models.yml', autoComponentIndexerOptions: 'Model' })).toEqual('ModelCodes'); }); it('drops basename when in trimOpts', () => { expect((0, buildIndexFromPath_1.default)({ cleanPath: 'cool/weather/weather.yml', autoComponentIndexerOptions: { dropBaseName: true } })).toEqual('CoolWeather'); expect((0, buildIndexFromPath_1.default)({ cleanPath: 'cool/weather/weather.yml', autoComponentIndexerOptions: { dropBaseName: true }, enableFancyPluralization: true })).toEqual('CoolWeather'); }); });