@@ -4,7 +4,7 @@ var Resource = require('../../lib/resource');
44var types = require ( '../../lib/config/resource-types' ) ;
55
66describe ( 'Resource' , function ( ) {
7- describe ( '#Resource ' , function ( ) {
7+ describe ( '#getType ' , function ( ) {
88 it ( 'should return correct type based on extension' , function ( ) {
99 var html = new Resource ( 'http://example.com' , 'index.html' ) ;
1010 var htm = new Resource ( 'http://example.com' , 'index.htm' ) ;
@@ -68,4 +68,56 @@ describe('Resource', function() {
6868 res . getType ( ) . should . be . eql ( types . other ) ;
6969 } ) ;
7070 } ) ;
71+
72+ describe ( '#setDepth' , function ( ) {
73+ it ( 'should set depth' , function ( ) {
74+ var o = new Resource ( 'http://google.com' ) ;
75+ o . setDepth ( 555 ) ;
76+ o . depth . should . be . eql ( 555 ) ;
77+ } ) ;
78+ } ) ;
79+
80+ describe ( '#getDepth' , function ( ) {
81+ it ( 'should return depth if object has it' , function ( ) {
82+ var o = new Resource ( 'http://google.com' ) ;
83+ o . setDepth ( 123 ) ;
84+ o . getDepth ( ) . should . be . eql ( 123 ) ;
85+ } ) ;
86+
87+ it ( 'should return 0 if object has no depth' , function ( ) {
88+ var o = new Resource ( 'http://google.com' ) ;
89+ o . getDepth ( ) . should . be . eql ( 0 ) ;
90+ } ) ;
91+
92+ } ) ;
93+
94+ describe ( '#createChild' , function ( ) {
95+ it ( 'should return Resource' , function ( ) {
96+ var parent = new Resource ( 'http://example.com' ) ;
97+ var child = parent . createChild ( 'http://google.com' ) ;
98+ child . should . be . instanceOf ( Resource ) ;
99+ } ) ;
100+
101+ it ( 'should set correct url and filename' , function ( ) {
102+ var parent = new Resource ( 'http://example.com' ) ;
103+ var child = parent . createChild ( 'http://google.com' , 'google.html' ) ;
104+ child . getUrl ( ) . should . be . eql ( 'http://google.com' ) ;
105+ child . getFilename ( ) . should . be . eql ( 'google.html' ) ;
106+ } ) ;
107+
108+ it ( 'should set parent' , function ( ) {
109+ var parent = new Resource ( 'http://example.com' ) ;
110+ var child = parent . createChild ( 'http://google.com' ) ;
111+ child . parent . should . be . equal ( parent ) ;
112+ } ) ;
113+
114+ it ( 'should set depth' , function ( ) {
115+ var parent = new Resource ( 'http://example.com' ) ;
116+ var child = parent . createChild ( 'http://google.com' ) ;
117+ child . getDepth ( ) . should . be . eql ( 1 ) ;
118+
119+ var childOfChild = child . createChild ( 'http://google.com.ua' ) ;
120+ childOfChild . getDepth ( ) . should . be . eql ( 2 ) ;
121+ } ) ;
122+ } ) ;
71123} ) ;
0 commit comments