This patch applies spaces after anonymous function expressions. This is consistent with how we lint function declarations. Change-Id: I9b330673daa632e8d22f0a506e41c9643bb821c7
82 lines
2.4 KiB
JavaScript
82 lines
2.4 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
var libDir = '../../../../generators/app/lib';
|
|
|
|
var license = require(libDir + '/component/license');
|
|
var projectBuilder = require(libDir + '/project_builder');
|
|
var pkgBuilder = require(libDir + '/pkg_builder');
|
|
var mocks = require('../../../helpers/mocks');
|
|
var mockGenerator;
|
|
|
|
describe('generator-openstack:lib/component/license', function () {
|
|
|
|
beforeEach(function () {
|
|
mockGenerator = mocks.buildGenerator();
|
|
projectBuilder.clear();
|
|
});
|
|
|
|
it('should define init, prompt, and configure',
|
|
function () {
|
|
expect(typeof license.init).toBe('function');
|
|
expect(typeof license.prompt).toBe('function');
|
|
expect(typeof license.configure).toBe('function');
|
|
});
|
|
|
|
describe('init()', function () {
|
|
it('should return a generator',
|
|
function () {
|
|
var outputGenerator = license.init(mockGenerator);
|
|
expect(outputGenerator).toEqual(mockGenerator);
|
|
});
|
|
|
|
it('should do nothing',
|
|
function () {
|
|
var spy = spyOn(mockGenerator.config, 'defaults');
|
|
license.init(mockGenerator);
|
|
expect(spy.calls.any()).toBeFalsy();
|
|
});
|
|
});
|
|
|
|
describe('prompt()', function () {
|
|
it('should return a generator',
|
|
function () {
|
|
var outputGenerator = license.prompt(mockGenerator);
|
|
expect(outputGenerator).toEqual(mockGenerator);
|
|
});
|
|
|
|
it('should do nothing',
|
|
function () {
|
|
var spy = spyOn(mockGenerator, 'prompt');
|
|
license.prompt(mockGenerator);
|
|
expect(spy.calls.any()).toBeFalsy();
|
|
});
|
|
});
|
|
|
|
describe('configure()', function () {
|
|
it('should return a generator',
|
|
function () {
|
|
var outputGenerator = license.configure(mockGenerator);
|
|
expect(outputGenerator).toEqual(mockGenerator);
|
|
});
|
|
|
|
it('should add license to the project files.',
|
|
function () {
|
|
license.configure(mockGenerator);
|
|
|
|
var files = projectBuilder.getIncludedFiles();
|
|
expect(files.length).toBe(1);
|
|
expect(files[0].from).toBe('LICENSE');
|
|
expect(files[0].to).toBe('LICENSE');
|
|
});
|
|
|
|
it('should add license to the package.json files.',
|
|
function () {
|
|
license.configure(mockGenerator);
|
|
|
|
var parsedResult = JSON.parse(pkgBuilder.toJSON());
|
|
expect(parsedResult.license).toBe("Apache-2.0");
|
|
});
|
|
});
|
|
});
|
|
})();
|