You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							45 lines
						
					
					
						
							1.8 KiB
						
					
					
				
			
		
		
	
	
							45 lines
						
					
					
						
							1.8 KiB
						
					
					
				"use strict";
 | 
						|
 | 
						|
var _path = _interopRequireDefault(require("path"));
 | 
						|
 | 
						|
var _adminjs = _interopRequireDefault(require("../../adminjs"));
 | 
						|
 | 
						|
var _utils = require("../utils");
 | 
						|
 | 
						|
var _generateUserComponentEntry = _interopRequireDefault(require("./generate-user-component-entry"));
 | 
						|
 | 
						|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
 | 
						|
 | 
						|
const exampleComponent = '../../../spec/fixtures/example-component';
 | 
						|
const entryPath = './';
 | 
						|
describe('generateUserComponentEntry', function () {
 | 
						|
  it('defines AdminJS.UserComponents', function () {
 | 
						|
    const adminJs = new _adminjs.default();
 | 
						|
    const entryFile = (0, _generateUserComponentEntry.default)(adminJs, entryPath);
 | 
						|
    expect(entryFile).to.have.string('AdminJS.UserComponents = {}\n');
 | 
						|
  });
 | 
						|
  it('adds env variables to the entry file', function () {
 | 
						|
    const adminJs = new _adminjs.default({
 | 
						|
      env: {
 | 
						|
        ENV_NAME: 'value'
 | 
						|
      }
 | 
						|
    });
 | 
						|
    const entryFile = (0, _generateUserComponentEntry.default)(adminJs, entryPath);
 | 
						|
    expect(entryFile).to.have.string('AdminJS.env.ENV_NAME = "value"\n');
 | 
						|
  });
 | 
						|
  it('adds components to the entry file', function () {
 | 
						|
    const loader = new _utils.ComponentLoader();
 | 
						|
    const componentId = loader.add('ExampleComponent', exampleComponent);
 | 
						|
    const adminJs = new _adminjs.default({
 | 
						|
      componentLoader: loader
 | 
						|
    });
 | 
						|
 | 
						|
    const rootEntryPath = _path.default.resolve(entryPath);
 | 
						|
 | 
						|
    const filePath = _path.default.relative(rootEntryPath, _path.default.normalize(_path.default.join(__dirname, exampleComponent)));
 | 
						|
 | 
						|
    const entryFile = (0, _generateUserComponentEntry.default)(adminJs, entryPath);
 | 
						|
    expect(entryFile).to.have.string([`import ${componentId} from '${filePath}'`, `AdminJS.UserComponents.${componentId} = ${componentId}`].join('\n'));
 | 
						|
    _adminjs.default.UserComponents = {};
 | 
						|
  });
 | 
						|
}); |