@@ -40,7 +40,8 @@ describe('Topic', function() {
4040 var topic ;
4141
4242 var PROJECT_ID = 'test-project' ;
43- var TOPIC_NAME = 'test-topic' ;
43+ var TOPIC_NAME = 'projects/' + PROJECT_ID + '/topics/test-topic' ;
44+ var TOPIC_UNFORMATTED_NAME = TOPIC_NAME . split ( '/' ) . pop ( ) ;
4445 var PUBSUB = {
4546 projectId : PROJECT_ID ,
4647 createTopic : util . noop
@@ -85,7 +86,7 @@ describe('Topic', function() {
8586
8687 assert . strictEqual ( calledWith . parent , pubsubInstance ) ;
8788 assert . strictEqual ( calledWith . baseUrl , '/topics' ) ;
88- assert . strictEqual ( calledWith . id , TOPIC_NAME ) ;
89+ assert . strictEqual ( calledWith . id , TOPIC_UNFORMATTED_NAME ) ;
8990 assert . deepEqual ( calledWith . methods , {
9091 create : true ,
9192 delete : true ,
@@ -100,7 +101,7 @@ describe('Topic', function() {
100101 PUBSUB ,
101102 {
102103 baseUrl : '/topics' ,
103- id : TOPIC_NAME
104+ id : TOPIC_UNFORMATTED_NAME
104105 }
105106 ] ) ;
106107 } ) ;
@@ -117,6 +118,10 @@ describe('Topic', function() {
117118 it ( 'should assign pubsub object to `this`' , function ( ) {
118119 assert . deepEqual ( topic . pubsub , PUBSUB ) ;
119120 } ) ;
121+
122+ it ( 'should localize the unformatted name' , function ( ) {
123+ assert . strictEqual ( topic . unformattedName , TOPIC_UNFORMATTED_NAME ) ;
124+ } ) ;
120125 } ) ;
121126
122127 describe ( 'formatMessage_' , function ( ) {
@@ -142,16 +147,14 @@ describe('Topic', function() {
142147 } ) ;
143148
144149 describe ( 'formatName_' , function ( ) {
145- var fullName = 'projects/' + PROJECT_ID + '/topics/' + TOPIC_NAME ;
146-
147150 it ( 'should format name' , function ( ) {
148- var formattedName = Topic . formatName_ ( PROJECT_ID , TOPIC_NAME ) ;
149- assert . equal ( formattedName , fullName ) ;
151+ var formattedName = Topic . formatName_ ( PROJECT_ID , TOPIC_UNFORMATTED_NAME ) ;
152+ assert . equal ( formattedName , TOPIC_NAME ) ;
150153 } ) ;
151154
152155 it ( 'should format name when given a complete name' , function ( ) {
153- var formattedName = Topic . formatName_ ( PROJECT_ID , fullName ) ;
154- assert . equal ( formattedName , fullName ) ;
156+ var formattedName = Topic . formatName_ ( PROJECT_ID , TOPIC_NAME ) ;
157+ assert . equal ( formattedName , TOPIC_NAME ) ;
155158 } ) ;
156159 } ) ;
157160
0 commit comments