diff --git a/contexts/Field.js b/contexts/Field.js index 4dbba8b..d9a4e43 100644 --- a/contexts/Field.js +++ b/contexts/Field.js @@ -1,6 +1,10 @@ import { Status } from '../types/Status' import { Labels } from '../i18n/Labels' +/** + * Represents a field of work. + * Do not confuse with the technical concept of database fields. + */ export const Field = {} Field.name = 'field' diff --git a/core-tests.js b/core-tests.js index a376a78..d803e8c 100644 --- a/core-tests.js +++ b/core-tests.js @@ -1,13 +1,13 @@ -//import './contexts/tests/contexts.tests' -// import './contexts/tests/fileContexts.tests' -// import './decorators/routes/tests/createGetByIdRoute.tests' -// import './decorators/routes/tests/getAll.tests' -// import './i18n/tests/i18n.tests' -// import './logging/tests/createLog.tests' -// import './mixins/tests/checkPermissions.tests' -// import './schema/tests/SchemaOptions.test' -// import './scoring/tests/Scoring.tests' -// import './items/tests' +import './contexts/tests/contexts.tests' +import './contexts/tests/fileContexts.tests' +import './decorators/routes/tests/createGetByIdRoute.tests' +import './decorators/routes/tests/getAll.tests' +import './i18n/tests/i18n.tests' +import './logging/tests/createLog.tests' +import './mixins/tests/checkPermissions.tests' +import './schema/tests/SchemaOptions.test' +import './scoring/tests/Scoring.tests' +import './items/tests' import './tts/tests' -// import './utils/tests' -// import './validation/tests' +import './utils/tests' +import './validation/tests' diff --git a/errors/FieldNotFoundError.js b/errors/FieldNotFoundError.js index 51375a5..c6d40ba 100644 --- a/errors/FieldNotFoundError.js +++ b/errors/FieldNotFoundError.js @@ -2,8 +2,8 @@ import { Meteor } from 'meteor/meteor' export class FieldNotFoundError extends Meteor.Error { constructor (reason, details) { - super(FieldNotFoundError.name, reason, details) + super(FieldNotFoundError.NAME, reason, details) } } -FieldNotFoundError.name = 'errors.fieldNotFound' +FieldNotFoundError.NAME = 'errors.fieldNotFound' diff --git a/package.js b/package.js index 2f83823..fcfd213 100644 --- a/package.js +++ b/package.js @@ -1,7 +1,7 @@ /* eslint-env meteor */ Package.describe({ name: 'leaonline:corelib', - version: '1.0.0', + version: '2.0.0', // Brief, one-line summary of the package. summary: 'Includes the most common reusable components for lea.online', // URL to the Git repository containing the source code for this package. @@ -12,16 +12,20 @@ Package.describe({ }) Package.onUse(function (api) { - api.versionsFrom('1.6') + api.versionsFrom(['3.0.1']) api.use('ecmascript') api.use('reactive-var') }) Package.onTest(function (api) { - api.use('ecmascript') - api.use('mongo') - api.use('random') - api.use(['lmieulet:meteor-legacy-coverage', 'lmieulet:meteor-coverage', 'meteortesting:mocha']) + api.versionsFrom(['3.0.1']) + api.use([ + 'ecmascript', + 'mongo', + 'random', + // 'lmieulet:meteor-coverage@1.0.0 || 2.0.0', + 'meteortesting:mocha@3.0.0-rc.1' + ]) api.use('leaonline:corelib') api.mainModule('core-tests.js') }) diff --git a/test-proxy/.meteor/packages b/test-proxy/.meteor/packages index f8442e0..12882c6 100644 --- a/test-proxy/.meteor/packages +++ b/test-proxy/.meteor/packages @@ -4,18 +4,18 @@ # 'meteor add' and 'meteor remove' will edit this file for you, # but you can also edit it by hand. -meteor-base@1.4.0 # Packages every Meteor app needs to have -mobile-experience@1.1.0 # Packages for a great mobile UX -mongo@1.10.0 # The database Meteor supports right now -static-html # Define static page content in .html files -reactive-var@1.0.11 # Reactive variable for tracker -tracker@1.2.0 # Meteor's client-side reactive programming library +meteor-base@1.5.2 # Packages every Meteor app needs to have +mobile-experience@1.1.2 # Packages for a great mobile UX +mongo@2.0.0 # The database Meteor supports right now +static-html@1.3.3 # Define static page content in .html files +reactive-var@1.0.13 # Reactive variable for tracker +tracker@1.3.4 # Meteor's client-side reactive programming library -standard-minifier-css@1.6.1 # CSS minifier run for production mode -standard-minifier-js@2.6.0 # JS minifier run for production mode -es5-shim@4.8.0 # ECMAScript 5 compatibility for older browsers -ecmascript@0.14.3 # Enable ECMAScript2015+ syntax in app code -typescript@3.7.6 # Enable TypeScript syntax in .ts and .tsx modules -shell-server@0.5.0 # Server-side component of the `meteor shell` command +standard-minifier-css@1.9.3 # CSS minifier run for production mode +standard-minifier-js@3.0.0 # JS minifier run for production mode +es5-shim@4.8.1 # ECMAScript 5 compatibility for older browsers +ecmascript@0.16.9 # Enable ECMAScript2015+ syntax in app code +typescript@5.4.3 # Enable TypeScript syntax in .ts and .tsx modules +shell-server@0.6.0 # Server-side component of the `meteor shell` command jkuester:http diff --git a/test-proxy/.meteor/release b/test-proxy/.meteor/release index 019e3ae..508bc95 100644 --- a/test-proxy/.meteor/release +++ b/test-proxy/.meteor/release @@ -1 +1 @@ -METEOR@1.11.1 +METEOR@3.0.1 diff --git a/test-proxy/.meteor/versions b/test-proxy/.meteor/versions index 7d0df17..c8cc9ad 100644 --- a/test-proxy/.meteor/versions +++ b/test-proxy/.meteor/versions @@ -1,69 +1,72 @@ -allow-deny@1.1.0 -autoupdate@1.6.0 -babel-compiler@7.5.3 -babel-runtime@1.5.0 -base64@1.0.12 -binary-heap@1.0.11 -blaze-tools@1.0.10 -boilerplate-generator@1.7.1 -caching-compiler@1.2.2 -caching-html-compiler@1.1.3 -callback-hook@1.3.0 -check@1.3.1 -ddp@1.4.0 -ddp-client@2.3.3 -ddp-common@1.4.0 -ddp-server@2.3.2 -deps@1.0.12 -diff-sequence@1.1.1 -dynamic-import@0.5.3 -ecmascript@0.14.3 -ecmascript-runtime@0.7.0 -ecmascript-runtime-client@0.11.0 -ecmascript-runtime-server@0.10.0 -ejson@1.1.1 -es5-shim@4.8.0 -fetch@0.1.1 -geojson-utils@1.0.10 -hot-code-push@1.0.4 -html-tools@1.0.11 -htmljs@1.0.11 -id-map@1.1.0 -inter-process-messaging@0.1.1 -launch-screen@1.2.0 -livedata@1.0.18 -logging@1.1.20 -meteor@1.9.3 -meteor-base@1.4.0 -minifier-css@1.5.3 -minifier-js@2.6.0 -minimongo@1.6.0 -mobile-experience@1.1.0 -mobile-status-bar@1.1.0 -modern-browsers@0.1.5 -modules@0.15.0 -modules-runtime@0.12.0 -mongo@1.10.0 -mongo-decimal@0.1.2 -mongo-dev-server@1.1.0 -mongo-id@1.0.7 -npm-mongo@3.8.1 -ordered-dict@1.1.0 -promise@0.11.2 -random@1.2.0 -reactive-var@1.0.11 -reload@1.3.0 -retry@1.1.0 -routepolicy@1.1.0 -shell-server@0.5.0 -socket-stream-client@0.3.1 -spacebars-compiler@1.1.3 -standard-minifier-css@1.6.1 -standard-minifier-js@2.6.0 -static-html@1.2.2 -templating-tools@1.1.2 -tracker@1.2.0 -typescript@3.7.6 -underscore@1.0.10 -webapp@1.9.1 -webapp-hashing@1.0.9 +allow-deny@2.0.0 +autoupdate@2.0.0 +babel-compiler@7.11.0 +babel-runtime@1.5.2 +base64@1.0.13 +binary-heap@1.0.12 +blaze-tools@2.0.0 +boilerplate-generator@2.0.0 +caching-compiler@2.0.0 +caching-html-compiler@2.0.0 +callback-hook@1.6.0 +check@1.4.2 +core-runtime@1.0.0 +ddp@1.4.2 +ddp-client@3.0.0 +ddp-common@1.4.3 +ddp-server@3.0.0 +diff-sequence@1.1.3 +dynamic-import@0.7.4 +ecmascript@0.16.9 +ecmascript-runtime@0.8.2 +ecmascript-runtime-client@0.12.2 +ecmascript-runtime-server@0.11.1 +ejson@1.1.4 +es5-shim@4.8.1 +facts-base@1.0.2 +fetch@0.1.5 +geojson-utils@1.0.12 +hot-code-push@1.0.5 +html-tools@2.0.0 +htmljs@2.0.1 +id-map@1.2.0 +inter-process-messaging@0.1.2 +jkuester:http@2.3.0 +launch-screen@2.0.1 +logging@1.3.5 +meteor@2.0.0 +meteor-base@1.5.2 +minifier-css@2.0.0 +minifier-js@3.0.0 +minimongo@2.0.0 +mobile-experience@1.1.2 +mobile-status-bar@1.1.1 +modern-browsers@0.1.11 +modules@0.20.1 +modules-runtime@0.13.2 +mongo@2.0.0 +mongo-decimal@0.1.4-beta300.7 +mongo-dev-server@1.1.1 +mongo-id@1.0.9 +npm-mongo@4.17.3 +ordered-dict@1.2.0 +promise@1.0.0 +random@1.2.2 +react-fast-refresh@0.2.9 +reactive-var@1.0.13 +reload@1.3.2 +retry@1.1.1 +routepolicy@1.1.2 +shell-server@0.6.0 +socket-stream-client@0.5.3 +spacebars-compiler@2.0.0 +standard-minifier-css@1.9.3 +standard-minifier-js@3.0.0 +static-html@1.3.3 +templating-tools@2.0.0 +tracker@1.3.4 +typescript@5.4.3 +underscore@1.6.4 +url@1.3.3 +webapp@2.0.0 +webapp-hashing@1.1.2 diff --git a/utils/getFieldName.js b/utils/getFieldName.js index f2739ba..cd9f1a0 100644 --- a/utils/getFieldName.js +++ b/utils/getFieldName.js @@ -1,5 +1,12 @@ import { FieldNotFoundError } from '../errors/FieldNotFoundError' +/** + * Extracts a field's name from a given schema. + * @param schema {object} + * @param field {object} + * @return {string} + * @throws {FieldNotFoundError} if no field has been found that matches given field + */ export const getFieldName = (schema, field) => { const found = Object.entries(schema).find(([key, value]) => value === field) if (found?.length === 2) { diff --git a/utils/tests/getFieldName.tests.js b/utils/tests/getFieldName.tests.js index 9b1a979..7c4a989 100644 --- a/utils/tests/getFieldName.tests.js +++ b/utils/tests/getFieldName.tests.js @@ -12,6 +12,6 @@ describe(getFieldName.name, function () { }) it('throws if the field name is not found', function () { const schema = {} - expect(() => getFieldName(schema, 'foo')).to.throw(FieldNotFoundError.name) + expect(() => getFieldName(schema, 'foo')).to.throw(FieldNotFoundError.NAME) }) })