Merge pull request #238 from gconsidine/ui/fix/lib-test-runner

Fix configuration for testing UI lib code
This commit is contained in:
Greg Considine
2017-08-10 09:36:12 -04:00
committed by GitHub
5 changed files with 45 additions and 31 deletions

View File

@@ -1,3 +1,3 @@
<div class="panel-body at-Panel-body"> <div class="panel-body at-Panel-body">
<ng-transclude></ng-transclude> <ng-transclude></ng-transclude>
</div> </div>

View File

@@ -1,5 +1,11 @@
// Import angular and angular-mocks to the global scope
import 'angular'; import 'angular';
import 'angular-mocks'; import 'angular-mocks';
import '../components'; // Import custom Angular module dependencies
import './panel.spec'; import '../src/i18n';
import '../lib/services';
import '../lib/components';
// Import tests
import './panel-body.spec';

View File

@@ -11,7 +11,7 @@ module.exports = config => {
reporters: ['progress'], reporters: ['progress'],
files: [ files: [
'./index.js', './index.js',
'../components/**/*.html' '../lib/components/**/*.html'
], ],
plugins: [ plugins: [
'karma-webpack', 'karma-webpack',
@@ -20,14 +20,15 @@ module.exports = config => {
'karma-ng-html2js-preprocessor' 'karma-ng-html2js-preprocessor'
], ],
preprocessors: { preprocessors: {
'../components/**/*.html': 'ng-html2js', '../lib/components/**/*.html': 'ng-html2js',
'../components/index.js': 'webpack',
'./index.js': 'webpack' './index.js': 'webpack'
}, },
ngHtml2JsPreprocessor: { ngHtml2JsPreprocessor: {
moduleName: 'at.test.templates', moduleName: 'at.test.templates',
stripPrefix: path.resolve(__dirname, '..'), cacheIdFromPath: function (filepath) {
prependPrefix: 'static/partials' filepath = filepath.replace(path.join(__dirname, '../lib'), '');
return '/static/partials' + filepath;
}
}, },
webpack: { webpack: {
module: { module: {
@@ -36,7 +37,12 @@ module.exports = config => {
test: /\.js$/, test: /\.js$/,
loader: 'babel', loader: 'babel',
exclude: /node_modules/ exclude: /node_modules/
} },
{
test: /\.json$/,
loader: 'json',
exclude: /node_modules/
},
] ]
} }
}, },

View 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');
});
});

View File

@@ -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');
}); });