mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 01:57:35 -03:30
Fix configuration for testing UI lib code
* Fix Karma configuration * Fix test file imports * Add simple test case as an example
This commit is contained in:
parent
51855f1b82
commit
516d1057d1
@ -1,3 +1,3 @@
|
||||
<div class="panel-body at-Panel-body">
|
||||
<ng-transclude></ng-transclude>
|
||||
<ng-transclude></ng-transclude>
|
||||
</div>
|
||||
|
||||
@ -1,5 +1,11 @@
|
||||
// Import angular and angular-mocks to the global scope
|
||||
import 'angular';
|
||||
import 'angular-mocks';
|
||||
|
||||
import '../components';
|
||||
import './panel.spec';
|
||||
// Import custom Angular module dependencies
|
||||
import '../src/i18n';
|
||||
import '../lib/services';
|
||||
import '../lib/components';
|
||||
|
||||
// Import tests
|
||||
import './panel-body.spec';
|
||||
|
||||
@ -11,7 +11,7 @@ module.exports = config => {
|
||||
reporters: ['progress'],
|
||||
files: [
|
||||
'./index.js',
|
||||
'../components/**/*.html'
|
||||
'../lib/components/**/*.html'
|
||||
],
|
||||
plugins: [
|
||||
'karma-webpack',
|
||||
@ -20,14 +20,15 @@ module.exports = config => {
|
||||
'karma-ng-html2js-preprocessor'
|
||||
],
|
||||
preprocessors: {
|
||||
'../components/**/*.html': 'ng-html2js',
|
||||
'../components/index.js': 'webpack',
|
||||
'../lib/components/**/*.html': 'ng-html2js',
|
||||
'./index.js': 'webpack'
|
||||
},
|
||||
ngHtml2JsPreprocessor: {
|
||||
moduleName: 'at.test.templates',
|
||||
stripPrefix: path.resolve(__dirname, '..'),
|
||||
prependPrefix: 'static/partials'
|
||||
cacheIdFromPath: function (filepath) {
|
||||
filepath = filepath.replace(path.join(__dirname, '../lib'), '');
|
||||
return '/static/partials' + filepath;
|
||||
}
|
||||
},
|
||||
webpack: {
|
||||
module: {
|
||||
@ -36,7 +37,12 @@ module.exports = config => {
|
||||
test: /\.js$/,
|
||||
loader: 'babel',
|
||||
exclude: /node_modules/
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json',
|
||||
exclude: /node_modules/
|
||||
},
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
24
awx/ui/client/test/panel-body.spec.js
Normal file
24
awx/ui/client/test/panel-body.spec.js
Normal file
@ -0,0 +1,24 @@
|
||||
describe('Components | panel/body', () => {
|
||||
|
||||
let $compile;
|
||||
let $rootScope;
|
||||
|
||||
beforeEach(() => {
|
||||
angular.mock.module('at.lib.services')
|
||||
angular.mock.module('at.lib.components')
|
||||
angular.mock.module('at.test.templates');
|
||||
});
|
||||
|
||||
beforeEach(angular.mock.inject((_$compile_, _$rootScope_) => {
|
||||
$compile = _$compile_;
|
||||
$rootScope = _$rootScope_;
|
||||
}));
|
||||
|
||||
it('Should produce at-Panel-body HTML content', () => {
|
||||
let element = $compile('<at-panel-body>yo</at-panel-body>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(element.hasClass('at-Panel-body')).toBe(true);
|
||||
expect(element.html()).toContain('yo');
|
||||
});
|
||||
});
|
||||
@ -1,22 +0,0 @@
|
||||
describe('Components | panel', () => {
|
||||
|
||||
let $compile;
|
||||
let $rootScope;
|
||||
|
||||
beforeEach(done => {
|
||||
angular.mock.module('at.components')
|
||||
angular.mock.module('at.test.templates');
|
||||
|
||||
inject((_$compile_, _$rootScope_) => {
|
||||
$compile = _$compile_;
|
||||
$rootScope = _$rootScope_;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should load the navigation partial', function() {
|
||||
var element = $compile('<at-panel></at-panel>')($rootScope);
|
||||
$rootScope.$digest();
|
||||
|
||||
expect(element.html()).toContain('at-Panel');
|
||||
}); });
|
||||
Loading…
x
Reference in New Issue
Block a user