File tree 2 files changed +24
-6
lines changed
2 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -36,12 +36,18 @@ function getTelemetry() {
36
36
*/
37
37
function getTelemetryFor ( filePath ) {
38
38
let modulePath = getModulePathFor ( filePath ) ;
39
- let moduleKey = modulePath . replace ( 'templates/components/' , 'components/' ) ;
39
+ let moduleKey = _generateModuleKey ( modulePath ) ;
40
40
let data = getTelemetry ( ) [ moduleKey ] ;
41
41
42
42
return data ;
43
43
}
44
44
45
+ function _generateModuleKey ( modulePath ) {
46
+ let moduleKey = modulePath . replace ( 'templates/components/' , 'components/' ) ;
47
+ // If `templates/` still exists in the path then it wasn't a component but a controller-level template instead
48
+ return moduleKey . replace ( 'templates/' , 'controllers/' ) ;
49
+ }
50
+
45
51
module . exports = {
46
52
getTelemetry,
47
53
setTelemetry,
Original file line number Diff line number Diff line change @@ -27,13 +27,25 @@ describe('getTelemetryFor', () => {
27
27
expect ( value ) . toEqual ( 1 ) ;
28
28
} ) ;
29
29
30
- test ( 'gets the data for the filePath in classic apps' , ( ) => {
31
- let fakeTelemetry = { 'test-app/components/test-component' : 1 } ;
30
+ describe ( 'classic apps' , ( ) => {
31
+ test ( 'gets the data for the component filePath' , ( ) => {
32
+ let fakeTelemetry = { 'test-app/components/test-component' : 1 } ;
32
33
33
- setTelemetry ( fakeTelemetry ) ;
34
+ setTelemetry ( fakeTelemetry ) ;
34
35
35
- let value = getTelemetryFor ( 'test-app/templates/components/test-component' ) ;
36
+ let value = getTelemetryFor ( 'test-app/templates/components/test-component' ) ;
36
37
37
- expect ( value ) . toEqual ( 1 ) ;
38
+ expect ( value ) . toEqual ( 1 ) ;
39
+ } ) ;
40
+
41
+ test ( 'gets the data for the controller filePath' , ( ) => {
42
+ let fakeTelemetry = { 'test-app/controllers/application' : 1 } ;
43
+
44
+ setTelemetry ( fakeTelemetry ) ;
45
+
46
+ let value = getTelemetryFor ( 'test-app/templates/application' ) ;
47
+
48
+ expect ( value ) . toEqual ( 1 ) ;
49
+ } ) ;
38
50
} ) ;
39
51
} ) ;
You can’t perform that action at this time.
0 commit comments