Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test format to modern qunit #974

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading