Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save madhums/2e9fb4138b6de6496b8f to your computer and use it in GitHub Desktop.
Save madhums/2e9fb4138b6de6496b8f to your computer and use it in GitHub Desktop.

Revisions

  1. @busypeoples busypeoples revised this gist Mar 13, 2015. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,11 @@
    ###Example Structure

    src/

    test/

    views/

    karma.conf.js

    Module.js
  2. @busypeoples busypeoples revised this gist Mar 13, 2015. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion AngularJS-ES6-Test-Skeleton
    Original file line number Diff line number Diff line change
    @@ -1 +0,0 @@
    --
  3. @busypeoples busypeoples revised this gist Mar 13, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions AngularJS-ES6-Test-Skeleton
    Original file line number Diff line number Diff line change
    @@ -0,0 +1 @@
    --
  4. @busypeoples busypeoples revised this gist Mar 13, 2015. 2 changed files with 6 additions and 1 deletion.
    4 changes: 4 additions & 0 deletions Module.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,4 @@
    import HelloWorldDirective from './src/HelloWorldDirective';

    angular.module('app', [])
    .directive('helloWorld', HelloWorldDirective);
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -5,4 +5,5 @@
    src/
    test/
    views/
    karma.conf.js
    karma.conf.js
    Module.js
  5. @busypeoples busypeoples revised this gist Mar 13, 2015. 2 changed files with 8 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions README
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    Quick set up for writing AngularJS tests in ES6 using Karma, Jasmine, Browserify and Stringify.

    Example Structure

    src/
    test/
    8 changes: 8 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    ###Quick set up for writing AngularJS tests in ES6 using Karma, Jasmine, Browserify and Stringify.

    ###Example Structure

    src/
    test/
    views/
    karma.conf.js
  6. @busypeoples busypeoples revised this gist Mar 13, 2015. 5 changed files with 5 additions and 1 deletion.
    File renamed without changes.
    File renamed without changes.
    6 changes: 5 additions & 1 deletion README
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,6 @@
    ###Quick set up for writing AngularJS tests in ES6 using Karma, Jasmine, Browserify and Stringify.
    Quick set up for writing AngularJS tests in ES6 using Karma, Jasmine, Browserify and Stringify.

    Example Structure

    src/
    test/
    File renamed without changes.
    File renamed without changes.
  7. @busypeoples busypeoples created this gist Mar 13, 2015.
    24 changes: 24 additions & 0 deletions HelloWorldDirective
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    /** src/HelloWorldDirective.js **/

    import helloWorldTemplate from './../views/hello-world.html';

    class HelloWorldController {
    constructor() {
    this.greet = 'Hello';
    }
    }

    function HelloWorldDirective() {
    return {
    scope: {
    name: '@'
    },
    controller: HelloWorldController,
    controllerAs: 'ctrl',
    bindToController: true,
    replace: true,
    template: helloWorldTemplate
    }
    }

    export default HelloWorldDirective;
    29 changes: 29 additions & 0 deletions HelloWorldDirective.test
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    /** test/HelloWorldDirective.js **/

    describe('The HelloWorldDirective', () => {

    let element, scope;

    beforeEach(angular.mock.module('app'));

    beforeEach(inject(function(_$rootScope_,_$compile_) {
    let $rootScope = _$rootScope_,
    $compile = _$compile_;

    scope = $rootScope.$new();

    element = angular.element('<hello-world data-name="{{ name }}"></hello-world>');

    $compile(element)(scope);

    }));

    it('should display the defined name', () => {
    let name = 'Some rendered text';

    scope.name = name;
    scope.$digest();

    expect(element.text()).toContain(`Hello ${name}`);
    });
    });
    2 changes: 2 additions & 0 deletions README
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    ###Quick set up for writing AngularJS tests in ES6 using Karma, Jasmine, Browserify and Stringify.

    2 changes: 2 additions & 0 deletions hello-world
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    <!-- views/hello-world.html -->
    <div>{{ ctrl.greet }} {{ ctrl.name }}</div>
    46 changes: 46 additions & 0 deletions karma.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    module.exports = function(config) {
    config.set({

    basePath: '',
    frameworks: ['browserify', 'jasmine'],

    files: [
    'node_modules/angular/angular.min.js',
    'node_modules/angular-mocks/angular-mocks.js',
    'Module.js',
    'views/*',
    'src/**/*.js',
    'test/**/*test.js'
    ],


    exclude: [
    ],

    preprocessors: {
    'Module.js': ['browserify'],
    'views/*' : ['browserify'],
    'src/**/*.js': ['browserify'],
    'test/**/*test.js': ['browserify']
    },

    browserify: {
    debug: true,
    transform: ['babelify', 'stringify']
    },

    reporters: ['progress'],

    port: 9876,

    colors: true,

    logLevel: config.LOG_DEBUG,

    autoWatch: true,

    browsers: ['PhantomJS'],

    singleRun: false
    });
    };