mirror of
https://github.com/strapi/strapi.git
synced 2025-07-21 07:57:45 +00:00
26 lines
820 B
JavaScript
26 lines
820 B
JavaScript
'use strict';
|
|
|
|
const { toPlural, toSingular, toInputName } = require('../naming');
|
|
|
|
describe('Name util', () => {
|
|
it('Pluralizes with camelcase', () => {
|
|
expect(toPlural('post')).toBe('posts');
|
|
expect(toPlural('posts')).toBe('posts');
|
|
expect(toPlural('Posts')).toBe('posts');
|
|
expect(toPlural('home-page')).toBe('homePages');
|
|
});
|
|
|
|
it('Casts to singular with camelcase', () => {
|
|
expect(toSingular('post')).toBe('post');
|
|
expect(toSingular('posts')).toBe('post');
|
|
expect(toSingular('Posts')).toBe('post');
|
|
expect(toSingular('home-pages')).toBe('homePage');
|
|
});
|
|
|
|
it('Generates valid input type names', () => {
|
|
expect(toInputName('post')).toBe('PostInput');
|
|
expect(toInputName('posts')).toBe('PostInput');
|
|
expect(toInputName('home-page')).toBe('HomePageInput');
|
|
});
|
|
});
|