{"id":23138204,"url":"https://github.com/softlayer/sl-ember-test-helpers","last_synced_at":"2025-08-17T11:32:47.035Z","repository":{"id":23503761,"uuid":"26869454","full_name":"softlayer/sl-ember-test-helpers","owner":"softlayer","description":"An Ember CLI Addon that provides and registers test helpers for use in the testing of your application","archived":false,"fork":false,"pushed_at":"2016-03-04T15:54:07.000Z","size":4647,"stargazers_count":6,"open_issues_count":17,"forks_count":6,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-12-14T03:03:55.148Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://softlayer.github.io/sl-ember-test-helpers","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/softlayer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-11-19T16:08:10.000Z","updated_at":"2016-01-11T20:58:10.000Z","dependencies_parsed_at":"2022-08-22T01:30:47.404Z","dependency_job_id":null,"html_url":"https://github.com/softlayer/sl-ember-test-helpers","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsl-ember-test-helpers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsl-ember-test-helpers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsl-ember-test-helpers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softlayer%2Fsl-ember-test-helpers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softlayer","download_url":"https://codeload.github.com/softlayer/sl-ember-test-helpers/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230121667,"owners_count":18176477,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-17T13:10:08.788Z","updated_at":"2024-12-17T13:10:09.431Z","avatar_url":"https://github.com/softlayer.png","language":"JavaScript","readme":"\n[![Latest Release](https://img.shields.io/github/release/softlayer/sl-ember-test-helpers.svg)](https://github.com/softlayer/sl-ember-test-helpers/releases) ![Ember CLI version](https://img.shields.io/badge/ember%20cli-2.4.1-blue.svg) [![License](https://img.shields.io/npm/l/sl-ember-test-helpers.svg)](LICENSE.md) [![Downloads](https://img.shields.io/npm/dm/sl-ember-test-helpers.svg)](https://www.npmjs.com/package/sl-ember-test-helpers)\n\n[![Dependencies](https://img.shields.io/david/softlayer/sl-ember-test-helpers.svg)](https://david-dm.org/softlayer/sl-ember-test-helpers) [![Dev Dependencies](https://img.shields.io/david/dev/softlayer/sl-ember-test-helpers.svg)](https://david-dm.org/softlayer/sl-ember-test-helpers#info=devDependencies)\n\n[![Build Status](https://img.shields.io/travis/softlayer/sl-ember-test-helpers/master.svg)](https://travis-ci.org/softlayer/sl-ember-test-helpers) [![Code Climate](https://img.shields.io/codeclimate/github/softlayer/sl-ember-test-helpers.svg)](https://codeclimate.com/github/softlayer/sl-ember-test-helpers) [![Ember Observer](http://emberobserver.com/badges/sl-ember-test-helpers.svg)](http://emberobserver.com/addons/sl-ember-test-helpers) [![Inch CI](http://inch-ci.org/github/softlayer/sl-ember-test-helpers.svg?branch=master)](http://inch-ci.org/github/softlayer/sl-ember-test-helpers)\n\nWe use [https://waffle.io/softlayer/sl-ember-test-helpers](https://waffle.io/softlayer/sl-ember-test-helpers) to work our issues.\n\n[![Stories in Ready](https://badge.waffle.io/softlayer/sl-ember-test-helpers.png?label=ready\u0026title=Ready)](https://waffle.io/softlayer/sl-ember-test-helpers) [![Stories in In Progress](https://badge.waffle.io/softlayer/sl-ember-test-helpers.png?label=in%20progress\u0026title=In%20Progress)](https://waffle.io/softlayer/sl-ember-test-helpers) [![Stories in Ready For Review](https://badge.waffle.io/softlayer/sl-ember-test-helpers.png?label=ready%20for%20review\u0026title=Ready%20For%20Review)](https://waffle.io/softlayer/sl-ember-test-helpers) [![Stories in In Review](https://badge.waffle.io/softlayer/sl-ember-test-helpers.png?label=in%20review\u0026title=In%20Review)](https://waffle.io/softlayer/sl-ember-test-helpers)\n\n[![Throughput Graph](https://graphs.waffle.io/softlayer/sl-ember-test-helpers/throughput.svg)](https://waffle.io/softlayer/sl-ember-test-helpers/metrics)\n\n\n# What is sl-ember-test-helpers\n\nThis addon provides and registers test helpers for use in the testing of your application.  This addon is compatible with QUnit, Mocha, and any other testing framework you wish to use (or at least should be).\n\n\n\n# Provided helpers\n\n## Synchronous\n\n### ajax\n\nEmulates the beginning and completion of an AJAX request or requests.\n\n* `Ajax.begin()` triggers the `ajaxStart` event on the document\n* `Ajax.begin( 'endpointValue' )` triggers the `ajaxSend` event on the document, passing the supplied endpoint value\n* `Ajax.end()` triggers the `ajaxStop` event on the document\n* `Ajax.end( 'endpointValue' )` triggers the `ajaxComplete` event on the document, passing the supplied endpoint\nvalue\n\n\n### contains\n\n```\ncontains( valuesUnderTest, valuesToTestFor );\n```\n\nDetermine whether values are contained in other values.  These values can be a combination of Arrays, Strings, or\nObjects (for which the keys are extracted).  All *valuesToTestFor* must exist in *valuesUnderTest* for this\ndetermination to pass successfully.\n\nCalls to `contains()` return a boolean which can then be used in your tests.\n\nThis call would fail because the Object being tested does not contain keys matching the values of \"a\" and \"b\":\n\n```\ncontains( { c: 1, b: 3 }, [ 'a', 'b' ] );\n```\n\nThis call would pass because the Array being tested contains the value of \"b\":\n\n```\ncontains( [ 'a', 'b' ], 'b' );\n```\n\n### requires\n\nUse this helper to test that an argument passed to a function is of the required type(s).  The first argument is the\nfunction under test and the second argument is an array of types to test for.\n\n```\nrequires( functionUnderTest, [ 'string', 'object', 'function' ] );\n```\n\n#### Types\n\n* number\n* string\n* array\n* object\n* function\n* undefined\n* boolean\n\nThe call to `requires` returns an object:\n\n```\n{\n    requires: \u003cboolean: true if functionUnderTest requires the provided arguments, false if not\u003e\n    messages: \u003cstring: message per argument type that failed\u003e\n}\n```\n\n### Global Libraries\n\nUse this helper in your unit tests to determine if a component called globally-scoped `Ember.$`, `$` or `jQuery`. You must wrap your component with references to the setup and removal functions.\n\n```\nconst component = this.subject();\n\nglobalLibraries.setupSpies();\n\nglobalLibraries.triggerEvents( component );\n\nassert.notOk(\n    globalLibraries.called(),\n    'There are no references to Ember.$, $ or jQuery'\n);\n\nglobalLibraries.restoreSpies();\n```\n\nThe `triggerEvents()` function takes a `component` as an argument and triggers the following events on it: `willInsertElement`, `didInsertElement`, `willClearRender` and `willDestroyElement`. Triggering of the various events\nwill ensure code that has handlers attached to those events will be exercised, making the helper more effective at detecting global references.\n\nThe call to `called()` returns a boolean that is the result of the sinon spies detecting `Ember.$`, `$`, or `jQuery`. Validate `false` to verify that the code within the component does not have global references to\n`Ember.$`, `$` or `jQuery`.\n\n```\n\u003cboolean: true if the spy detects a reference to the global scope, false if not\u003e\n```\n\n## Asynchronous\n\n### ajax\n\nSee description in *Synchronous* section\n\n### contains\n\nSee description in *Synchronous* section\n\n### requires\n\nSee description in *Synchronous* section\n\n\n\n# Utilities\n\nThere are several utility functions provided in the */test-support/helpers/sl/utils/utils.js* file that, while used\ninternally by the helpers themselves, can be imported as needed for use.  These include:\n\n* convertToArray()\n* convertStringToArray()\n* convertObjectKeysToArray()\n* doArraysIntersect()\n\n\n\n# How to use this addon in your application\n\n## Install\n\n```\nember install sl-ember-test-helpers\n```\n\n## If running Synchronous tests, such as Unit Tests\n\nFor each test helper you wish to use, you will need to import them into each individual Unit Tests. For example:\n\n```\nimport { contains } from '../../helpers/sl/synchronous';\n```\n\n## If running Asynchronous tests, such as Acceptance Tests\n\nInstalling this addon via the `ember install:addon` command will automatically run the generator, which will make\nchanges to the following files:\n\n* tests/helpers/start-app.js\n* tests/.jshintrc\n\nIf your application is under source control management, such as via Git, make sure to commit these changes.\n\nThe generator makes changes to the above files assuming the structure of them has not changed much from the default\nversion created during the initial Ember application creation.  If too many changes have been made you will need to\nmanually make the changes below:\n\n* Add `import slRegisterTestHelpers from './sl/register-test-helpers';` to the beginning of the *tests/helpers/start-\napp.js* file\n* In the *tests/helpers/start-app.js* file, place `slRegisterTestHelpers();` before the `application.\ninjectTestHelpers()` line\n* Add `\"contains\",` to the `predef` section of the */tests/.jshintrc* file\n\n## Generated documentation\n\nThis addon leverages the [ember-cli-jsdoc](https://github.com/softlayer/ember-cli-jsdoc) addon.  Simply run either\n`ember ember-cli-jsdoc` or `npm run docs` (shortcut setup in this repo) and then visit *http://localhost:4200/docs*.\n\n\n\n# Versioning\nEmploys [Semantic Versioning 2.0.0](http://semver.org/)\n\n\n# Contribution\n[See CONTRIBUTING.md](https://github.com/softlayer/sl-ember-test-helpers/blob/master/CONTRIBUTING.md)\n\n\n# Copyright and License\nsl-ember-test-helpers and its source files are Copyright © 2014-2015\n[SoftLayer Technologies, Inc.](http://www.softlayer.com/). The software is\n[MIT Licensed](https://github.com/softlayer/sl-ember-test-helpers/blob/master/LICENSE.md)\n\n\n\n# Warranty\nThis software is provided “as is” and without any express or implied warranties, including, without limitation, the\nimplied warranties of merchantability and fitness for a particular purpose.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftlayer%2Fsl-ember-test-helpers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftlayer%2Fsl-ember-test-helpers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftlayer%2Fsl-ember-test-helpers/lists"}