Skip to content

Commit dc8e1a8

Browse files
Merge pull request #974 from ember-cli/migrate-tests
Update test format to modern qunit
2 parents fe73b7d + 60d0a6d commit dc8e1a8

File tree

10 files changed

+911
-877
lines changed

10 files changed

+911
-877
lines changed

package-lock.json

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-app/tests/unit/classify_test.js

Lines changed: 54 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,58 @@ import { module } from 'qunit';
22
import { classify } from 'ember-resolver/string/index';
33
import createTestFunction from '../helpers/create-test-function';
44

5-
module('classify');
5+
module('classify', function () {
6+
const test = createTestFunction(classify);
67

7-
const test = createTestFunction(classify);
8-
9-
test('my favorite items', 'MyFavoriteItems', 'classify normal string');
10-
test('css-class-name', 'CssClassName', 'classify dasherized string');
11-
test('action_name', 'ActionName', 'classify underscored string');
12-
test(
13-
'privateDocs/ownerInvoice',
14-
'PrivateDocs/OwnerInvoice',
15-
'classify namespaced camelized string'
16-
);
17-
test(
18-
'private_docs/owner_invoice',
19-
'PrivateDocs/OwnerInvoice',
20-
'classify namespaced underscored string'
21-
);
22-
test(
23-
'private-docs/owner-invoice',
24-
'PrivateDocs/OwnerInvoice',
25-
'classify namespaced dasherized string'
26-
);
27-
test('-view-registry', '_ViewRegistry', 'classify prefixed dasherized string');
28-
test(
29-
'components/-text-field',
30-
'Components/_TextField',
31-
'classify namespaced prefixed dasherized string'
32-
);
33-
test('_Foo_Bar', '_FooBar', 'classify underscore-prefixed underscored string');
34-
test('_Foo-Bar', '_FooBar', 'classify underscore-prefixed dasherized string');
35-
test(
36-
'_foo/_bar',
37-
'_Foo/_Bar',
38-
'classify underscore-prefixed-namespaced underscore-prefixed string'
39-
);
40-
test(
41-
'-foo/_bar',
42-
'_Foo/_Bar',
43-
'classify dash-prefixed-namespaced underscore-prefixed string'
44-
);
45-
test(
46-
'-foo/-bar',
47-
'_Foo/_Bar',
48-
'classify dash-prefixed-namespaced dash-prefixed string'
49-
);
50-
test('InnerHTML', 'InnerHTML', 'does nothing with classified string');
51-
test('_FooBar', '_FooBar', 'does nothing with classified prefixed string');
8+
test('my favorite items', 'MyFavoriteItems', 'classify normal string');
9+
test('css-class-name', 'CssClassName', 'classify dasherized string');
10+
test('action_name', 'ActionName', 'classify underscored string');
11+
test(
12+
'privateDocs/ownerInvoice',
13+
'PrivateDocs/OwnerInvoice',
14+
'classify namespaced camelized string'
15+
);
16+
test(
17+
'private_docs/owner_invoice',
18+
'PrivateDocs/OwnerInvoice',
19+
'classify namespaced underscored string'
20+
);
21+
test(
22+
'private-docs/owner-invoice',
23+
'PrivateDocs/OwnerInvoice',
24+
'classify namespaced dasherized string'
25+
);
26+
test(
27+
'-view-registry',
28+
'_ViewRegistry',
29+
'classify prefixed dasherized string'
30+
);
31+
test(
32+
'components/-text-field',
33+
'Components/_TextField',
34+
'classify namespaced prefixed dasherized string'
35+
);
36+
test(
37+
'_Foo_Bar',
38+
'_FooBar',
39+
'classify underscore-prefixed underscored string'
40+
);
41+
test('_Foo-Bar', '_FooBar', 'classify underscore-prefixed dasherized string');
42+
test(
43+
'_foo/_bar',
44+
'_Foo/_Bar',
45+
'classify underscore-prefixed-namespaced underscore-prefixed string'
46+
);
47+
test(
48+
'-foo/_bar',
49+
'_Foo/_Bar',
50+
'classify dash-prefixed-namespaced underscore-prefixed string'
51+
);
52+
test(
53+
'-foo/-bar',
54+
'_Foo/_Bar',
55+
'classify dash-prefixed-namespaced dash-prefixed string'
56+
);
57+
test('InnerHTML', 'InnerHTML', 'does nothing with classified string');
58+
test('_FooBar', '_FooBar', 'does nothing with classified prefixed string');
59+
});

test-app/tests/unit/dasherize_test.js

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,35 @@ import { module } from 'qunit';
22
import { dasherize } from 'ember-resolver/string/index';
33
import createTestFunction from '../helpers/create-test-function';
44

