Skip to content

Instantly share code, notes, and snippets.

@vucalur
Last active September 22, 2016 20:59

Revisions

  1. vucalur revised this gist Jun 25, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion karma.conf.js
    Original file line number Diff line number Diff line change
    @@ -16,7 +16,7 @@ module.exports = function (config) {
    'app/scripts/**/*.coffee',
    'test/mock/**/*.coffee',
    'test/spec/**/*.coffee',
    'app/directiveTemplates/**/*.html' // HERE
    'app/templates/**/*.html' // HERE
    ],

    preprocessors: {
  2. vucalur revised this gist Oct 30, 2013. 3 changed files with 5 additions and 5 deletions.
    2 changes: 1 addition & 1 deletion app myDirective.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

    angular.module('someApp.directive').directive('myDirective', function () {
    return {
    templateUrl: 'templates/myDirective.html',
    templateUrl: 'templates/myDirective.html', // HERE
    ....
    }
    });
    6 changes: 3 additions & 3 deletions karma.conf.js
    Original file line number Diff line number Diff line change
    @@ -16,17 +16,17 @@ module.exports = function (config) {
    'app/scripts/**/*.coffee',
    'test/mock/**/*.coffee',
    'test/spec/**/*.coffee',
    'app/directiveTemplates/**/*.html'
    'app/directiveTemplates/**/*.html' // HERE
    ],

    preprocessors: {
    '**/*.coffee': 'coffee',
    'app/templates/**/*.html': 'ng-html2js'
    'app/templates/**/*.html': 'ng-html2js' // HERE
    },

    ngHtml2JsPreprocessor: {
    // strip this from the file path
    stripPrefix: 'app/'
    stripPrefix: 'app/' // HERE
    },

    autoWatch: true,
    2 changes: 1 addition & 1 deletion test myDirective.js
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,7 @@ describe('Directive: myDirective', function() {

    beforeEach(module('someApp.directive'));

    beforeEach(module('templates/myDirective.html', 'templates/myDirective.html')); // load module prepared by ng-html2js
    beforeEach(module('templates/myDirective.html', 'templates/myDirective.html')); // HERE. load module prepared by ng-html2js

    beforeEach(inject(function($compile, $rootScope) {
    scope = $rootScope.$new();
  3. vucalur revised this gist Oct 30, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions test myDirective.js
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@ describe('Directive: myDirective', function() {
    beforeEach(inject(function($compile, $rootScope) {
    scope = $rootScope.$new();
    // prepare scope in which your directive should be used
    // ...
    element = angular.element('<myDirective></myDirective>');
    $compile(element)(scope);
    scope = element.scope();
  4. vucalur revised this gist Oct 30, 2013. 2 changed files with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions app myDirective.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    // file: app/scripts/directives/myDirective.js

    angular.module('someApp.directive').directive('myDirective', function () {
    return {
    templateUrl: 'templates/myDirective.html',
    ....
    }
    });
    File renamed without changes.
  5. vucalur revised this gist Oct 30, 2013. 2 changed files with 25 additions and 6 deletions.
    2 changes: 2 additions & 0 deletions karma.conf.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    // file: karma.conf.js

    // Karma configuration
    // http://karma-runner.github.io/0.10/config/configuration-file.html

    29 changes: 23 additions & 6 deletions myDirective.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,24 @@
    angular.module('someApp.directive').directive('myDirective', function () {
    return {
    templateUrl: 'templates/myDirective.html',
    ....
    }
    });
    // file: test/spec/directives/myDirective.js

    describe('Directive: myDirective', function() {

    var element, scope;

    beforeEach(module('someApp.directive'));

    beforeEach(module('templates/myDirective.html', 'templates/myDirective.html')); // load module prepared by ng-html2js

    beforeEach(inject(function($compile, $rootScope) {
    scope = $rootScope.$new();
    // prepare scope in which your directive should be used
    element = angular.element('<myDirective></myDirective>');
    $compile(element)(scope);
    scope = element.scope();
    return scope.$apply();
    }));

    it('fancy-dancy test', inject(function($compile) {
    expect(element.text()).toBe('...');
    }));

    });
  6. vucalur created this gist Oct 30, 2013.
    35 changes: 35 additions & 0 deletions karma.conf.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    // Karma configuration
    // http://karma-runner.github.io/0.10/config/configuration-file.html

    module.exports = function (config) {
    config.set({
    basePath: '',

    frameworks: ['jasmine'],

    files: [
    'app/bower_components/angular/angular.js',
    'app/bower_components/angular-mocks/angular-mocks.js',
    'app/scripts/*.coffee',
    'app/scripts/**/*.coffee',
    'test/mock/**/*.coffee',
    'test/spec/**/*.coffee',
    'app/directiveTemplates/**/*.html'
    ],

    preprocessors: {
    '**/*.coffee': 'coffee',
    'app/templates/**/*.html': 'ng-html2js'
    },

    ngHtml2JsPreprocessor: {
    // strip this from the file path
    stripPrefix: 'app/'
    },

    autoWatch: true,

    ...

    });
    };
    7 changes: 7 additions & 0 deletions myDirective.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    angular.module('someApp.directive').directive('myDirective', function () {
    return {
    templateUrl: 'templates/myDirective.html',
    ....
    }
    });