- Details
- Written by: Stanko Milosev
- Category: Jasmine
- Hits: 6321
Jasmine tests are separated in two separate files. One is for HTML view, and it is called, like, myFile.Specrunner.html, second is javascript file, which will be used for testing our javascript.
In beforeEach section we can put things which have to be executed before starting test. In my case, for example, I needed to add Resources, something like:
describe("Add notification rule", function() { beforeEach(function() { Resource = { Notification_Choose_parameter: 'Choose Parameter' ,Component_Notification_Position: 'test' }; }); });
Otherwise I was receiving error "Resource not found".
In the HTML file, if I need some HTML I can add it on the of file, in my case, I needed something like:
<body> <button id="cleanApply" data-bind="click: cleanApply">Click to apply "clean" - without any model - bindings</button> <button id="addPredefCars" data-bind="click: addPredefCars">Click to apply bindings with predefined type and subtype (example for </body>
All javascript files which are needed for testing are in HTML file.
Then, for example, I was testing addCars method from my "add cars" example:
describe("Add cars", function() { it("add two type of cars", function() { var target = new CarsViewModel(); target.addCars(); expect(target.Cars().length).toBe(1); target.addCars(); expect(target.Cars().length).toBe(2); }); });
My Jasmine example you can see here.
- Details
- Written by: Stanko Milosev
- Category: Jasmine
- Hits: 892
I had a problem to test touchmove and mouseve events.
- Details
- Written by: Stanko Milosev
- Category: Moment
- Hits: 4016
I was playing little with jQuery UI datePicker, and Moment.js library, and here you can see result of it. Also, that source can be used for jQuery UI development, since I extracted only necessary files.
In my example most important are these two lines of code:
var $myDate = $( "#datepicker" ).datepicker( "getDate" ); var $formatedMyDate = moment($myDate).format('YYYY-MM-DD hh:mm');
As you can see with line:
moment($myDate).format('YYYY-MM-DD hh:mm');
Date $myDate, I am formating to format YYYY-MM-DD hh:mm
- Details
- Written by: Stanko Milosev
- Category: node.js
- Hits: 4088
Today I discovered stylelint, and here is my example how to use it on windows, since I was struggling with CLI in windows.
First to install stylelint I was using this command:
npm install stylelint
After that I installed standard configuration:
npm install stylelint-config-standard
After that step in folder ..\node_modules\stylelint-config-standard you can find file index.js, which I copy / pasted to folder ..\node_modules\.bin and renamed to stylelint.config.js
Then I went to folder ..\node_modules\.bin in command prompt, and wrote on CSS with empty rule, something like:
a {}
In command prompt executed:
stylelint *.css
And voilà:
There is also possibility to use stylelint against less files, as explained here, but I didn't test it.