Skip to content

Commit

Permalink
First test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
passy committed May 4, 2013
1 parent f4de2bb commit 5e49ac9
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 18 deletions.
13 changes: 13 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# editorconfig.org
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
12 changes: 6 additions & 6 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ module.exports = function (grunt) {
// Use the two last components of the path, e.g. 'hyperagent/agent'
var name = filepath.replace(/dist\/amd\//, '').replace(/\.js$/, '');
return src.replace(/define\(/, 'define(\'' + name + '\',');
}
};

var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
return connect.static(require('path').resolve(dir));
};

grunt.initConfig({
Expand Down Expand Up @@ -77,19 +78,18 @@ module.exports = function (grunt) {
options: {
middleware: function (connect) {
return [
mountFolder(connect, '<%= yeoman.dist %>'),
mountFolder(connect, 'test')
mountFolder(connect, '.')
];
}
}
},
}
},

mocha: {
all: {
options: {
run: true,
urls: ['http://localhost:<%= connect.options.port %>/index.html']
urls: ['http://localhost:<%= connect.options.port %>/test/index.html']
}
},
},
Expand Down
4 changes: 4 additions & 0 deletions lib/hyperagent/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,8 @@ Agent.prototype.fetch = function fetch() {
return loader(options);
};

Agent.prototype.url = function url() {
return this.options.url;
};

export Agent;
3 changes: 2 additions & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
<script>var expect = chai.expect</script>

<!-- include source files here... -->
<script src="../dist/hyperagent.js"></script>

<!-- include spec files here... -->
<script src="spec/test.js"></script>
<script src="spec/test-agent.js"></script>

<script>mocha.run()</script>
</body>
Expand Down
29 changes: 29 additions & 0 deletions test/spec/test-agent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*global describe, it, chai, Hyperagent */
'use strict';
(function () {
var assert = chai.assert;

describe('Agent', function () {
it('should initialize', function () {
var agent = new Hyperagent.Agent('http://example.com/');
assert(agent.fetch);
});

it('should accept options hash', function () {
var agent = new Hyperagent.Agent({
url: 'http://example.com/'
});
assert(agent.fetch);
});

it('should return its url', function () {
var agent = new Hyperagent.Agent('http://example.com/');
assert(agent.url(), 'http://example.com/');
});

it('should return its url from an options hash', function () {
var agent = new Hyperagent.Agent({ url: 'http://example.com/' });
assert(agent.url(), 'http://example.com/');
});
});
})();
11 changes: 0 additions & 11 deletions test/spec/test.js

This file was deleted.

0 comments on commit 5e49ac9

Please sign in to comment.