Skip to content

Commit

Permalink
Merge pull request #974 from ember-cli/migrate-tests
Browse files Browse the repository at this point in the history
Update test format to modern qunit
  • Loading branch information
NullVoxPopuli authored Jun 6, 2024
2 parents fe73b7d + 60d0a6d commit dc8e1a8
Show file tree
Hide file tree
Showing 10 changed files with 911 additions and 877 deletions.
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

100 changes: 54 additions & 46 deletions test-app/tests/unit/classify_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,50 +2,58 @@ import { module } from 'qunit';
import { classify } from 'ember-resolver/string/index';
import createTestFunction from '../helpers/create-test-function';

module('classify');
module('classify', function () {
const test = createTestFunction(classify);

const test = createTestFunction(classify);

test('my favorite items', 'MyFavoriteItems', 'classify normal string');
test('css-class-name', 'CssClassName', 'classify dasherized string');
test('action_name', 'ActionName', 'classify underscored string');
test(
'privateDocs/ownerInvoice',
'PrivateDocs/OwnerInvoice',
'classify namespaced camelized string'
);
test(
'private_docs/owner_invoice',
'PrivateDocs/OwnerInvoice',
'classify namespaced underscored string'
);
test(
'private-docs/owner-invoice',
'PrivateDocs/OwnerInvoice',
'classify namespaced dasherized string'
);
test('-view-registry', '_ViewRegistry', 'classify prefixed dasherized string');
test(
'components/-text-field',
'Components/_TextField',
'classify namespaced prefixed dasherized string'
);
test('_Foo_Bar', '_FooBar', 'classify underscore-prefixed underscored string');
test('_Foo-Bar', '_FooBar', 'classify underscore-prefixed dasherized string');
test(
'_foo/_bar',
'_Foo/_Bar',
'classify underscore-prefixed-namespaced underscore-prefixed string'
);
test(
'-foo/_bar',
'_Foo/_Bar',
'classify dash-prefixed-namespaced underscore-prefixed string'
);
test(
'-foo/-bar',
'_Foo/_Bar',
'classify dash-prefixed-namespaced dash-prefixed string'
);
test('InnerHTML', 'InnerHTML', 'does nothing with classified string');
test('_FooBar', '_FooBar', 'does nothing with classified prefixed string');
test('my favorite items', 'MyFavoriteItems', 'classify normal string');
test('css-class-name', 'CssClassName', 'classify dasherized string');
test('action_name', 'ActionName', 'classify underscored string');
test(
'privateDocs/ownerInvoice',
'PrivateDocs/OwnerInvoice',
'classify namespaced camelized string'
);
test(
'private_docs/owner_invoice',
'PrivateDocs/OwnerInvoice',
'classify namespaced underscored string'
);
test(
'private-docs/owner-invoice',
'PrivateDocs/OwnerInvoice',
'classify namespaced dasherized string'
);
test(
'-view-registry',
'_ViewRegistry',
'classify prefixed dasherized string'
);
test(
'components/-text-field',
'Components/_TextField',
'classify namespaced prefixed dasherized string'
);
test(
'_Foo_Bar',
'_FooBar',
'classify underscore-prefixed underscored string'
);
test('_Foo-Bar', '_FooBar', 'classify underscore-prefixed dasherized string');
test(
'_foo/_bar',
'_Foo/_Bar',
'classify underscore-prefixed-namespaced underscore-prefixed string'
);
test(
'-foo/_bar',
'_Foo/_Bar',
'classify dash-prefixed-namespaced underscore-prefixed string'
);
test(
'-foo/-bar',
'_Foo/_Bar',
'classify dash-prefixed-namespaced dash-prefixed string'
);
test('InnerHTML', 'InnerHTML', 'does nothing with classified string');
test('_FooBar', '_FooBar', 'does nothing with classified prefixed string');
});
58 changes: 31 additions & 27 deletions test-app/tests/unit/dasherize_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,35 @@ import { module } from 'qunit';
import { dasherize } from 'ember-resolver/string/index';
import createTestFunction from '../helpers/create-test-function';

module('dasherize');
module('dasherize', function () {
const test = createTestFunction(dasherize);

const test = createTestFunction(dasherize);

test('my favorite items', 'my-favorite-items', 'dasherize normal string');
test('css-class-name', 'css-class-name', 'does nothing with dasherized string');
test('action_name', 'action-name', 'dasherize underscored string');
test('innerHTML', 'inner-html', 'dasherize camelcased string');
test(
'toString',
'to-string',
'dasherize string that is the property name of Object.prototype'
);
test(
'PrivateDocs/OwnerInvoice',
'private-docs/owner-invoice',
'dasherize namespaced classified string'
);
test(
'privateDocs/ownerInvoice',
'private-docs/owner-invoice',
'dasherize namespaced camelized string'
);
test(
'private_docs/owner_invoice',
'private-docs/owner-invoice',
'dasherize namespaced underscored string'
);
test('my favorite items', 'my-favorite-items', 'dasherize normal string');
test(
'css-class-name',
'css-class-name',
'does nothing with dasherized string'
);
test('action_name', 'action-name', 'dasherize underscored string');
test('innerHTML', 'inner-html', 'dasherize camelcased string');
test(
'toString',
'to-string',
'dasherize string that is the property name of Object.prototype'
);
test(
'PrivateDocs/OwnerInvoice',
'private-docs/owner-invoice',
'dasherize namespaced classified string'
);
test(
'privateDocs/ownerInvoice',
'private-docs/owner-invoice',
'dasherize namespaced camelized string'
);
test(
'private_docs/owner_invoice',
'private-docs/owner-invoice',
'dasherize namespaced underscored string'
);
});
56 changes: 30 additions & 26 deletions test-app/tests/unit/decamelize_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,34 @@ import { module } from 'qunit';
import { decamelize } from 'ember-resolver/string/index';
import createTestFunction from '../helpers/create-test-function';

module('decamelize');
module('decamelize', function () {
const test = createTestFunction(decamelize);

const test = createTestFunction(decamelize);

test(
'my favorite items',
'my favorite items',
'does nothing with normal string'
);
test('css-class-name', 'css-class-name', 'does nothing with dasherized string');
test('action_name', 'action_name', 'does nothing with underscored string');
test(
'innerHTML',
'inner_html',
'converts a camelized string into all lower case separated by underscores.'
);
test('size160Url', 'size160_url', 'decamelizes strings with numbers');
test(
'PrivateDocs/OwnerInvoice',
'private_docs/owner_invoice',
'decamelize namespaced classified string'
);
test(
'privateDocs/ownerInvoice',
'private_docs/owner_invoice',
'decamelize namespaced camelized string'
);
test(
'my favorite items',
'my favorite items',
'does nothing with normal string'
);
test(
'css-class-name',
'css-class-name',
'does nothing with dasherized string'
);
test('action_name', 'action_name', 'does nothing with underscored string');
test(
'innerHTML',
'inner_html',
'converts a camelized string into all lower case separated by underscores.'
);
test('size160Url', 'size160_url', 'decamelizes strings with numbers');
test(
'PrivateDocs/OwnerInvoice',
'private_docs/owner_invoice',
'decamelize namespaced classified string'
);
test(
'privateDocs/ownerInvoice',
'private_docs/owner_invoice',
'decamelize namespaced camelized string'
);
});
25 changes: 25 additions & 0 deletions test-app/tests/unit/resolvers/classic/-setup-resolver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import Resolver, { ModuleRegistry } from 'ember-resolver';

export let resolver;
export let loader;

export function setupResolver(options = {}) {
if (!options.namespace) {
options.namespace = { modulePrefix: 'appkit' };
}
loader = {
entries: Object.create(null),
define(id, deps, callback) {
if (deps.length > 0) {
throw new Error('Test Module loader does not support dependencies');
}
this.entries[id] = callback;
},
};
options._moduleRegistry = new ModuleRegistry(loader.entries);
options._moduleRegistry.get = function (moduleName) {
return loader.entries[moduleName]();
};

resolver = Resolver.create(options);
}
Loading

0 comments on commit dc8e1a8

Please sign in to comment.