Skip to content

Instantly share code, notes, and snippets.

@JeffryGonzalez
Last active December 6, 2016 11:18
Show Gist options
  • Select an option

  • Save JeffryGonzalez/8c15627901a28732a4e6f997f0b2bdbd to your computer and use it in GitHub Desktop.

Select an option

Save JeffryGonzalez/8c15627901a28732a4e6f997f0b2bdbd to your computer and use it in GitHub Desktop.
/*
// Place your snippets for typescript.json here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, ${id} and ${id:label} and ${1:label} for variables. Variables with the same id are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
*/
{
"Angular 2 Module": {
"prefix": "ng2module",
"body": [
"import { NgModule } from '@angular/core';",
"",
"",
"@NgModule({",
" declarations: [",
" ],",
" exports: [",
" ]",
"})",
"export class ${1:ModuleName} {}$2"
],
"description": "Your snippet description here."
},
"Angular 2 Component": {
"prefix": "ng2component",
"body": [
"import { Component } from '@angular/core';",
"",
"@Component({",
" template: `<h3>${1:Message}</h3>`",
"})",
"export class ${2:ComponentName} {}$3"
],
"description": "Your snippet description here."
},
"afterEach": {
"prefix": "ae",
"body": "\nafterEach(() => {\n\t$1\n});\n\t",
"description": "afterEach function is called once after each spec"
},
"beforeEach": {
"prefix": "be",
"body": "\nbeforeEach(() => {\n\t$1\n});\n\t",
"description": "beforeEach function is called once before each spec"
},
"callsAll": {
"prefix": "ca",
"body": "${1:spy}.calls.all()\n\t",
"description": "returns the context (the this) and arguments passed all calls"
},
"callsAllArgs": {
"prefix": "caa",
"body": "${1:spy}.calls.allArgs()\n\t",
"description": "returns the arguments to all calls"
},
"callsAny": {
"prefix": "ca",
"body": "${1:spy}.calls.any()\n\t",
"description": "returns false if the spy has not been called at all, and then true once at least one call happens"
},
"callsArgsFor": {
"prefix": "caf",
"body": "${1:spy}.calls.argsFor(${2:call number})\n\t",
"description": "returns the arguments passed to call number index"
},
"callsCount": {
"prefix": "cc",
"body": "${1:spy}.calls.count()\n\t",
"description": "returns the number of times the spy was called"
},
"callsFirst": {
"prefix": "cf",
"body": "${1:spy}.calls.first()\n\t",
"description": "returns the context (the this) and arguments for the first call"
},
"callsMostRescent": {
"prefix": "cmr",
"body": "${1:spy}.calls.mostRecent()\n\t",
"description": "returns the context (the this) and arguments for the most recent call"
},
"callsReset": {
"prefix": "cr",
"body": "${1:spy}.calls.reset()\n\t",
"description": "clears all tracking for a spy"
},
"createSpy": {
"prefix": "cs",
"body": "jasmine.createSpy('${1:name}');$0",
"description": "creates a “bare” spy"
},
"createSpyObject": {
"prefix": "cso",
"body": "jasmine.createSpyObj('${1:spy name}', ['${2:method name}'$3]);$0",
"description": "creates a mock with multiple spies"
},
"describe": {
"prefix": "desc",
"body": "\ndescribe('${1:Name of the group}', () => {\n\t$2\n});\n\t",
"description": "creates a suite of tests"
},
"expext": {
"prefix": "exp",
"body": "expect($1)$0",
"description": "takes a value, called the actual." },
"focusDescribe": {
"prefix": "fdesc",
"body": "\nfdescribe('${1:Name of the group}', () => {\n $2\n});\n ",
"description": "focused describe" },
"focusedIt": {
"prefix": "fit",
"body": "\nfit('${1:should behave...}', () => {\n $2\n});\n ",
"description": "focused it" },
"it": {
"prefix": "it",
"body": "\nit('${1:should behave...}', () => {\n\t$2\n});\n\t",
"description": "creates a test method" },
"any": {
"prefix": "any",
"body": "jasmine.any($1)$0",
"description": "akes a constructor or “class” name as an expected value. It returns true if the constructor matches the constructor of the actual value" },
"objectContaining": {
"prefix": "oc",
"body": "jasmine.objectContaining('${1:key}': ${2:value}\\}})$0",
"description": "when an expectation only cares about certain key/value pairs in the actual" },
"notToBe": {
"prefix": "nb",
"body": "expect($1).not.toBe($2);$0\n\t",
"description": "expects an object - value not to be equal" },
"notToBleCloseTo": {
"prefix": "nct",
"body": "expect($1).not.toBeCloseTo(${2:number}, ${3:delta});$0\n\t",
"description": "expects a value not to be close to another value" },
"notToBeDefined": {
"prefix": "nd",
"body": "expect($1).not.toBeDefined();$0\n\t",
"description": "expects the argument is not defined" },
"notToBeFalsef": {
"prefix": "nf",
"body": "expect($1).not.toBeFalsy();$0\n\t",
"description": "expects the argument not to be false" },
"notToBeGreaterThan": {
"prefix": "ngt",
"body": "expect($1).not.toBeGreaterThan($2);$0\n\t",
"description": "expects the argument not to be greater than" },
"notToBeLessThanlt": {
"prefix": "nlt",
"body": "expect($1).not.toBeLessThan($2);$0\n\t",
"description": "expects the argument not to be less than" },
"notToBeNull": {
"prefix": "nn",
"body": "expect($1).not.toBeNull();$0\n\t",
"description": "expects the argument not to be null" },
"notToBeTruthy": {
"prefix": "nt",
"body": "expect($1).not.toBeTruthy();$0\n\t",
"description": "expects the argument not to be truthy" },
"notToBeUndefined": {
"prefix": "nu",
"body": "expect($1).not.toBeUndefined();$0\n\t",
"description": "expects the argument not to be undefined" },
"notToContain": {
"prefix": "nc",
"body": "expect(${1:array}).not.toContain(${2:item});$0\n\t",
"description": "expects the array does not contain the argument" },
"notToEqual": {
"prefix": "ne",
"body": "expect($1).not.toEqual($2);$0\n\t",
"description": "expects the first argument not to be equal to the second one" },
"notToMatch": {
"prefix": "nm",
"body": "expect($1).not.toMatch($2);$0\n\t",
"description": "expects the first argument not to match the second one" },
"notToThrow": {
"prefix": "nt",
"body": "expect($1).not.toThrow();$0\n\t",
"description": "expects the argument not to throw" },
"spyOnAndCallFake": {
"prefix": "scf",
"body": "spyOn(${1:object}, '${2:method}').and.callFake(${3:() => \\{\n $4\n\\}});$0\n ",
"description": "all calls to the spy will delegate to the supplied function" },
"spyOnAndCallThrough": {
"prefix": "sct",
"body": "spyOn(${1:object}, '${2:method}').and.callThrough();$0",
"description": "tracks all calls to it and delegates to the actual implementation" },
"spyOnAndReturnValue": {
"prefix": "srv",
"body": "spyOn(${1:object}, '${2:method}').and.returnValue('${3:value}');$0",
"description": "all calls to the function will return a specific value" },
"spyOnAndStub": {
"prefix": "ss",
"body": "spyOn(${1:object}, '${2:method}').and.stub();$0",
"description": "The original stubbing behavior is returned at any time" },
"spyOnAndThrowError": {
"prefix": "ste",
"body": "spyOn(${1:object}, '${2:method}').and.throwError('${3:error}');$0",
"description": "all calls to the spy will throw the specified value as an error" },
"spyOn": {
"prefix": "so",
"body": "spyOn(${1:object}, '${2:method}')$3;$0\n\t",
"description": "creates a spy for the specified method" },
"toBe": {
"prefix": "tb",
"body": "expect($1).toBe($2);$0\n\t",
"description": "expects the first argument to be equal with the second one" },
"toBeCloseTo": {
"prefix": "tbct",
"body": "expect($1).toBeCloseTo(${2:number}, ${3:delta});$0\n\t",
"description": "expects the first argument to be close to the second one base on the delta" },
"toBeDefined": {
"prefix": "tbd",
"body": "expect($1).toBeDefined();$0\n\t",
"description": "expects the argument is defined" },
"toBeFalsy": {
"prefix": "tbf",
"body": "expect($1).toBeFalsy();$0\n\t",
"description": "expects the argument is falsy" },
"toBeGreaterThan": {
"prefix": "tbgt",
"body": "expect($1).toBeGreaterThan($2);$0\n\t",
"description": "expects the argument is greater than" },
"toBeLessThan": {
"prefix": "tblt",
"body": "expect($1).toBeLessThan($2);$0\n\t",
"description": "expects the argument is less than" },
"toBeNull": {
"prefix": "tbn",
"body": "expect($1).toBeNull();$0\n\t",
"description": "expects the argument is null" },
"toBeTruthy": {
"prefix": "tbt",
"body": "expect($1).toBeTruthy();$0\n\t",
"description": "expects the argument is truthy" },
"toBeUndefined": {
"prefix": "tbu",
"body": "expect($1).toBeUndefined();$0\n\t",
"description": "expects the argument is undefined" },
"toContain": {
"prefix": "tc",
"body": "expect(${1:array}).toContain(${2:item});$0\n\t",
"description": "expects the array contains the argument" },
"toEqual": {
"prefix": "te",
"body": "expect($1).toEqual($2);$0\n\t",
"description": "expects the first argument to be equal with the second one" },
"toHaveBeenCalled": {
"prefix": "thbc",
"body": "expect($1).toHaveBeenCalled();$0\n\t",
"description": "returns true if the spy was called" },
"toHaveBeenCalledWith": {
"prefix": "thbcw",
"body": "expect($1).toHaveBeenCalledWith(${2:params});$0\n\t",
"description": "he toHaveBeenCalled matcher will return true if the argument list matches any of the recorded calls to the spy" },
"toMatch": {
"prefix": "tm",
"body": "expect($1).toMatch($2);$0\n\t",
"description": "returns true if the argument matches the second value" },
"toThrow": {
"prefix": "tt",
"body": "expect($1).toThrow();$0\n\t",
"description": "expects that the specified method will throw" },
"toThrowError": {
"prefix": "tte",
"body": "expect($1).toThrowError(${2:error});$0",
"description": "expects that the specified method will throw with the specified error" },
"xDescribe": {
"prefix": "xdesc",
"body": "\nxdescribe('${1:Name of the group}', () => {\n\t$2\n});\n\t",
"description": "these suites and any specs inside them are skipped when run and thus their results will not appear in the results" },
"xIt": {
"prefix": "xit",
"body": "\nxit('${1:should behave...}', () => {\n\t$2\n});\n\t",
"description": "pending specs do not run, but their names will show up in the results as pending" }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment