Skip to content

Commit

Permalink
restore app_entry_template tests
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Jul 12, 2018
1 parent 4f8fe21 commit 5357110
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 2 deletions.
49 changes: 49 additions & 0 deletions src/ui/ui_bundles/__tests__/app_entry_template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import sinon from 'sinon';
import expect from 'expect.js';

import { appEntryTemplate } from '../app_entry_template';

function createMockBundle() {
return {
getContext: sinon.stub().returns(''),
getRequires: sinon.stub().returns([])
};
}

describe('ui bundles / appEntryTemplate', () => {
it('embeds bundle.getContext() result', () => {
const bundle = createMockBundle();
bundle.getContext.returns('foo bar baz');
expect(appEntryTemplate(bundle)).to.contain('foo bar baz');
});

it('joins requires into list', () => {
const bundle = createMockBundle();
const requires = [
'foo',
'bar',
'baz'
];
bundle.getRequires.returns(requires);
expect(appEntryTemplate(bundle)).to.contain(requires.join('\n '));
});
});
4 changes: 2 additions & 2 deletions src/ui/ui_bundles/ui_bundles_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { makeRe } from 'minimatch';
import mkdirp from 'mkdirp';

import { UiBundle } from './ui_bundle';
import { newPlatformEntryTemplate } from './new_platform_entry_template';
import { appEntryTemplate } from './app_entry_template';

const mkdirpAsync = promisify(mkdirp);

Expand Down Expand Up @@ -84,7 +84,7 @@ export class UiBundlesController {
this.add({
id: uiApp.getId(),
modules: [uiApp.getMainModuleId()],
template: newPlatformEntryTemplate,
template: appEntryTemplate,
});
}
}
Expand Down

0 comments on commit 5357110

Please sign in to comment.