Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Adding and improving the jasmine snippets #11

Merged
merged 1 commit into from

2 participants

@claco
Owner

Thanks for taking some interest in this plugin and giving it some love!

@claco claco merged commit 6d17504 into claco:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 15, 2012
  1. @jvortmann
This page is out of date. Refresh to see the latest.
Showing with 266 additions and 15 deletions.
  1. +266 −15 snippets/jasmine.snippets
View
281 snippets/jasmine.snippets
@@ -1,35 +1,254 @@
+# Describe
+snippet d describe("...". function() { ... });
+ describe("${1:description}", function() {
+ ${2}
+ });${3}
+snippet des
+ describe("${1:description}", function() {
+ ${2}
+ });${3}
+
+# Describe with beforeEach and it
+snippet d describe("...". function() { beforeEach()... it...});
+ describe('${1:when...}', function () {
+ beforeEach(function () {
+ ${2}
+ });
+
+ it('${3:should...}', function () {
+ expect(${4:condition}).toEqual(${5});
+ });
+ });
snippet desc
describe('${1:when...}', function () {
- beforeEach(function () {
+ beforeEach(function () {
${2}
- });
+ });
- it('${3:should...}', function () {
- expect(${4:condition}).toEqual(${5});
- });
+ it('${3:should...}', function () {
+ expect(${4:condition}).toEqual(${5});
+ });
});
-snippet it
+# It
+snippet i it("...", function() { ... });...
+ it("${1:description}", function() {
+ ${2}
+ });${3}
+snippet it it("...", function() { ... });...
+ it("${1:description}", function() {
+ ${2}
+ });${3}
+
+snippet i it('...', function() { expect(...).toEqual(...); });
it('${1:should...}', function() {
expect(${2:condition}).toEqual(${3});
});
+snippet it it('...', function() { expect(...).toEqual(...); });
+ it('${1:should...}', function() {
+ expect(${2:condition}).toEqual(${3});
+ });
+
+# Any
+snippet any
+ jasmine.any(${1})
+# Before Each
+snippet b beforeEach(function() { ... });
+ beforeEach(function() {
+ ${1}
+ });
+snippet bef
+ beforeEach(function() {
+ ${1}
+ });
snippet before
beforeEach(function () {
- ${1}
+ ${1}
});
+# After Each
+snippet a afterEach(function() { ... });
+ afterEach(function() {
+ ${1}
+ });
+snippet aft
+ afterEach(function() {
+ ${1}
+ });
snippet after
afterEach(function () {
- ${1}
+ ${1}
});
+# Expect
+snippet e expect(...);...
+ expect(${1:target});${2}
+snippet ex
+ expect(${1:target});${2}
+
+#Expect to
+snippet e expect(...).to...();
+ expect(${1}).to${2}();
snippet expect
expect(${1}).to${2}();
+# Expect not to be defined
+snippet e expect(...).not.toBeDefined();...
+ expect(${1:target}).not.toBeDefined();${2}
+snippet notd
+ expect(${1:target}).not.toBeDefined();${2}
+
+# Expect not to be falsy
+snippet e expect(...).to.toBeFalsy();...
+ expect(${1:target}).not.toBeFalsy();${2}
+snippet notf
+ expect(${1:target}).not.toBeFalsy();${2}
+
+# Expect not to be null
+snippet e expect(...).not.toBeNull();...
+ expect(${1:target}).not.toBeNull();${2}
+snippet notn
+ expect(${1:target}).not.toBeNull();${2}
+
+# Expect to be truthy
+snippet e expect(...).not.toBeTruthy();...
+ expect(${1:target}).not.toBeTruthy();${2}
+snippet nott
+ expect(${1:target}).not.toBeTruthy();${2}
+
+# Expect not to contain
+snippet e expect(...).not.toContain(...);...
+ expect(${1:target}).not.toContain(${2:value});${3}
+snippet notc
+ expect(${1:target}).not.toContain(${2:value});${3}
+
+# Expect not to equal
+snippet e expect(...}).not.toEqual(...);...
+ expect(${1:target}).not.toEqual(${2:value});${3}
+snippet note
+ expect(${1:target}).not.toEqual(${2:value});${3}
+
+# Expect not to match
+snippet e expect(...).not.toBeDefined();...
+ expect(${1:target}).not.toBeDefined();${2}
+snippet notm
+ expect(${1:target}).not.toBeDefined();${2}
+
+# Expect not
+snippet e expect(...).not;...
+ expect(${1:target}).not;${2}
+snippet notx
+ expect(${1:target}).not;${2}
+
+# Expect to be defined
+snippet e expect(...).toBeDefined();...
+ expect(${1:target}).toBeDefined();${2}
+snippet ed
+ expect(${1:target}).toBeDefined();${2}
+
+# Expect to be falsy
+snippet e expect(...).toBeFalsy();...
+ expect(${1:target}).toBeFalsy();${2}
+snippet ef
+ expect(${1:target}).toBeFalsy();${2}
+
+# Expect to be null
+snippet e expect(...).toBeNull();...
+ expect(${1:target}).toBeNull();${2}
+snippet en
+ expect(${1:target}).toBeNull();${2}
+
+# Expect to be truthy
+snippet e expect(...).toBeTruthy();...
+ expect(${1:target}).toBeTruthy();${2}
+snippet et
+ expect(${1:target}).toBeTruthy();${2}
+
+# Expect to contain
+snippet e expect(...).toContain(...);...
+ expect(${1:target}).toContain(${2:value});${3}
+snippet ec
+ expect(${1:target}).toContain(${2:value});${3}
+
+# Expect to equal
+snippet e expect(...).toEqual(...);...
+ expect(${1:target}).toEqual(${2:value});${3}
+snippet ee
+ expect(${1:target}).toEqual(${2:value});${3}
+
+# Expect to match
+snippet e expect(...).toMatch(...);...
+ expect(${1:target}).toMatch(${2:pattern});${3}
+snippet em
+ expect(${1:target}).toMatch(${2:pattern});${3}
+
+# Expect was called with
+snippet e expect(...).wasCalledWith(...);...
+ expect(${1:target}).wasCalledWith(${2:arguments});${3}
+snippet escw
+ expect(${1:target}).wasCalledWith(${2:arguments});${3}
+
+# Expect was called
+snippet e expect(...).wasCalled();...
+ expect(${1:target}).wasCalled();${2}
+snippet esc
+ expect(${1:target}).wasCalled();${2}
+
+# Expect was not called with
+snippet e expect(...).wasNotCalledWith(...);...
+ expect(${1:target}).wasNotCalledWith(${2:arguments});${3}
+snippet notscw
+ expect(${1:target}).wasNotCalledWith(${2:arguments});${3}
+
+# Expect was not called
+snippet e expect(...).wasNotCalled();...
+ expect(${1:target}).wasNotCalled();${3}
+snippet notsc
+ expect(${1:target}).wasNotCalled();${3}
+
+# Spy on
+snippet s spyOn(..., "...");...
+ spyOn(${1:object}, "${2:method}");${3}
+snippet s spyOn(..., "...");
+ spyOn(${1:object}, "${2:method}");${3}
snippet spy
spyOn(${1:object}, '${2:method}');
+# Spy on and call fake
+snippet s spyOn(..., "...").andCallFake(...);...
+ spyOn(${1:object}, "${2:method}").andCallFake(${3:function});${4}
+snippet scf
+ spyOn(${1:object}, "${2:method}").andCallFake(${3:function});${4}
+
+# Spy on and call through
+snippet s spyOn(..., "...").andCallThrough();...
+ spyOn(${1:object}, "${2:method}").andCallThrough();${3}
+snippet sct
+ spyOn(${1:object}, "${2:method}").andCallThrough();${3}
+
+# Spy on and return
+snippet s spyOn(..., "...").andReturn(...);...
+ spyOn(${1:object}, "${2:method}").andReturn(${3:arguments});${4}
+snippet sr
+ spyOn(${1:object}, "${2:method}").andReturn(${3:arguments});${4}
+
+# Spy on and throw
+snippet s spyOn(..., "...").andThrow(...);...
+ spyOn(${1:object}, "${2:method}").andThrow(${3:exception});${4}
+snippet st
+ spyOn(${1:object}, "${2:method}").andThrow(${3:exception});${4}
+
+# Matcher
+snippet m to...: function { [init] ... return ...; },
+ to${1}: function() {
+ var summary = this.actual;
+ this.actual = summary.clone().wrap('<div>').parent().html();
+
+ ${2}
+
+ return ${3:false};
+ },
snippet matcher
to${1}: function() {
var summary = this.actual;
@@ -40,16 +259,48 @@ snippet matcher
return ${3:false};
},
+#Helper
+snippet h beforeEach(function() { this.addMatchers({ [matcher] } })
+ beforeEach(function() {
+ this.addMatchers({
+
+ to${1}: function() {
+ var summary = this.actual;
+ this.actual = summary.clone().wrap('<div>').parent().html();
+
+ ${2}
+
+ return ${3:false};
+ },
+ });
+ });
snippet helper
beforeEach(function() {
- this.addMatchers({
+ this.addMatchers({
- to${1}: function() {
- var summary = this.actual;
- this.actual = summary.clone().wrap('<div>').parent().html();
+ to${1}: function() {
+ var summary = this.actual;
+ this.actual = summary.clone().wrap('<div>').parent().html();
- ${2}
+ ${2}
- return ${3:false};
- },
+ return ${3:false};
+ },
+ });
});
+
+# Runs
+snippet r runs(function() { ... }); ...
+ runs(function() {
+ ${1}
+ });${2}
+snippet ru
+ runs(function() {
+ ${1}
+ });${2}
+
+# Waits
+snippet w waits(...);...
+ waits(${1});${2}
+snippet wa
+ waits(${1});${2}
Something went wrong with that request. Please try again.