From 54e087e176156c435851b220a7be571c4759955b Mon Sep 17 00:00:00 2001 From: Mark David Avery Date: Sun, 30 Jul 2017 21:24:32 -0700 Subject: [PATCH] fix(component name parsing): only switching out the word 'compoent/' if it is what starts the path, not for nest options. This should be revisited with unification Closes #236 --- lib/component-names.js | 2 +- tests/acceptance/unique-component-paths-test.js | 12 ++++++++++++ tests/dummy/app/router.js | 1 + .../-components/test-component/styles.scss | 3 +++ .../-components/test-component/template.hbs | 1 + tests/dummy/app/unique-component-paths/template.hbs | 1 + 6 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tests/acceptance/unique-component-paths-test.js create mode 100644 tests/dummy/app/unique-component-paths/-components/test-component/styles.scss create mode 100644 tests/dummy/app/unique-component-paths/-components/test-component/template.hbs create mode 100644 tests/dummy/app/unique-component-paths/template.hbs diff --git a/lib/component-names.js b/lib/component-names.js index ed2704c..1215214 100644 --- a/lib/component-names.js +++ b/lib/component-names.js @@ -6,7 +6,7 @@ var md5 = require('md5'); module.exports = { path: function(actualPath, classicStyleDir) { var terminator = '/'; - var pathSegementToRemove = 'components/'; + var pathSegementToRemove = /^components\//; if (actualPath.includes(classicStyleDir)) { terminator = '.'; diff --git a/tests/acceptance/unique-component-paths-test.js b/tests/acceptance/unique-component-paths-test.js new file mode 100644 index 0000000..ddffc9f --- /dev/null +++ b/tests/acceptance/unique-component-paths-test.js @@ -0,0 +1,12 @@ +import { test } from 'qunit'; +import moduleForAcceptance from '../../tests/helpers/module-for-acceptance'; + +moduleForAcceptance(`Acceptance | Unique Paths`); + +test('base rule followed', function(assert) { + visit(`/unique-component-paths`); + + andThen(function() { + assert.equal(find('h1').css('color'), 'rgb(0, 0, 14)'); + }); +}); diff --git a/tests/dummy/app/router.js b/tests/dummy/app/router.js index db38766..a7b3aae 100644 --- a/tests/dummy/app/router.js +++ b/tests/dummy/app/router.js @@ -15,6 +15,7 @@ export default Ember.Router.extend({ this.route('no-style-files-yet'); this.route('classic-structure'); this.route('classic-structure-nested'); + this.route('unique-component-paths'); this.route('addon', function() { this.route('scss'); diff --git a/tests/dummy/app/unique-component-paths/-components/test-component/styles.scss b/tests/dummy/app/unique-component-paths/-components/test-component/styles.scss new file mode 100644 index 0000000..7919e30 --- /dev/null +++ b/tests/dummy/app/unique-component-paths/-components/test-component/styles.scss @@ -0,0 +1,3 @@ +h1 { + color: rgb(0, 0, 14); +} diff --git a/tests/dummy/app/unique-component-paths/-components/test-component/template.hbs b/tests/dummy/app/unique-component-paths/-components/test-component/template.hbs new file mode 100644 index 0000000..5a2da7b --- /dev/null +++ b/tests/dummy/app/unique-component-paths/-components/test-component/template.hbs @@ -0,0 +1 @@ +

my color should be rgb(0, 0, 14)

diff --git a/tests/dummy/app/unique-component-paths/template.hbs b/tests/dummy/app/unique-component-paths/template.hbs new file mode 100644 index 0000000..2d18e24 --- /dev/null +++ b/tests/dummy/app/unique-component-paths/template.hbs @@ -0,0 +1 @@ +{{unique-component-paths/-components/test-component}}