|
| 1 | +buster.spec.expose(); |
| 2 | + |
| 3 | +describe("purl in non-strict mode", function () { |
| 4 | + |
| 5 | + before(function () { |
| 6 | + this.url = purl('http://allmarkedup.com/folder/dir/index.html?item=value#foo'); |
| 7 | + }); |
| 8 | + |
| 9 | + it('should have a protocol of http', function() { |
| 10 | + expect(this.url.attr('protocol')).toBe('http'); |
| 11 | + }); |
| 12 | + |
| 13 | + it('should have a path of /folder/dir/index.html', function() { |
| 14 | + expect(this.url.attr('path')).toBe('/folder/dir/index.html'); |
| 15 | + }); |
| 16 | + |
| 17 | + /* should it? */ |
| 18 | + it('should have an unset port', function() { |
| 19 | + expect(this.url.attr('port')).toBe(''); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should have an host of allmarkedup.com', function() { |
| 23 | + expect(this.url.attr('host')).toBe('allmarkedup.com'); |
| 24 | + }); |
| 25 | + |
| 26 | + it('should have a relative path of /folder/dir/index.html?item=value#foo', function() { |
| 27 | + expect(this.url.attr('relative')).toBe('/folder/dir/index.html?item=value#foo'); |
| 28 | + }); |
| 29 | + |
| 30 | + it('should have a path of /folder/dir/index.html', function() { |
| 31 | + expect(this.url.attr('path')).toBe('/folder/dir/index.html'); |
| 32 | + }); |
| 33 | + |
| 34 | + it('should have a directory of /folder/dir/', function() { |
| 35 | + expect(this.url.attr('directory')).toBe('/folder/dir/'); |
| 36 | + }); |
| 37 | + |
| 38 | + it('should have a file of index.html', function() { |
| 39 | + expect(this.url.attr('file')).toBe('index.html'); |
| 40 | + }); |
| 41 | + |
| 42 | + it('should have a querystring of item=value', function() { |
| 43 | + expect(this.url.attr('query')).toBe('item=value'); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should have an anchor of foo', function() { |
| 47 | + expect(this.url.attr('anchor')).toBe('foo'); |
| 48 | + expect(this.url.attr('fragment')).toBe('foo'); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should have a param() of item: "value"', function() { |
| 52 | + expect(this.url.param()).toBeObject({item: 'value'}) |
| 53 | + }); |
| 54 | + |
| 55 | + it('should have a param("item") of "value"', function() { |
| 56 | + expect(this.url.param('item')).toBe('value') |
| 57 | + }); |
| 58 | + |
| 59 | + it('should have a segment() of ["folder","dir","index.html"]', function() { |
| 60 | + expect(this.url.segment()).toEqual(["folder","dir","index.html"]) |
| 61 | + }); |
| 62 | + |
| 63 | + it('should have a segment(1) of "folder"', function() { |
| 64 | + expect(this.url.segment(1)).toBe("folder"); |
| 65 | + }); |
| 66 | + |
| 67 | + it('should have a segment(-1) of "folder"', function() { |
| 68 | + expect(this.url.segment(-1)).toBe("index.html"); |
| 69 | + }); |
| 70 | + |
| 71 | +}); |
0 commit comments