Skip to content

Instantly share code, notes, and snippets.

@rossedfort
Last active July 18, 2016 21:17
Show Gist options
  • Save rossedfort/4bdee93be4dcd236e947cf73b72bd397 to your computer and use it in GitHub Desktop.
Save rossedfort/4bdee93be4dcd236e947cf73b72bd397 to your computer and use it in GitHub Desktop.

Step 1: Open your TypeScript user defined snippets: Code > Preferences > User Snippets > (select TypeScript)

Step 2: Paste this block of JSON between the 2 brackets that are already there. Make sure it's not in the commented out text.

	"Start a test 'it' block for a component": {
		"prefix": "itc",
		"body": [
			"it('Should $1',",
			"  inject([${2:component}], (component: ${2:component}) => {",
			"    $4",
			"  }));"
			],
		"description": "Start at test 'it' block for a component"
	},
	"Start a test 'it' block for a service": {
		"prefix": "its",
		"body": [
			"it('Should $1',",
			"  inject([${2:service}], (service: ${2:service}) => {",
			"    $4",
			"  }));"
		],
		"description": "Start at test 'it' block for a service"
	}

Step 3: Profit

Use for testing. when testing a component, type itc then tab. When testing a service, type its then tab. Your cursor will automatically be placed in the string to write the 'it' portion of the spec. When you're done completing the string, press tab to advance to the next section (which is the name of the component or service you are testing) It will select both of these so you can edit them at the same time. Finally press tab a third time to advance to writing the actual spec.

GIF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment