|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const blueprintHelpers = require('ember-cli-blueprint-test-helpers/helpers'); |
| 4 | +const setupTestHooks = blueprintHelpers.setupTestHooks; |
| 5 | +const emberNew = blueprintHelpers.emberNew; |
| 6 | +const emberGenerateDestroy = blueprintHelpers.emberGenerateDestroy; |
| 7 | +const setupPodConfig = blueprintHelpers.setupPodConfig; |
| 8 | + |
| 9 | +const chai = require('ember-cli-blueprint-test-helpers/chai'); |
| 10 | +const expect = chai.expect; |
| 11 | + |
| 12 | +describe('Blueprint: mixin', function() { |
| 13 | + setupTestHooks(this); |
| 14 | + |
| 15 | + describe('in app', function() { |
| 16 | + beforeEach(function() { |
| 17 | + return emberNew(); |
| 18 | + }); |
| 19 | + |
| 20 | + it('mixin foo', function() { |
| 21 | + return emberGenerateDestroy(['mixin', 'foo'], _file => { |
| 22 | + expect(_file('app/mixins/foo.ts')) |
| 23 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 24 | + .to.contain('export default Mixin.create({\n});'); |
| 25 | + |
| 26 | + expect(_file('tests/unit/mixins/foo-test.ts')).to.contain( |
| 27 | + "import FooMixin from 'my-app/mixins/foo';" |
| 28 | + ); |
| 29 | + }); |
| 30 | + }); |
| 31 | + |
| 32 | + it('mixin foo/bar', function() { |
| 33 | + return emberGenerateDestroy(['mixin', 'foo/bar'], _file => { |
| 34 | + expect(_file('app/mixins/foo/bar.ts')) |
| 35 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 36 | + .to.contain('export default Mixin.create({\n});'); |
| 37 | + |
| 38 | + expect(_file('tests/unit/mixins/foo/bar-test.ts')).to.contain( |
| 39 | + "import FooBarMixin from 'my-app/mixins/foo/bar';" |
| 40 | + ); |
| 41 | + }); |
| 42 | + }); |
| 43 | + |
| 44 | + it('mixin foo/bar/baz', function() { |
| 45 | + return emberGenerateDestroy(['mixin', 'foo/bar/baz'], _file => { |
| 46 | + expect(_file('tests/unit/mixins/foo/bar/baz-test.ts')).to.contain( |
| 47 | + "import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';" |
| 48 | + ); |
| 49 | + }); |
| 50 | + }); |
| 51 | + |
| 52 | + it('mixin foo --pod', function() { |
| 53 | + return emberGenerateDestroy(['mixin', 'foo', '--pod'], _file => { |
| 54 | + expect(_file('app/mixins/foo.ts')) |
| 55 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 56 | + .to.contain('export default Mixin.create({\n});'); |
| 57 | + |
| 58 | + expect(_file('tests/unit/mixins/foo-test.ts')).to.contain( |
| 59 | + "import FooMixin from 'my-app/mixins/foo';" |
| 60 | + ); |
| 61 | + }); |
| 62 | + }); |
| 63 | + |
| 64 | + it('mixin foo/bar --pod', function() { |
| 65 | + return emberGenerateDestroy(['mixin', 'foo/bar', '--pod'], _file => { |
| 66 | + expect(_file('app/mixins/foo/bar.ts')) |
| 67 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 68 | + .to.contain('export default Mixin.create({\n});'); |
| 69 | + |
| 70 | + expect(_file('tests/unit/mixins/foo/bar-test.ts')).to.contain( |
| 71 | + "import FooBarMixin from 'my-app/mixins/foo/bar';" |
| 72 | + ); |
| 73 | + }); |
| 74 | + }); |
| 75 | + |
| 76 | + it('mixin foo/bar/baz --pod', function() { |
| 77 | + return emberGenerateDestroy(['mixin', 'foo/bar/baz', '--pod'], _file => { |
| 78 | + expect(_file('tests/unit/mixins/foo/bar/baz-test.ts')).to.contain( |
| 79 | + "import FooBarBazMixin from 'my-app/mixins/foo/bar/baz';" |
| 80 | + ); |
| 81 | + }); |
| 82 | + }); |
| 83 | + |
| 84 | + describe('with podModulePrefix', function() { |
| 85 | + beforeEach(function() { |
| 86 | + setupPodConfig({ podModulePrefix: true }); |
| 87 | + }); |
| 88 | + |
| 89 | + it('mixin foo --pod', function() { |
| 90 | + return emberGenerateDestroy(['mixin', 'foo', '--pod'], _file => { |
| 91 | + expect(_file('app/mixins/foo.ts')) |
| 92 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 93 | + .to.contain('export default Mixin.create({\n});'); |
| 94 | + |
| 95 | + expect(_file('tests/unit/mixins/foo-test.ts')).to.contain( |
| 96 | + "import FooMixin from 'my-app/mixins/foo';" |
| 97 | + ); |
| 98 | + }); |
| 99 | + }); |
| 100 | + |
| 101 | + it('mixin foo/bar --pod', function() { |
| 102 | + return emberGenerateDestroy(['mixin', 'foo/bar', '--pod'], _file => { |
| 103 | + expect(_file('app/mixins/foo/bar.ts')) |
| 104 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 105 | + .to.contain('export default Mixin.create({\n});'); |
| 106 | + |
| 107 | + expect(_file('tests/unit/mixins/foo/bar-test.ts')).to.contain( |
| 108 | + "import FooBarMixin from 'my-app/mixins/foo/bar';" |
| 109 | + ); |
| 110 | + }); |
| 111 | + }); |
| 112 | + }); |
| 113 | + }); |
| 114 | + |
| 115 | + describe('in addon', function() { |
| 116 | + beforeEach(function() { |
| 117 | + return emberNew({ target: 'addon' }); |
| 118 | + }); |
| 119 | + |
| 120 | + it('mixin foo', function() { |
| 121 | + return emberGenerateDestroy(['mixin', 'foo'], _file => { |
| 122 | + expect(_file('addon/mixins/foo.ts')) |
| 123 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 124 | + .to.contain('export default Mixin.create({\n});'); |
| 125 | + |
| 126 | + expect(_file('tests/unit/mixins/foo-test.ts')).to.contain( |
| 127 | + "import FooMixin from 'my-addon/mixins/foo';" |
| 128 | + ); |
| 129 | + |
| 130 | + expect(_file('app/mixins/foo.ts')).to.not.exist; |
| 131 | + }); |
| 132 | + }); |
| 133 | + |
| 134 | + it('mixin foo/bar', function() { |
| 135 | + return emberGenerateDestroy(['mixin', 'foo/bar'], _file => { |
| 136 | + expect(_file('addon/mixins/foo/bar.ts')) |
| 137 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 138 | + .to.contain('export default Mixin.create({\n});'); |
| 139 | + |
| 140 | + expect(_file('tests/unit/mixins/foo/bar-test.ts')).to.contain( |
| 141 | + "import FooBarMixin from 'my-addon/mixins/foo/bar';" |
| 142 | + ); |
| 143 | + |
| 144 | + expect(_file('app/mixins/foo/bar.ts')).to.not.exist; |
| 145 | + }); |
| 146 | + }); |
| 147 | + |
| 148 | + it('mixin foo/bar/baz', function() { |
| 149 | + return emberGenerateDestroy(['mixin', 'foo/bar/baz'], _file => { |
| 150 | + expect(_file('addon/mixins/foo/bar/baz.ts')) |
| 151 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 152 | + .to.contain('export default Mixin.create({\n});'); |
| 153 | + |
| 154 | + expect(_file('tests/unit/mixins/foo/bar/baz-test.ts')).to.contain( |
| 155 | + "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';" |
| 156 | + ); |
| 157 | + |
| 158 | + expect(_file('app/mixins/foo/bar/baz.ts')).to.not.exist; |
| 159 | + }); |
| 160 | + }); |
| 161 | + }); |
| 162 | + |
| 163 | + describe('in in-repo-addon', function() { |
| 164 | + beforeEach(function() { |
| 165 | + return emberNew({ target: 'in-repo-addon' }); |
| 166 | + }); |
| 167 | + |
| 168 | + it('mixin foo --in-repo-addon=my-addon', function() { |
| 169 | + return emberGenerateDestroy(['mixin', 'foo', '--in-repo-addon=my-addon'], _file => { |
| 170 | + expect(_file('lib/my-addon/addon/mixins/foo.ts')) |
| 171 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 172 | + .to.contain('export default Mixin.create({\n});'); |
| 173 | + |
| 174 | + expect(_file('tests/unit/mixins/foo-test.ts')).to.contain( |
| 175 | + "import FooMixin from 'my-addon/mixins/foo';" |
| 176 | + ); |
| 177 | + }); |
| 178 | + }); |
| 179 | + |
| 180 | + it('mixin foo/bar --in-repo-addon=my-addon', function() { |
| 181 | + return emberGenerateDestroy(['mixin', 'foo/bar', '--in-repo-addon=my-addon'], _file => { |
| 182 | + expect(_file('lib/my-addon/addon/mixins/foo/bar.ts')) |
| 183 | + .to.contain("import Mixin from '@ember/object/mixin';") |
| 184 | + .to.contain('export default Mixin.create({\n});'); |
| 185 | + |
| 186 | + expect(_file('tests/unit/mixins/foo/bar-test.ts')).to.contain( |
| 187 | + "import FooBarMixin from 'my-addon/mixins/foo/bar';" |
| 188 | + ); |
| 189 | + }); |
| 190 | + }); |
| 191 | + |
| 192 | + it('mixin foo/bar/baz --in-repo-addon=my-addon', function() { |
| 193 | + return emberGenerateDestroy(['mixin', 'foo/bar/baz', '--in-repo-addon=my-addon'], _file => { |
| 194 | + expect(_file('tests/unit/mixins/foo/bar/baz-test.ts')).to.contain( |
| 195 | + "import FooBarBazMixin from 'my-addon/mixins/foo/bar/baz';" |
| 196 | + ); |
| 197 | + }); |
| 198 | + }); |
| 199 | + }); |
| 200 | +}); |
0 commit comments