milosev.com
  • Home
    • List all categories
    • Sitemap
  • Downloads
    • WebSphere
    • Hitachi902
    • Hospital
    • Kryptonite
    • OCR
    • APK
  • About me
    • Gallery
      • Italy2022
      • Côte d'Azur 2024
    • Curriculum vitae
      • Resume
      • Lebenslauf
    • Social networks
      • Facebook
      • Twitter
      • LinkedIn
      • Xing
      • GitHub
      • Google Maps
      • Sports tracker
    • Adventures planning
  1. You are here:  
  2. Home
  3. JavaScript

Some tips

Details
Written by: Stanko Milosev
Category: Jasmine
Published: 05 October 2013
Last Updated: 06 April 2022
Hits: 6801

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.

Testing screenX

Details
Written by: Stanko Milosev
Category: Jasmine
Published: 30 November -0001
Last Updated: 24 June 2015
Hits: 1382

I had a problem to test touchmove and mouseve events.

 

Formating date

Details
Written by: Stanko Milosev
Category: Moment
Published: 29 October 2013
Last Updated: 29 October 2013
Hits: 4458

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

Stylelint

Details
Written by: Stanko Milosev
Category: node.js
Published: 24 April 2016
Last Updated: 24 April 2016
Hits: 4593

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.

  1. Video streaming
  2. Installing Karma runner
  3. Function like message handler
  4. node.js "Hello World" example

Subcategories

Ajax

JavaScript

ExtJS


jQuery

Bing Maps AJAX Control, Version 7.0

Knockout

Jasmine

Moment

node.js

Page 22 of 24

  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24