Socket
Socket
Sign inDemoInstall

grunt-contrib-templify

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-contrib-templify - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

specs/mode-angular/generic-spec.js

2

package.json
{
"name": "grunt-contrib-templify",
"version": "0.0.3",
"version": "0.0.4",
"description": "A simple project for quick and dirty conversion of HTML files to javascript for various cases, particularly unit testing.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -22,3 +22,3 @@ # grunt-contrib-templify

templify: {
//...
// ...
}

@@ -138,3 +138,3 @@ ```

mode: "karma-angular",
output: "spec/templates.js"
output: "specs/templates.js"
}

@@ -145,10 +145,59 @@ }

Once the grunt process is described, the templify:testing task will need to preceed the karma task for testing. The idea being that the generated javascript file will then be provided to karma, where the declarations for the templates to pass to angular are ready in a function named **__templifyTemplates**. Then inside the jasmine tests:
Once the grunt process is described, the templify:testing task will need to preceed the karma task for testing. The idea being that the generated javascript file will then be provided to karma, where the declarations for the templates to pass to angular are ready in a function named **__templifyTemplates**. Then inside the jasmine tests.
In Karma's Grunt declaration:
```javascript
//...
karma: {
options: {
// ...
files: [
// Dependencies...
"specs/templates.js",
// Tests...
]
},
// ...
}
```
In your Jasmine tests:
```javascript
// ...
/* Creates a beforeEach clause in Jasmine to bind the templates to the Template cache */
__templifyTemplates();
//...
// ...
```
Now when using angular later, the templates can be pulled from the $templateCache for use in unit and functional tests.
Now when using angular later, the templates can be pulled from the $templateCache for use in unit and functional tests.
For Example:
```javascript
describe("Templify Karma-Angular template processing", function() {
var $compile, $scope;
var template, html, element;
__templifyTemplates();
describe("Templating", function() {
beforeEach(inject(function(_$compile_, _$rootScope_) {
$compile = _$compile_;
$scope = _$rootScope_.$new();
}));
it("passes standard checks", inject(function($templateCache) {
$scope.title = "Titling";
$scope.paragraph = "This is some text";
template = $compile($templateCache.get("angular-template1.html"))($scope);
$scope.$digest();
html = template.html();
expect(html).toContain($scope.title);
expect(html).toContain($scope.paragraph);
expect(html).not.toContain("title");
expect(html).not.toContain("paragraph");
}));
});
});
```

@@ -7,5 +7,2 @@

// beforeEach(inject(function($templateCache) {
// __templifyTemplates($templateCache);
// }));
__templifyTemplates();

@@ -12,0 +9,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc