Skip to content

Instantly share code, notes, and snippets.

@GabiGrin
Created August 24, 2015 14:31
Show Gist options
  • Save GabiGrin/5229a2c7aca54801791a to your computer and use it in GitHub Desktop.
Save GabiGrin/5229a2c7aca54801791a to your computer and use it in GitHub Desktop.
snippers
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#
# '.source.coffee':
# 'Console log':
# 'prefix': 'log'
# 'body': 'console.log $1'
#
# This file uses CoffeeScript Object Notation (CSON).
# If you are unfamiliar with CSON, you can read more about it here:
# https://github.com/bevry/cson#what-is-cson
'.source.js':
'Console log':
'prefix': 'clog',
'body': 'console.log(\'$1\', $1)'
'.source.ts':
'Console log':
'prefix': 'clog',
'body': 'console.log(\'$1\', $1)'
'Exported class':
'prefix': 'eclass',
'body': """
export default class $1 {
/*@ngInject*/
constructor($2) {
}
$3
}
"""
'Directive':
'prefix': 'edirective'
'body': """
class $1Controller {
constructor() {}
}
export default function $2DirectiveFactory(): ng.IDirective {
return <ng.IDirective> {
restrict: 'E',
scope: {
attr: '='
},
template: require('./$3.tpl.html'),
controller: $1Controller,
controllerAs: 'ctrl',
bindToController: true
};
}
"""
'Directive test':
'prefix': 'dtest',
'body': """
describe('$1', function () {
let buildDirective;
beforeEach(function () {
angular.mock.module('$2');
inject(function ($compile, $rootScope: ng.IRootScopeService, $q) {
buildDirective = function () {
let scope: any = $rootScope.$new();
let $elem = $compile('<$3></$3>')(scope);
scope.$digest();
return $elem;
};
});
});
it('should $4', function () {
let $elem = buildDirective();
$5
});
});
"""
'Service test':
'prefix': 'stest',
'body': """
describe('$1', function () {
beforeEach(function () {
angular.mock.module('$2');
});
it('$3', inject(function ($4) {
$5
}));
});
"""
'"it" block':
'prefix': 'it',
'body': """
it('should $1', function () {
$3
});
"""
'"it" with inject':
'prefix': 'iti',
'body': """
it('should $1', inject(function ($2) {
$3
}));
"""
'"it" with external inject':
'prefix': 'itei',
'body': """
it('should $1', function () {
inject(function ($2){
$3;
});
});
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment