test/unit/helpers.language.js
import sinon from 'sinon';
import test from 'ava';
import {
client,
Language,
} from '../../src';
test.before('start server', () => {
client.apiBaseUrl = 'https://somesite.Clinical6.com';
client.config = {
track: {
flows: false,
gps: false
}
};
});
test.after('server shut down', () => {});
test.beforeEach((t) => {
client.authToken = 'valid_token';
// Reusable Server
t.context.server = sinon.fakeServer.create();
t.context.server.autoRespond = true;
t.context.server.respondWith('GET', `${client.apiBaseUrl}/api/languages/en`,
[200, { 'Content-Type': 'application/json' }, JSON.stringify({
translations: {
verify_title: 'Enter your 6 Digit ID & Email Address',
verify_email_input: 'Email Address',
verify_continue: 'CONTINUE',
verify_disclaimer: 'Click here if you have already enrolled',
welcome_header: 'WELCOME TO THE STUDY',
welcome_title: 'Qualify',
welcome_description: 'Blah blah blah',
welcome_button_continue: 'CONTINUE',
qualification_button_next: 'NEXT',
qualification_button_prev: 'PREV',
qualification_page_number: '{{value}} of {{value1}}',
walkthrough_title: 'Welcome!',
walkthrough_description: 'This simple walkthrough',
walkthrough_button_continue: 'CONTINUE',
consent_button_aggree: 'AGREE',
consent_button_learn_more: 'LEARN MORE',
consent_header: 'Informed Consent',
comprehension_header: 'Comprehension Check',
comprehension_title: 'Did you understand everything?',
comprehension_description: 'Blah blah blah',
comprehension_button_submit: 'SUBMIT',
comprehension_great_job: 'Great Job!',
comprehension_great_job_description: 'You answered all of the questions correctly. Tap Next to continue.',
comprehension_great_job_button_next: 'NEXT',
agreement_title: 'Final Agreement',
agreement_description: 'By tapping Agree below, you are consenting to be part of this study',
agreement_button_agree: 'AGREE',
agreement_check_agree: 'I agree to the terms of the study',
participant_title: 'Check your email',
participant_description: 'Your participant ID has been sent to the email you provided. Please enter below to unlock the app.',
participant_text_field: 'Participant ID',
participant_button_submit: 'SUBMIT',
dialog_content_empty_text: 'Please enter all required values.',
dialog_button_ok: 'OK',
create_pin_title: 'Next, create a 4 digit PIN',
create_pin_description: 'Please be sure to remember this information. You will be asked to enter this information the next time you enter the app.',
create_pin_text_field_pin: 'Enter Unique 4 Digit PIN',
create_pin_text_field_confirm: 'Confirm 4 Digit PIN',
create_pin_button_unlock: 'UNLOCK',
home_your_progress: 'Your Progress',
home_alerts: 'You have {{value}} alerts',
tutorial_home_at_any_time: 'At any time, access help screens for each area.',
tutorial_home_see: 'See your current progress within the study.',
tutorial_home_swipe: 'Swipe up on the menu to scroll down.',
profile_button_cancel: 'Cancel',
profile_button_edit_profile: 'EDIT PROFILE',
profile_button_withdraw: 'WITHDRAW FROM APP',
profile_button_save: 'SAVE',
profile_textfield_name: 'First Name',
profile_textfield_email: 'Email',
alert_withdraw_cancel: 'Cancel',
alert_withdraw_continue: 'Continue',
alert_delete_cancel: 'Cancel',
alert_confirm: 'Confirm',
withdraw_header: 'Withdraw from App',
withdraw_title: 'Withdraw from App',
withdraw_description: '<p>Please provide the reason for leaving the study app below:</p>',
withdraw_textfield_hint: 'Why are you leaving the study app?',
withdraw_textfield_yes: 'yes',
withdraw_button_submit: 'SUBMIT',
withdraw_option_yes: 'Yes, erase my data',
withdraw_option_no: 'No, Keep my data',
studyp_header: 'Study Progress',
studyp_title_completion: '{{value}}% Complete',
studyp_row_quarter: 'QUARTER {{value}}',
studyp_row_percentage: '{{value}}%',
studyp_row_complete: 'COMPLETE',
event_tracker_header: 'Events',
event_tracker_disclaimer: 'If you are experiencing a SH or MH, please contact your doctor immediately.',
event_tracker_button_continue: 'CONTINUE',
event_tracker_search: 'search',
event_tracker_button_record_new: 'RECORD NEW EVENT',
event_tracker_new_header: 'New Event',
event_tracker_new_title: 'Title Your Entry',
event_tracker_new_write_event: 'Write Event Entry',
event_tracker_new_record_a_video: 'Record a Video',
event_tracker_new_take_a_photo: 'Take a Photo',
event_tracker_new_button_submit: 'Submit Event',
tutorial_event_tracker_describe: 'Describe your event here',
tutorial_event_tracker_you_can: 'You can also add a photo or video to your event by selecting the buttons below the text field.',
badges_header: 'Badges',
badges_keep_up: 'Keep up the good work!',
badges_below: 'Below are the badges earned throughout the study so far. Earn more as new milestones are met.',
badges_recent_badges: 'Recent Badges',
tutorial_badges_tap_on: 'Tap on any badge to read its description',
tutorial_resources_select_an: 'Select an item from the list on this screen to find top level details about the study.',
tutorial_resources_about: 'About the study',
tutorial_resources_faqs: 'FAQs',
tutorial_resources_key: 'Key Terms',
tutorial_resources_glossary: 'Glossary of Terms',
tutorial_resources_technical: 'Technical Support',
resource_header: 'Resources',
tech_support_header: 'Tech Support',
tech_support_title: 'Contact Tech Support',
tech_support_button_call: 'TAP TO CALL: {{value}}',
tech_support_button_email: 'EMAIL: {{value}}',
about_study_header: 'About the Study',
about_study_title: 'About the Study',
faq_header: 'FAQ',
key_terms_header: 'Key Terms',
glossary_header: 'Glossary of Terms',
glossary_search: 'Search',
alerts_header: 'Alerts',
tutorial_alerts_you_can: 'You can tap any notification and be sent to the appropriate section of the app. Tap X to ignore.',
tutorial_alerts_title: '1 New Survey Available',
tutorial_alerts_description: '1st Quarterly Survey Available',
surveys_header: 'Surveys',
surveys_title_no: 'You have no new surveys',
surveys_title_yes: 'You have {{value}} new survey. Tap below to complete:',
surveys_thank_you_title: 'Thank you!',
surveys_thank_you_subtitle: 'You have completed today\'s survey.',
surveys_thank_you_description: 'Thank you for your time.',
surveys_thank_you_button_complete: 'COMPLETE',
tutorial_surveys_title: '1st Quarterly Assessment: Nov 25, 2016',
profile_setup_header: 'Profile Setup',
profile_setup_title: 'Profile Setup',
profile_setup_description: 'As a last step, we will ask you a few questions to complete your profile. Tap Next to complete setup.',
ethnicity_title: 'Ethnicity',
ethnicity_american: 'American Indian or Alaska Native',
ethnicity_asian: 'Asian',
ethnicity_black: 'Black, African American or of African Heritage',
ethnicity_white: 'White',
ethnicity_other: 'Other',
education_title: 'Education',
education_highschool: 'High School Degree',
education_associate: 'Associate\'s Degree',
education_bachelor: 'Bachelor\'s Degree',
education_master: 'Master\'s Degree',
education_doctoral: 'Doctoral Degree',
education_other: 'Other',
error_unexpected_result: 'Unable to connect with Dexcom. Try again later.',
error_unexpected_request: 'There was an error processing your information, please try again',
error_button_confirm: 'Confirm',
error_empty_list: 'There is no content available for this!',
error_button_cancel: 'Cancel',
error_header_subject_site: 'Incorrect ID',
error_record_not_found: 'The information you entered does not match our records. Please try again.',
error_email_syntax: 'The email format is incorrect.',
error_missing_fields: 'All text fields are required.',
error_required_field: 'Required Field',
error_pin_size_header: 'Not Enough Characters',
error_pin_size: 'The information you entered does not contain 4 characters. Please try again.',
error_email_duplicated: 'The email address entered is already in use.',
error_header_pin_match: 'PINs Do Not Match',
error_header_invalid_pin: 'Invalid PIN',
error_pin_invalid: 'We cannot find your PIN in the system. Please re-enter your PIN.',
error_pin_reset: 'Would you like to reset your 4 Digit PIN?',
error_email_not_found: 'We cannot find your email address in the system. Please re-enter your email address.',
error_activation_code: 'An invalid activation code has been entered.',
error_pin_match: 'Your PINs do not match. Please try again.',
error_video_size: 'Your video must not exceed 16 MB.',
insurance_title: 'Insurance',
insurance_ppo: 'PPO',
insurance_hmo: 'HMO',
insurance_medicare: 'Medicare',
insurance_medicaid: 'Medicaid',
insurance_other: 'Other',
help_learn_more: 'Learn More',
help_more_info: 'For More Information',
help_call: 'Call',
help_email: 'Email',
help_download_consent: 'Download Consent',
help_read_information: 'Read the information below to see specific details outlined within the consent form.',
help_excerpt: 'Excerpt From Consent Form',
verify_id_title: 'Enter your 6 Digit ID',
verify_id_description: 'Please enter the 6 Digit ID that was provided in the email invitation.',
verify_id_input: '6 Digit ID',
verify_id_continue: 'Continue',
tutorial_home_info: 'At any time, access help screens for each area.',
tutorial_study_description: 'The list on this screen shows your progress in the study. Tap a month to learn more about it.',
enter_pin_title: 'Enter your 4 digit PIN',
enter_pint_input: 'Enter unique 4 digit PIN',
enter_pin_reset: 'I forgot my 4 digit PIN',
verify_digit_input: '6 Digit ID',
welcome_enroll_title: 'Please select an option below that applies:',
welcome_enroll_new: 'ENROLLING AS NEW PARTICIPANT',
welcome_enroll_active: 'PREVIOUSLY ENROLLED ON WEB',
verify_id_dob: 'Date of Birth',
reset_pin_title: 'We can send an activation code to your email to reset your PIN.',
reset_pin_input: 'Email Address',
reset_button_send: 'Send',
reset_success_title: 'Please check your email. We sent you a new activation code.',
reset_success_description: 'We sent an email to {{value}}',
reset_button_continue: 'Continue',
activation_title: 'Enter the activation code found in your email.',
activation_input: 'Enter 4 digit code',
activation_button_submit: 'Submit',
contact_close_app: 'CLOSE APP',
ethnicity_question: 'What is your ethnicity?',
ethnicity_hispanic: 'Hispanic',
ethnicity_nonhispanic: 'Non-Hispanic',
ethnicity_race_title: 'Race',
ethnicity_race: 'What is your race?',
education_question: 'What is your highest level of education?',
insurance_coverage: 'What is your insurance coverage?',
error_header_pin_invalid: 'Invalid PIN',
survey_question_screen_label: '{{value}} of {{value2}}',
no_alerts: 'No notifications',
login_error_header: 'Login error',
login_error_body: 'Your login pin is incorrect',
learn_more_incorrect_answer: 'Incorrect Answer'
}
})]);
// Reusable Flow
t.context.lang = new Language({ iso: 'en' });
});
test.afterEach((t) => {
t.context.server.restore();
});
// Get Translations
/**
* @test {Language.getTranslations}
*/
test('[unit] Language.getTranslations should exist', (t) => {
const { lang } = t.context;
t.truthy(lang.getTranslations);
});
/**
* @test {Language.getTranslations}
*/
test('[unit] Language.getTranslations method should return a promise', (t) => {
const { lang } = t.context;
t.truthy(lang.getTranslations().then);
});
/**
* @test {Language.getTranslations}
*/
test('[unit] Language.getTranslations method should return a comment object', async (t) => {
const { lang } = t.context;
await lang.getTranslations();
t.is(lang.translate('verify_title'), 'Enter your 6 Digit ID & Email Address');
});