Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Added specs for URL
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Mar 26, 2015
1 parent d0f3a34 commit 6a459b2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
27 changes: 26 additions & 1 deletion test/spec/modules/promise.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(function() {
'use strict';

// jshint unused: false
var Promise = require('../../../src/js/modules/promise');

describe('Promise', function() {
Expand All @@ -18,6 +17,19 @@
expect(deferred).toBeTruthy();
});

it('should resolve promise with value', function() {
var promise = new Promise(),
deferred = false;

promise.then(function(data) {
deferred = data;
});

promise.resolve('Allright!');

expect(deferred).toEqual('Allright!');
});

it('should start tasks which are defined after resolving', function() {
var promise = new Promise(),
deferred = false;
Expand All @@ -44,6 +56,19 @@
expect(rejected).toBeTruthy();
});

it('should reject promise with reason', function() {
var promise = new Promise(),
rejected = null;

promise.then(null, function(reason) {
rejected = reason;
});

promise.reject('Something happened');

expect(rejected).toEqual('Something happened');
});

it('should start fail tasks which are defined after rejecting', function() {
var promise = new Promise(),
rejected = false;
Expand Down
17 changes: 16 additions & 1 deletion test/spec/modules/url.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
(function() {
'use strict';

// jshint unused: false
var url = require('../../../src/js/modules/url');

describe('URL', function() {
it('should retrieve hostname from URL', function() {
var data = {
'http://www.google.pl': 'www.google.pl',
'http://www.goog.pl/something-is-there-also': 'www.goog.pl',
'http://goog.pl/something-is-there-also': 'goog.pl',
'http://usr@goog.pl/something-is-there-also': 'goog.pl',
'ftp://usr@goog.pl/something-is-there-also': 'goog.pl'
};

for (var idx in data) {
expect(url.getHostname(idx)).toEqual(data[idx]);
}
});
});
}());

0 comments on commit 6a459b2

Please sign in to comment.