Debian Codegraph @

pretender/test/hosts_test.js

raw
1 var hosts;
2 var describe = QUnit.module;
3 var it = QUnit.test;
4
5 describe('Hosts', function(config) {
6 config.beforeEach(function() {
7 hosts = new Pretender.Hosts();
8 });
9
10 config.afterEach(function() {
11 hosts = undefined;
12 });
13
14 describe('#forURL', function() {
15 it('returns a registry for a URL', function(assert) {
16 assert.ok(hosts.forURL('http://www.groupon.com/offers/skydiving'));
17 });
18
19 it('returns a registry for a relative path', function(assert) {
20 assert.ok(hosts.forURL('/offers/skydiving'));
21 });
22
23 it('returns different Registry objects for different hosts ', function(
24 assert
25 ) {
26 var registry1 = hosts.forURL('/offers/dinner_out');
27 var registry2 = hosts.forURL('http://www.yahoo.com/offers/dinner_out');
28 registry1.GET.add({
29 path: 'http://www.yahoo.com/offers/dinner_out',
30 handler: function() {
31 return [200, {}, 'ok'];
32 },
33 });
34 assert.ok(
35 !registry2.GET.recognize('http://www.yahoo.com/offers/dinner_out')
36 );
37 assert.ok(
38 !registry1.GET.recognize('http://www.yahoo.com/offers/dinner_out')
39 );
40 });
41 });
42 });