5-
module('dasherize');
5+
module('dasherize', function () {
6+
const test = createTestFunction(dasherize);
67

7-
const test = createTestFunction(dasherize);
8-
9-
test('my favorite items', 'my-favorite-items', 'dasherize normal string');
10-
test('css-class-name', 'css-class-name', 'does nothing with dasherized string');
11-
test('action_name', 'action-name', 'dasherize underscored string');
12-
test('innerHTML', 'inner-html', 'dasherize camelcased string');
13-
test(
14-
'toString',
15-
'to-string',
16-
'dasherize string that is the property name of Object.prototype'
17-
);
18-
test(
19-
'PrivateDocs/OwnerInvoice',
20-
'private-docs/owner-invoice',
21-
'dasherize namespaced classified string'
22-
);
23-
test(
24-
'privateDocs/ownerInvoice',
25-
'private-docs/owner-invoice',
26-
'dasherize namespaced camelized string'
27-
);
28-
test(
29-
'private_docs/owner_invoice',
30-
'private-docs/owner-invoice',
31-
'dasherize namespaced underscored string'
32-
);
8+
test('my favorite items', 'my-favorite-items', 'dasherize normal string');
9+
test(
10+
'css-class-name',
11+
'css-class-name',
12+
'does nothing with dasherized string'
13+
);
14+
test('action_name', 'action-name', 'dasherize underscored string');
15+
test('innerHTML', 'inner-html', 'dasherize camelcased string');
16+
test(
17+
'toString',
18+
'to-string',
19+
'dasherize string that is the property name of Object.prototype'
20+
);
21+
test(
22+
'PrivateDocs/OwnerInvoice',
23+
'private-docs/owner-invoice',
24+
'dasherize namespaced classified string'
25+
);
26+
test(
27+
'privateDocs/ownerInvoice',
28+
'private-docs/owner-invoice',
29+
'dasherize namespaced camelized string'
30+
);
31+
test(
32+
'private_docs/owner_invoice',
33+
'private-docs/owner-invoice',
34+
'dasherize namespaced underscored string'
35+
);
36+
});

test-app/tests/unit/decamelize_test.js

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,34 @@ import { module } from 'qunit';
22
import { decamelize } from 'ember-resolver/string/index';
33
import createTestFunction from '../helpers/create-test-function';
44

5-
module('decamelize');
5+
module('decamelize', function () {
6+
const test = createTestFunction(decamelize);
67

7-
const test = createTestFunction(decamelize);
8-
9-
test(
10-
'my favorite items',
11-
'my favorite items',
12-
'does nothing with normal string'
13-
);
14-
test('css-class-name', 'css-class-name', 'does nothing with dasherized string');
15-
test('action_name', 'action_name', 'does nothing with underscored string');
16-
test(
17-
'innerHTML',
18-
'inner_html',
19-
'converts a camelized string into all lower case separated by underscores.'
20-
);
21-
test('size160Url', 'size160_url', 'decamelizes strings with numbers');
22-
test(
23-
'PrivateDocs/OwnerInvoice',
24-
'private_docs/owner_invoice',
25-
'decamelize namespaced classified string'
26-
);
27-
test(
28-
'privateDocs/ownerInvoice',
29-
'private_docs/owner_invoice',
30-
'decamelize namespaced camelized string'
31-
);
8+
test(
9+
'my favorite items',
10+
'my favorite items',
11+
'does nothing with normal string'
12+
);
13+
test(
14+
'css-class-name',
15+
'css-class-name',
16+
'does nothing with dasherized string'
17+
);
18+
test('action_name', 'action_name', 'does nothing with underscored string');
19+
test(
20+
'innerHTML',
21+
'inner_html',
22+
'converts a camelized string into all lower case separated by underscores.'
23+
);
24+
test('size160Url', 'size160_url', 'decamelizes strings with numbers');
25+
test(
26+
'PrivateDocs/OwnerInvoice',
27+
'private_docs/owner_invoice',
28+
'decamelize namespaced classified string'
29+
);
30+
test(
31+
'privateDocs/ownerInvoice',
32+
'private_docs/owner_invoice',
33+
'decamelize namespaced camelized string'
34+
);
35+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Resolver, { ModuleRegistry } from 'ember-resolver';
2+
3+
export let resolver;
4+
export let loader;
5+
6+
export function setupResolver(options = {}) {
7+
if (!options.namespace) {
8+
options.namespace = { modulePrefix: 'appkit' };
9+
}
10+
loader = {
11+
entries: Object.create(null),
12+
define(id, deps, callback) {
13+
if (deps.length > 0) {
14+
throw new Error('Test Module loader does not support dependencies');
15+
}
16+
this.entries[id] = callback;
17+
},
18+
};
19+
options._moduleRegistry = new ModuleRegistry(loader.entries);
20+
options._moduleRegistry.get = function (moduleName) {
21+
return loader.entries[moduleName]();
22+
};
23+
24+
resolver = Resolver.create(options);
25+
}

0 commit comments

Comments
 (0)