mirror of
https://github.com/strapi/strapi.git
synced 2025-08-07 08:16:35 +00:00

* Split init to init & information endpoints Signed-off-by: Convly <jean-sebastien.herbaux@epitech.eu> * Add unit tests / Rename controller Signed-off-by: Convly <jean-sebastien.herbaux@epitech.eu> * Remove unnecessary comment Signed-off-by: Convly <jean-sebastien.herbaux@epitech.eu>
69 lines
1.6 KiB
JavaScript
69 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const adminController = require('../admin');
|
|
|
|
describe('Admin Controller', () => {
|
|
describe('init', () => {
|
|
beforeAll(() => {
|
|
global.strapi = {
|
|
config: {
|
|
get: jest.fn(() => 'foo'),
|
|
},
|
|
admin: {
|
|
services: {
|
|
user: {
|
|
exists: jest.fn(() => true),
|
|
},
|
|
},
|
|
},
|
|
};
|
|
});
|
|
|
|
test('Returns the uuid and if the app has admins', async () => {
|
|
const result = await adminController.init();
|
|
|
|
expect(global.strapi.config.get).toHaveBeenCalledWith('uuid', false);
|
|
expect(global.strapi.admin.services.user.exists).toHaveBeenCalled();
|
|
expect(result.data).toBeDefined();
|
|
expect(result.data).toStrictEqual({
|
|
uuid: 'foo',
|
|
hasAdmin: true,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('information', () => {
|
|
beforeAll(() => {
|
|
global.strapi = {
|
|
app: {
|
|
env: 'development',
|
|
},
|
|
config: {
|
|
get: jest.fn(
|
|
(key, value) =>
|
|
({
|
|
autoReload: undefined,
|
|
'info.strapi': '1.0.0',
|
|
}[key] || value)
|
|
),
|
|
},
|
|
EE: true,
|
|
};
|
|
});
|
|
|
|
test('Returns application information', async () => {
|
|
const result = await adminController.information();
|
|
|
|
expect(global.strapi.config.get).toHaveBeenCalledTimes(2);
|
|
expect(result.data).toBeDefined();
|
|
expect(result.data).toStrictEqual({
|
|
currentEnvironment: 'development',
|
|
autoReload: false,
|
|
strapiVersion: '1.0.0',
|
|
nodeVersion: process.version,
|
|
communityEdition: false,
|
|
});
|
|
});
|
|
});
|
|
});
|