├── .bowerrc
├── .circleci
└── config.yml
├── .editorconfig
├── .ember-cli
├── .eslintignore
├── .eslintrc.js
├── .github
├── ISSUE_TEMPLATE.md
└── PULL_REQUEST_TEMPLATE.md
├── .gitignore
├── .npmignore
├── .template-lintrc.js
├── .travis.yml
├── .watchmanconfig
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── LICENSE.md
├── README.md
├── addon
├── -private
│ └── create-string-helper.js
├── .gitkeep
├── helpers
│ ├── camelize.js
│ ├── capitalize.js
│ ├── classify.js
│ ├── dasherize.js
│ ├── html-safe.js
│ ├── humanize.js
│ ├── lowercase.js
│ ├── titleize.js
│ ├── trim.js
│ ├── truncate.js
│ ├── underscore.js
│ ├── uppercase.js
│ └── w.js
└── utils
│ ├── lowercase.js
│ ├── titleize.js
│ ├── trim.js
│ └── uppercase.js
├── app
├── .gitkeep
├── helpers
│ ├── camelize.js
│ ├── capitalize.js
│ ├── classify.js
│ ├── dasherize.js
│ ├── html-safe.js
│ ├── humanize.js
│ ├── lowercase.js
│ ├── titleize.js
│ ├── trim.js
│ ├── truncate.js
│ ├── underscore.js
│ ├── uppercase.js
│ └── w.js
└── utils
│ └── titleize.js
├── config
├── ember-try.js
└── environment.js
├── ember-cli-build.js
├── index.js
├── lib
├── difference.js
├── intersection.js
└── strip-bad-reexports.js
├── package.json
├── test
├── index-test.js
└── lib
│ ├── difference-test.js
│ └── intersection-test.js
├── testem.js
├── tests
├── dummy
│ ├── app
│ │ ├── app.js
│ │ ├── components
│ │ │ └── .gitkeep
│ │ ├── controllers
│ │ │ └── .gitkeep
│ │ ├── helpers
│ │ │ └── .gitkeep
│ │ ├── index.html
│ │ ├── models
│ │ │ └── .gitkeep
│ │ ├── resolver.js
│ │ ├── router.js
│ │ ├── routes
│ │ │ └── .gitkeep
│ │ ├── styles
│ │ │ └── app.css
│ │ └── templates
│ │ │ ├── application.hbs
│ │ │ └── components
│ │ │ ├── .gitkeep
│ │ │ ├── perform-calculation.hbs
│ │ │ └── toggle-button.hbs
│ ├── config
│ │ ├── environment.js
│ │ ├── optional-features.json
│ │ └── targets.js
│ └── public
│ │ └── robots.txt
├── index.html
├── integration
│ ├── .gitkeep
│ └── helpers
│ │ ├── camelize-test.js
│ │ ├── capitalize-test.js
│ │ ├── classify-test.js
│ │ ├── dasherize-test.js
│ │ ├── html-safe-test.js
│ │ ├── humanize-test.js
│ │ ├── lowercase-test.js
│ │ ├── titleize-test.js
│ │ ├── trim-test.js
│ │ ├── truncate-test.js
│ │ ├── underscore-test.js
│ │ ├── uppercase-test.js
│ │ └── w-test.js
├── test-helper.js
└── unit
│ ├── .gitkeep
│ └── utils
│ └── titleize-test.js
├── vendor
└── .gitkeep
└── yarn.lock
/.bowerrc:
--------------------------------------------------------------------------------
1 | {
2 | "directory": "bower_components",
3 | "analytics": false
4 | }
5 |
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | jobs:
3 | build:
4 | working_directory: ~/adopted-ember-addons/ember-cli-string-helpers
5 | docker:
6 | - image: circleci/node:10-browsers
7 | steps:
8 | - checkout
9 | - restore_cache:
10 | key: node-modules-cache-{{ checksum "yarn.lock" }}
11 | - run:
12 | name: Install packages
13 | command: yarn
14 | - save_cache:
15 | key: node-modules-cache-{{ checksum "yarn.lock" }}
16 | paths:
17 | - node_modules
18 | - run:
19 | name: Run tests
20 | command: yarn test
21 | esac
22 | - store_test_results:
23 | path: test-results
24 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig helps developers define and maintain consistent
2 | # coding styles between different editors and IDEs
3 | # editorconfig.org
4 |
5 | root = true
6 |
7 |
8 | [*]
9 | end_of_line = lf
10 | charset = utf-8
11 | trim_trailing_whitespace = true
12 | insert_final_newline = true
13 | indent_style = space
14 | indent_size = 2
15 |
16 | [*.hbs]
17 | insert_final_newline = false
18 |
19 | [*.{diff,md}]
20 | trim_trailing_whitespace = false
21 |
--------------------------------------------------------------------------------
/.ember-cli:
--------------------------------------------------------------------------------
1 | {
2 | /**
3 | Ember CLI sends analytics information by default. The data is completely
4 | anonymous, but there are times when you might want to disable this behavior.
5 |
6 | Setting `disableAnalytics` to true will prevent any data from being sent.
7 | */
8 | "disableAnalytics": false
9 | }
10 |
--------------------------------------------------------------------------------
/.eslintignore:
--------------------------------------------------------------------------------
1 | # unconventional js
2 | /blueprints/*/files/
3 | /vendor/
4 |
5 | # compiled output
6 | /dist/
7 | /tmp/
8 |
9 | # dependencies
10 | /bower_components/
11 |
12 | # misc
13 | /coverage/
14 | !.*
15 |
16 | # ember-try
17 | /.node_modules.ember-try/
18 | /bower.json.ember-try
19 | /package.json.ember-try
20 |
--------------------------------------------------------------------------------
/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | parserOptions: {
4 | ecmaVersion: 2017,
5 | sourceType: 'module'
6 | },
7 | plugins: [
8 | 'ember'
9 | ],
10 | extends: [
11 | 'eslint:recommended',
12 | 'plugin:ember/recommended'
13 | ],
14 | env: {
15 | browser: true
16 | },
17 | rules: {
18 | },
19 | overrides: [
20 | // node files
21 | {
22 | files: [
23 | '.template-lintrc.js',
24 | 'ember-cli-build.js',
25 | 'index.js',
26 | 'testem.js',
27 | 'blueprints/*/index.js',
28 | 'config/**/*.js',
29 | 'tests/dummy/config/**/*.js'
30 | ],
31 | excludedFiles: [
32 | 'addon/**',
33 | 'addon-test-support/**',
34 | 'app/**',
35 | 'tests/dummy/app/**'
36 | ],
37 | parserOptions: {
38 | sourceType: 'script',
39 | ecmaVersion: 2015
40 | },
41 | env: {
42 | browser: false,
43 | node: true
44 | },
45 | plugins: ['node'],
46 | rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
47 | // add your custom rules and overrides for node files here
48 | })
49 | }
50 | ]
51 | };
52 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
20 |
21 |
22 | ## Version
23 |
24 |
25 | ## Test Case
26 |
27 |
28 | ## Steps to reproduce
29 |
30 |
31 | ## Expected Behavior
32 |
33 |
34 | ## Actual Behavior
35 |
36 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 | Closes # .
12 |
13 | ## Changes proposed in this pull request
14 |
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /dist/
5 | /tmp/
6 |
7 | # dependencies
8 | /bower_components/
9 | /node_modules/
10 |
11 | # misc
12 | /.sass-cache
13 | /connect.lock
14 | /coverage/
15 | /libpeerconnection.log
16 | /npm-debug.log*
17 | /testem.log
18 | /yarn-error.log
19 |
20 | # ember-try
21 | /.node_modules.ember-try/
22 | /bower.json.ember-try
23 | /package.json.ember-try
24 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | # compiled output
2 | /dist/
3 | /tmp/
4 |
5 | # dependencies
6 | /bower_components/
7 |
8 | # misc
9 | /.bowerrc
10 | /.editorconfig
11 | /.ember-cli
12 | /.eslintignore
13 | /.eslintrc.js
14 | /.gitignore
15 | /.template-lintrc.js
16 | /.travis.yml
17 | /.watchmanconfig
18 | /bower.json
19 | /config/ember-try.js
20 | /ember-cli-build.js
21 | /testem.js
22 | /tests/
23 | /yarn.lock
24 | .gitkeep
25 |
26 | # ember-try
27 | /.node_modules.ember-try/
28 | /bower.json.ember-try
29 | /package.json.ember-try
30 |
--------------------------------------------------------------------------------
/.template-lintrc.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = {
4 | extends: 'recommended'
5 | };
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | ---
2 | language: node_js
3 | node_js:
4 | # we recommend testing addons with the same minimum supported node version as Ember CLI
5 | # so that your addon works for all apps
6 | - "6"
7 |
8 | sudo: false
9 | dist: trusty
10 |
11 | addons:
12 | chrome: stable
13 |
14 | cache:
15 | directories:
16 | - $HOME/.npm
17 |
18 | env:
19 | global:
20 | # See https://git.io/vdao3 for details.
21 | - JOBS=1
22 |
23 | jobs:
24 | fail_fast: true
25 | allow_failures:
26 | - env: EMBER_TRY_SCENARIO=ember-canary
27 |
28 | include:
29 | # runs linting and tests with current locked deps
30 |
31 | - stage: "Tests"
32 | name: "Tests"
33 | script:
34 | - npm run lint:hbs
35 | - npm run lint:js
36 | - npm test
37 |
38 | # we recommend new addons test the current and previous LTS
39 | # as well as latest stable release (bonus points to beta/canary)
40 | - stage: "Additional Tests"
41 | env: EMBER_TRY_SCENARIO=ember-lts-2.16
42 | - env: EMBER_TRY_SCENARIO=ember-lts-2.18
43 | - env: EMBER_TRY_SCENARIO=ember-release
44 | - env: EMBER_TRY_SCENARIO=ember-beta
45 | - env: EMBER_TRY_SCENARIO=ember-canary
46 | - env: EMBER_TRY_SCENARIO=ember-default-with-jquery
47 | - env: EMBER_TRY_SCENARIO=embroider-safe
48 | - env: EMBER_TRY_SCENARIO=embroider-optimized
49 |
50 | before_install:
51 | - npm config set spin false
52 | - npm install -g npm@4
53 | - npm --version
54 |
55 | script:
56 | - node_modules/.bin/ember try:one $EMBER_TRY_SCENARIO
57 |
--------------------------------------------------------------------------------
/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {
2 | "ignore_dirs": ["tmp", "dist"]
3 | }
4 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, gender identity and expression, level of experience,
9 | nationality, personal appearance, race, religion, or sexual identity and
10 | orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | * Using welcoming and inclusive language
18 | * Being respectful of differing viewpoints and experiences
19 | * Gracefully accepting constructive criticism
20 | * Focusing on what is best for the community
21 | * Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | * The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | * Trolling, insulting/derogatory comments, and personal or political attacks
28 | * Public or private harassment
29 | * Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | * Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at brian@dockyard.com. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at [http://contributor-covenant.org/version/1/4][version]
72 |
73 | [homepage]: http://contributor-covenant.org
74 | [version]: http://contributor-covenant.org/version/1/4/
75 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # How to contribute
2 |
3 | ## Improve documentation
4 |
5 | We are always looking to improve our documentation. If at some moment you are
6 | reading the documentation and something is not clear, or you can't find what you
7 | are looking for, then please open an issue with the repository. This gives us a
8 | chance to answer your question and to improve the documentation if needed.
9 |
10 | Pull requests correcting spelling or grammar mistakes are always welcome.
11 |
12 | ## Found a bug?
13 |
14 | Please try to answer at least the following questions when reporting a bug:
15 |
16 | - Which version of the project did you use when you noticed the bug?
17 | - How do you reproduce the error condition?
18 | - What happened that you think is a bug?
19 | - What should it do instead?
20 |
21 | It would really help the maintainers if you could provide a reduced test case
22 | that reproduces the error condition.
23 |
24 | ## Have a feature request?
25 |
26 | Please provide some thoughful commentary and code samples on what this feature
27 | should do and why it should be added (your use case). The minimal questions you
28 | should answer when submitting a feature request should be:
29 |
30 | - What will it allow you to do that you can't do today?
31 | - Why do you need this feature and how will it benefit other users?
32 | - Are there any drawbacks to this feature?
33 |
34 | ## Submitting a pull-request?
35 |
36 | Here are some things that will increase the chance that your pull-request will
37 | get accepted:
38 | - Did you confirm this fix/feature is something that is needed?
39 | - Did you write tests, preferably in a test driven style?
40 | - Did you add documentation for the changes you made?
41 | - Did you follow our [styleguide](https://github.com/dockyard/styleguides)?
42 |
43 | If your pull-request addresses an issue then please add the corresponding
44 | issue's number to the description of your pull-request.
45 |
46 | # How to work with this project locally
47 |
48 | ## Installation
49 |
50 | First clone this repository:
51 |
52 | ```sh
53 | git clone https://github.com/adopted-ember-addons/ember-cli-string-helpers.git
54 | ```
55 |
56 |
57 |
58 | ## Running tests
59 |
60 |
61 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 DockYard, Inc
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6 |
7 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8 |
9 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
10 |
11 | ---
12 |
13 | For code taken from `ember-compose-action-helper`
14 |
15 | The MIT License (MIT)
16 |
17 | Copyright (c) 2016 Ryan Tablada
18 |
19 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
20 |
21 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
22 |
23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ember-cli-string-helpers
2 |  [](https://circleci.com/gh/adopted-ember-addons/ember-cli-string-helpers) [](https://badge.fury.io/js/ember-cli-string-helpers) [](http://emberobserver.com/addons/ember-cli-string-helpers)
3 |
4 | String helpers for Ember. Extracted from the great [DockYard's ember-composable-helpers](https://github.com/DockYard/ember-composable-helpers/).
5 |
6 | To install:
7 |
8 | ```no-highlight
9 | ember install ember-cli-string-helpers
10 | ```
11 |
12 | ## Configuration
13 |
14 | If you don't need all the helpers, you can specify which to whitelist or blacklist using `only` or `except` within your `ember-cli-build.js`:
15 |
16 | ```js
17 | module.exports = function(defaults) {
18 | var app = new EmberApp(defaults, {
19 | 'ember-cli-string-helpers': {
20 | only: ['dasherize', 'underscore'],
21 | except: ['titleize', 'capitalize']
22 | }
23 | });
24 | };
25 | ```
26 |
27 | Both `only` and `except` can be safely used together (the addon computes the diff), although it's best if you only use one for your own sanity.
28 |
29 | ```js
30 | except: ['camelize'] // imports all helpers except `camelize`
31 | only: ['camelize'] // imports only `camelize`
32 | ```
33 |
34 | ## Available helpers
35 |
36 | * [`camelize`](#camelize)
37 | * [`capitalize`](#capitalize)
38 | * [`classify`](#classify)
39 | * [`dasherize`](#dasherize)
40 | * [`html-safe`](#html-safe)
41 | * [`humanize`](#humanize)
42 | * [`lowercase`](#lowercase)
43 | * [`titleize`](#titleize)
44 | * [`trim`](#trim)
45 | * [`truncate`](#truncate)
46 | * [`underscore`](#underscore)
47 | * [`uppercase`](#uppercase)
48 | * [`w`](#w)
49 |
50 | ## Usage
51 |
52 | #### `camelize`
53 | Camelizes a string using `Ember.String.camelize`.
54 |
55 | ```hbs
56 | {{camelize "hello jim bob"}}
57 | {{camelize stringWithDashes}}
58 | ```
59 | Output: `helloJimBob`
60 |
61 | **[⬆️ back to top](#available-helpers)**
62 |
63 | #### `capitalize`
64 | Capitalizes a string using `Ember.String.capitalize`.
65 |
66 | ```hbs
67 | {{capitalize "hello jim bob"}}
68 | {{capitalize fullName}}
69 | ```
70 | Output: `Hello jim bob`
71 |
72 | **[⬆️ back to top](#available-helpers)**
73 |
74 | #### `classify`
75 | Classifies a string using `Ember.String.classify`.
76 |
77 | ```hbs
78 | {{classify "hello jim bob"}}
79 | {{classify stringWithDashes}}
80 | ```
81 | Output: `HelloJimBob`
82 |
83 | **[⬆️ back to top](#available-helpers)**
84 |
85 | #### `dasherize`
86 | Dasherizes a string using `Ember.String.dasherize`.
87 |
88 | ```hbs
89 | {{dasherize "whatsThat"}}
90 | {{dasherize phrase}}
91 | ```
92 | Output: `whats-that`
93 |
94 | **[⬆️ back to top](#available-helpers)**
95 |
96 | #### `html-safe`
97 | Mark a string as safe for unescaped output with Ember templates using `Ember.String.htmlSafe`.
98 |
99 | ```hbs
100 | {{html-safe "
someString
"}}
101 | {{html-safe unsafeString}}
102 | ```
103 |
104 | **[⬆️ back to top](#available-helpers)**
105 |
106 | #### `humanize`
107 | Removes dashes and underscores from a string, capitalizes the first letter and makes the rest of the string lower case.
108 |
109 | ```hbs
110 | {{humanize "some-string"}}
111 | {{humanize phrase}}
112 | ```
113 | Output: `Some string`
114 |
115 | **[⬆️ back to top](#available-helpers)**
116 |
117 |
118 | #### `lowercase`
119 | Lowercases a string.
120 |
121 | ```hbs
122 | {{lowercase "People Person's Paper People"}}
123 | {{lowercase phrase}}
124 | ```
125 | Output: `people person's paper people`
126 |
127 | **[⬆️ back to top](#available-helpers)**
128 |
129 | #### `titleize`
130 | Capitalizes every word separated by a white space or a dash.
131 |
132 | ```hbs
133 | {{titleize "my big fat greek wedding"}}
134 | {{titleize phrase}}
135 | ```
136 | Output: `My Big Fat Greek Wedding`
137 |
138 | **[⬆️ back to top](#available-helpers)**
139 |
140 | #### `trim`
141 | Trim a string.
142 |
143 | ```hbs
144 | {{trim " Lorem ipsum dolor sit amet, consectetur adipiscing elit. "}}
145 | {{trim phrase}}
146 | ```
147 | Output: `Lorem ipsum dolor sit amet, consectetur adipiscing elit.`
148 |
149 | #### `truncate`
150 | Truncates a string with a characterLimit and optionally adds an ellipsis to the end.
151 |
152 | ```hbs
153 | {{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit." 20 true}}
154 | {{truncate phrase characterLimit useEllipsis}}
155 | ```
156 | Output: `Lorem ipsum dolor...`
157 |
158 | **[⬆️ back to top](#available-helpers)**
159 |
160 | #### `underscore`
161 | Underscores a string using `Ember.String.underscore`.
162 |
163 | ```hbs
164 | {{underscore "whatsThat"}}
165 | {{underscore phrase}}
166 | ```
167 | Output: `whats_that`
168 |
169 | **[⬆️ back to top](#available-helpers)**
170 |
171 | #### `uppercase`
172 | Uppercases a string.
173 |
174 | ```hbs
175 | {{uppercase "loud noises"}}
176 | {{uppercase phrase}}
177 | ```
178 | Output: `LOUD NOISES`
179 |
180 | **[⬆️ back to top](#available-helpers)**
181 |
182 | #### `w`
183 | Splits a string on whitespace and/or turns multiple words into an array.
184 |
185 | ```hbs
186 | {{#each (w "First" "Second" "Last") as |rank|}}
187 | Our {{rank}} place winner is ...
188 | {{/each}}
189 | ```
190 |
191 | or:
192 |
193 | ```hbs
194 | {{#each (w "First Second Last") as |rank|}}
195 | Our {{rank}} place winner is ...
196 | {{/each}}
197 | ```
198 |
199 | See also: [Ember `w` documentation](https://api.emberjs.com/ember/release/classes/String/methods/w?anchor=w)
200 |
201 | **[⬆️ back to top](#available-helpers)**
202 |
203 | ## See also:
204 |
205 | * [ember-composable-helpers](https://github.com/dockyard/ember-composable-helpers)
206 | * [ember-truth-helpers](https://github.com/jmurphyau/ember-truth-helpers)
207 |
208 | ## Legal
209 |
210 | [Licensed under the MIT license](http://www.opensource.org/licenses/mit-license.php)
211 |
--------------------------------------------------------------------------------
/addon/-private/create-string-helper.js:
--------------------------------------------------------------------------------
1 | import { isHTMLSafe } from '@ember/template';
2 |
3 | export default function(stringFunction) {
4 | return function([string]) {
5 | if (isHTMLSafe(string)) {
6 | string = string.string;
7 | }
8 |
9 | string = string || '';
10 | return stringFunction(string);
11 | };
12 | }
13 |
--------------------------------------------------------------------------------
/addon/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/addon/.gitkeep
--------------------------------------------------------------------------------
/addon/helpers/camelize.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { camelize as _camelize } from '@ember/string';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const camelize = createStringHelperFunction(_camelize);
6 | export default helper(camelize);
7 |
--------------------------------------------------------------------------------
/addon/helpers/capitalize.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { capitalize as _capitalize } from '@ember/string';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const capitalize = createStringHelperFunction(_capitalize);
6 | export default helper(capitalize);
7 |
--------------------------------------------------------------------------------
/addon/helpers/classify.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { classify as _classify } from '@ember/string';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const classify = createStringHelperFunction(_classify);
6 | export default helper(classify);
7 |
--------------------------------------------------------------------------------
/addon/helpers/dasherize.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { dasherize as _dasherize } from '@ember/string';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const dasherize = createStringHelperFunction(_dasherize);
6 | export default helper(dasherize);
7 |
--------------------------------------------------------------------------------
/addon/helpers/html-safe.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { htmlSafe as _htmlSafe } from '@ember/template';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const htmlSafe = createStringHelperFunction(_htmlSafe);
6 | export default helper(htmlSafe);
7 |
--------------------------------------------------------------------------------
/addon/helpers/humanize.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { isHTMLSafe } from '@ember/template';
3 |
4 | const regex = /_+|-+/g;
5 | const replacement = ' ';
6 |
7 | // The substituted value will be contained in the result variable
8 | export function humanize([string]) {
9 | if (isHTMLSafe(string)) {
10 | string = string.string;
11 | }
12 |
13 | if (string === undefined || string === null) {
14 | return '';
15 | }
16 |
17 | let result = string.toLowerCase().replace(regex, replacement);
18 | return result.charAt(0).toUpperCase() + result.slice(1);
19 | }
20 |
21 | export default helper(humanize);
22 |
--------------------------------------------------------------------------------
/addon/helpers/lowercase.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import lowercaseLib from 'ember-cli-string-helpers/utils/lowercase';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const lowercase = createStringHelperFunction(lowercaseLib);
6 | export default helper(lowercase);
7 |
--------------------------------------------------------------------------------
/addon/helpers/titleize.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import titleizeLib from 'ember-cli-string-helpers/utils/titleize';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const titleize = createStringHelperFunction(titleizeLib);
6 | export default helper(titleize);
7 |
--------------------------------------------------------------------------------
/addon/helpers/trim.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import trimLib from 'ember-cli-string-helpers/utils/trim';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const trim = createStringHelperFunction(trimLib);
6 | export default helper(trim);
7 |
--------------------------------------------------------------------------------
/addon/helpers/truncate.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { isHTMLSafe } from '@ember/template';
3 |
4 | export function truncate([string, characterLimit = 140, useEllipsis = true]) {
5 | let limit = useEllipsis ? characterLimit - 3 : characterLimit;
6 |
7 | if (isHTMLSafe(string)) {
8 | string = string.string;
9 | }
10 |
11 | if (string && string.length > limit) {
12 | return useEllipsis ? `${string.substring(0, limit)}...` : string.substring(0, limit);
13 | } else {
14 | return string;
15 | }
16 | }
17 |
18 | export default helper(truncate);
19 |
--------------------------------------------------------------------------------
/addon/helpers/underscore.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { underscore as _underscore } from '@ember/string';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const underscore = createStringHelperFunction(_underscore);
6 | export default helper(underscore);
7 |
--------------------------------------------------------------------------------
/addon/helpers/uppercase.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import uppercaseLib from 'ember-cli-string-helpers/utils/uppercase';
3 | import createStringHelperFunction from '../-private/create-string-helper';
4 |
5 | export const uppercase = createStringHelperFunction(uppercaseLib);
6 | export default helper(uppercase);
7 |
--------------------------------------------------------------------------------
/addon/helpers/w.js:
--------------------------------------------------------------------------------
1 | import { helper } from '@ember/component/helper';
2 | import { w as toWords } from '@ember/string';
3 |
4 | export function w([...wordStrings]) {
5 | return wordStrings
6 | .map(toWords)
7 | .reduce((words, moreWords) => {
8 | return words.concat(moreWords);
9 | }, []);
10 | }
11 |
12 | export default helper(w);
13 |
--------------------------------------------------------------------------------
/addon/utils/lowercase.js:
--------------------------------------------------------------------------------
1 | export default function lowercase(string = '') {
2 | if (typeof string !== 'string') {
3 | throw new TypeError(`Expected a string, got a ${typeof string}`);
4 | }
5 |
6 | return string.toLowerCase();
7 | }
8 |
--------------------------------------------------------------------------------
/addon/utils/titleize.js:
--------------------------------------------------------------------------------
1 | export default function titleize(string = '') {
2 | if (typeof string !== 'string') {
3 | throw new TypeError(`Expected a string, got a ${typeof string}`);
4 | }
5 |
6 | return string.toLowerCase().replace(/(?:^|\s|-|\/)\S/g, function(m) {
7 | return m.toUpperCase();
8 | });
9 | }
10 |
--------------------------------------------------------------------------------
/addon/utils/trim.js:
--------------------------------------------------------------------------------
1 | export default function trim(string = '') {
2 | if (typeof string !== 'string') {
3 | throw new TypeError(`Expected a string, got a ${typeof string}`);
4 | }
5 |
6 | return string.trim();
7 | }
8 |
--------------------------------------------------------------------------------
/addon/utils/uppercase.js:
--------------------------------------------------------------------------------
1 | export default function uppercase(string = '') {
2 | if (typeof string !== 'string') {
3 | throw new TypeError(`Expected a string, got a ${typeof string}`);
4 | }
5 |
6 | return string.toUpperCase();
7 | }
8 |
--------------------------------------------------------------------------------
/app/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/app/.gitkeep
--------------------------------------------------------------------------------
/app/helpers/camelize.js:
--------------------------------------------------------------------------------
1 | export { default, camelize } from 'ember-cli-string-helpers/helpers/camelize';
2 |
--------------------------------------------------------------------------------
/app/helpers/capitalize.js:
--------------------------------------------------------------------------------
1 | export { default, capitalize } from 'ember-cli-string-helpers/helpers/capitalize';
2 |
--------------------------------------------------------------------------------
/app/helpers/classify.js:
--------------------------------------------------------------------------------
1 | export { default, classify } from 'ember-cli-string-helpers/helpers/classify';
2 |
--------------------------------------------------------------------------------
/app/helpers/dasherize.js:
--------------------------------------------------------------------------------
1 | export { default, dasherize } from 'ember-cli-string-helpers/helpers/dasherize';
2 |
--------------------------------------------------------------------------------
/app/helpers/html-safe.js:
--------------------------------------------------------------------------------
1 | export { default, htmlSafe } from 'ember-cli-string-helpers/helpers/html-safe';
2 |
--------------------------------------------------------------------------------
/app/helpers/humanize.js:
--------------------------------------------------------------------------------
1 | export { default, humanize } from 'ember-cli-string-helpers/helpers/humanize';
2 |
--------------------------------------------------------------------------------
/app/helpers/lowercase.js:
--------------------------------------------------------------------------------
1 | export { default, lowercase } from 'ember-cli-string-helpers/helpers/lowercase';
2 |
--------------------------------------------------------------------------------
/app/helpers/titleize.js:
--------------------------------------------------------------------------------
1 | export { default, titleize } from 'ember-cli-string-helpers/helpers/titleize';
2 |
--------------------------------------------------------------------------------
/app/helpers/trim.js:
--------------------------------------------------------------------------------
1 | export { default, trim } from 'ember-cli-string-helpers/helpers/trim';
2 |
--------------------------------------------------------------------------------
/app/helpers/truncate.js:
--------------------------------------------------------------------------------
1 | export { default, truncate } from 'ember-cli-string-helpers/helpers/truncate';
2 |
--------------------------------------------------------------------------------
/app/helpers/underscore.js:
--------------------------------------------------------------------------------
1 | export { default, underscore } from 'ember-cli-string-helpers/helpers/underscore';
2 |
--------------------------------------------------------------------------------
/app/helpers/uppercase.js:
--------------------------------------------------------------------------------
1 | export { default, uppercase } from 'ember-cli-string-helpers/helpers/uppercase';
2 |
--------------------------------------------------------------------------------
/app/helpers/w.js:
--------------------------------------------------------------------------------
1 | export { default, w } from 'ember-cli-string-helpers/helpers/w';
2 |
--------------------------------------------------------------------------------
/app/utils/titleize.js:
--------------------------------------------------------------------------------
1 | export { default } from 'ember-cli-string-helpers/utils/titleize';
2 |
--------------------------------------------------------------------------------
/config/ember-try.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const getChannelURL = require('ember-source-channel-url');
4 | const { embroiderSafe, embroiderOptimized } = require('@embroider/test-setup');
5 |
6 | module.exports = function() {
7 | return Promise.all([
8 | getChannelURL('release'),
9 | getChannelURL('beta'),
10 | getChannelURL('canary')
11 | ]).then((urls) => {
12 | return {
13 | useYarn: true,
14 | scenarios: [
15 | {
16 | name: 'ember-lts-2.16',
17 | env: {
18 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }),
19 | },
20 | npm: {
21 | devDependencies: {
22 | '@ember/jquery': '^0.5.1',
23 | 'ember-source': '~2.16.0'
24 | }
25 | }
26 | },
27 | {
28 | name: 'ember-lts-2.18',
29 | env: {
30 | EMBER_OPTIONAL_FEATURES: JSON.stringify({ 'jquery-integration': true }),
31 | },
32 | npm: {
33 | devDependencies: {
34 | '@ember/jquery': '^0.5.1',
35 | 'ember-source': '~2.18.0'
36 | }
37 | }
38 | },
39 | {
40 | name: 'ember-release',
41 | npm: {
42 | devDependencies: {
43 | 'ember-source': urls[0]
44 | }
45 | }
46 | },
47 | {
48 | name: 'ember-beta',
49 | npm: {
50 | devDependencies: {
51 | 'ember-source': urls[1]
52 | }
53 | }
54 | },
55 | {
56 | name: 'ember-canary',
57 | npm: {
58 | devDependencies: {
59 | 'ember-source': urls[2]
60 | }
61 | }
62 | },
63 | {
64 | name: 'ember-default',
65 | npm: {
66 | devDependencies: {}
67 | }
68 | },
69 | {
70 | name: 'ember-default-with-jquery',
71 | env: {
72 | EMBER_OPTIONAL_FEATURES: JSON.stringify({
73 | 'jquery-integration': true
74 | })
75 | },
76 | npm: {
77 | devDependencies: {
78 | '@ember/jquery': '^0.5.1'
79 | }
80 | }
81 | },
82 | embroiderSafe(),
83 | embroiderOptimized()
84 | ]
85 | };
86 | });
87 | };
88 |
--------------------------------------------------------------------------------
/config/environment.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function(/* environment, appConfig */) {
4 | return { };
5 | };
6 |
--------------------------------------------------------------------------------
/ember-cli-build.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const EmberAddon = require('ember-cli/lib/broccoli/ember-addon');
4 | const { maybeEmbroider } = require('@embroider/test-setup');
5 |
6 | module.exports = function(defaults) {
7 | let app = new EmberAddon(defaults, {
8 | // Add options here
9 | });
10 |
11 | /*
12 | This build file specifies the options for the dummy test app of this
13 | addon, located in `/tests/dummy`
14 | This build file does *not* influence how the addon or the app using it
15 | behave. You most likely want to be modifying `./index.js` or app's build file
16 | */
17 |
18 | return maybeEmbroider(app);
19 | };
20 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var Funnel = require('broccoli-funnel');
4 | var path = require('path');
5 | var intersection = require('./lib/intersection');
6 | var difference = require('./lib/difference');
7 | var StripBadReexports = require('./lib/strip-bad-reexports');
8 |
9 | module.exports = {
10 | name: require('./package').name,
11 |
12 | included: function(app) {
13 | this._super.included.apply(this, arguments);
14 |
15 | // see: https://github.com/ember-cli/ember-cli/issues/3718
16 | if (typeof app.import !== 'function' && app.app) {
17 | app = app.app;
18 | }
19 |
20 | this.app = app;
21 |
22 | var addonOptions = (this.parent && this.parent.options) || (this.app && this.app.options) || {};
23 | var addonConfig = addonOptions[this.name] || {};
24 |
25 | this.whitelist = this.generateWhitelist(addonConfig);
26 | this.blacklist = this.generateBlacklist(addonConfig);
27 | },
28 |
29 | treeForAddon: function(tree) {
30 | tree = this.filterHelpers(tree, new RegExp(/^helpers\//, 'i'));
31 | tree = new StripBadReexports(tree, [`index.js`]);
32 | return this._super.treeForAddon.call(this, tree);
33 | },
34 |
35 | treeForApp: function(tree) {
36 | tree = this.filterHelpers(tree, new RegExp(/^helpers\//, 'i'));
37 | return this._super.treeForApp.call(this, tree);
38 | },
39 |
40 | filterHelpers: function(tree, regex) {
41 | var whitelist = this.whitelist;
42 | var blacklist = this.blacklist;
43 | var _this = this;
44 |
45 | // exit early if no opts defined
46 | if ((!whitelist || whitelist.length === 0) && (!blacklist || blacklist.length === 0)) {
47 | return tree;
48 | }
49 |
50 | return new Funnel(tree, {
51 | exclude: [function(name) {
52 | return _this.exclusionFilter(name, regex, {
53 | whitelist: whitelist,
54 | blacklist: blacklist
55 | });
56 | }]
57 | });
58 | },
59 |
60 | exclusionFilter: function(name, regex, lists) {
61 | var whitelist = lists.whitelist || [];
62 | var blacklist = lists.blacklist || [];
63 | var isAddonHelper = regex.test(name);
64 | var helperName = path.basename(name, '.js');
65 | var isWhitelisted = whitelist.indexOf(helperName) !== -1;
66 | var isBlacklisted = blacklist.indexOf(helperName) !== -1;
67 |
68 | // non-helper, don't exclude
69 | if (!isAddonHelper) {
70 | return false;
71 | }
72 |
73 | // don't exclude if both lists are empty
74 | if (whitelist.length === 0 && blacklist.length === 0) {
75 | return false;
76 | }
77 |
78 | // don't exclude if both whitelisted and blacklisted
79 | if (isWhitelisted && isBlacklisted) {
80 | return false;
81 | }
82 |
83 | // only whitelist defined
84 | if (whitelist.length && blacklist.length === 0) {
85 | return !isWhitelisted;
86 | }
87 |
88 | // only blacklist defined
89 | if (blacklist.length && whitelist.length === 0) {
90 | return isBlacklisted;
91 | }
92 |
93 | return !isWhitelisted || isBlacklisted;
94 | },
95 |
96 | generateWhitelist: function(addonConfig) {
97 | var only = addonConfig.only || [];
98 | var except = addonConfig.except || [];
99 |
100 | if (except && except.length) {
101 | return difference(only, except);
102 | }
103 |
104 | return only;
105 | },
106 |
107 | generateBlacklist: function(addonConfig) {
108 | var only = addonConfig.only || [];
109 | var except = addonConfig.except || [];
110 |
111 | if (only && only.length) {
112 | return intersection(except, only);
113 | }
114 |
115 | return except;
116 | }
117 | };
118 |
--------------------------------------------------------------------------------
/lib/difference.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | 'use strict';
3 |
4 | /**
5 | * Finds the difference between 2 arrays.
6 | *
7 | * let a = [1, 2, 3];
8 | * let b = [3, 4, 5];
9 | * difference(a, b) === [1, 2];
10 | * difference(b, a) === [4, 5];
11 | *
12 | * @public
13 | * @param {Array} a
14 | * @param {Array} b
15 | * @return {Array} diff
16 | */
17 | module.exports = function difference(a, b) {
18 | let seen = [];
19 | let diff = [];
20 |
21 | for (let i = 0; i < b.length; i++) {
22 | seen[b[i]] = true;
23 | }
24 |
25 | for (let j = 0; j < a.length; j++) {
26 | if (!seen[a[j]]) {
27 | diff.push(a[j]);
28 | }
29 | }
30 |
31 | return diff;
32 | };
33 |
--------------------------------------------------------------------------------
/lib/intersection.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | 'use strict';
3 |
4 | /**
5 | * Finds the intersection between 2 arrays.
6 | *
7 | * let a = [1, 2, 3];
8 | * let b = [3, 4, 5];
9 | * intersection(a, b) === [3];
10 | * intersection(b, a) === [3];
11 | *
12 | * @public
13 | * @param {Array} a
14 | * @param {Array} b
15 | * @return {Array}
16 | */
17 | module.exports = function intersection(a, b) {
18 | let arrays = [a, b];
19 |
20 | return arrays.pop().filter(function(candidate) {
21 | for (let i = 0; i < arrays.length; i++) {
22 | let found = false;
23 | let array = arrays[i];
24 | for (let j = 0; j < array.length; j++) {
25 | if (array[j] === candidate) {
26 | found = true;
27 | break;
28 | }
29 | }
30 |
31 | if (found === false) {
32 | return false;
33 | }
34 | }
35 |
36 | return true;
37 | });
38 | };
39 |
--------------------------------------------------------------------------------
/lib/strip-bad-reexports.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | const resolve = require('resolve');
3 | const { transform } = require('@babel/core');
4 | const Funnel = require('broccoli-funnel');
5 | const { writeFileSync, readFileSync, existsSync, unlinkSync } = require('fs');
6 | const { join } = require('path');
7 |
8 |
9 | module.exports = class StripBadReexports extends Funnel {
10 | constructor(tree, files) {
11 | super(tree);
12 | this.filesToStrip = files;
13 | }
14 | build() {
15 | super.build();
16 | for (let file of this.filesToStrip) {
17 | let srcFile = join(this.inputPaths[0], file);
18 | if (!existsSync(srcFile)) {
19 | continue;
20 | }
21 | let src = readFileSync(srcFile, 'utf8');
22 | let plugins = [[stripBadReexportsTransform, { resolveBase: this.outputPath }]];
23 | let destFile = join(this.outputPath, file);
24 | unlinkSync(destFile);
25 | writeFileSync(destFile, transform(src, { plugins }).code);
26 | }
27 | }
28 | shouldLinkRoots() {
29 | // We want to force funnel to copy things rather than just linking the whole
30 | // directory, because we're planning to mutate it.
31 | return false;
32 | }
33 | }
34 |
35 | function stripBadReexportsTransform() {
36 | return {
37 | visitor: {
38 | ExportNamedDeclaration(path, state) {
39 | if (
40 | path.node.source &&
41 | path.node.source.type === 'StringLiteral'
42 | ) {
43 | try {
44 | resolve.sync(path.node.source.value, { basedir: state.opts.resolveBase });
45 | } catch (err) {
46 | path.remove();
47 | }
48 | }
49 | },
50 | },
51 | };
52 | }
53 |
54 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ember-cli-string-helpers",
3 | "version": "6.1.0",
4 | "description": "String helpers for Ember",
5 | "scripts": {
6 | "build": "ember build",
7 | "lint:hbs": "ember-template-lint .",
8 | "lint:js": "eslint .",
9 | "start": "ember serve",
10 | "test": "ember test",
11 | "node-test": "mocha test --recursive --reporter spec",
12 | "test:all": "ember try:each"
13 | },
14 | "bugs": "https://github.com/adopted-ember-addons/ember-cli-string-helpers/issues",
15 | "homepage": "https://github.com/adopted-ember-addons/ember-cli-string-helpers",
16 | "devDependencies": {
17 | "@ember/optional-features": "^2.0.0",
18 | "@embroider/test-setup": "^0.37.0",
19 | "broccoli-asset-rev": "^3.0.0",
20 | "chai": "^4.2.0",
21 | "ember-ajax": "^5.0.0",
22 | "ember-cli": "~3.21.2",
23 | "ember-cli-dependency-checker": "^3.0.0",
24 | "ember-cli-eslint": "^5.1.0",
25 | "ember-cli-htmlbars": "^5.1.2",
26 | "ember-cli-htmlbars-inline-precompile": "^3.0.0",
27 | "ember-cli-inject-live-reload": "^2.0.1",
28 | "ember-cli-sri": "^2.1.1",
29 | "ember-cli-template-lint": "^1.0.0-beta.1",
30 | "ember-cli-uglify": "^3.0.0",
31 | "ember-cli-update": "^0.54.6",
32 | "ember-disable-prototype-extensions": "^1.1.3",
33 | "ember-exam": "^5.0.1",
34 | "ember-export-application-global": "^2.0.0",
35 | "ember-load-initializers": "^2.0.0",
36 | "ember-maybe-import-regenerator": "^0.1.6",
37 | "ember-qunit": "^4.4.1",
38 | "ember-resolver": "^8.0.0",
39 | "ember-source": "~3.22.0",
40 | "ember-source-channel-url": "^3.0.0",
41 | "ember-try": "^1.0.0",
42 | "eslint-plugin-ember": "^8.7.0",
43 | "eslint-plugin-ember-suave": "^2.0.0",
44 | "eslint-plugin-node": "^11.0.0",
45 | "loader.js": "^4.7.0",
46 | "mocha": "^8.0.1",
47 | "qunit-dom": "^1.2.0"
48 | },
49 | "keywords": [
50 | "ember-addon",
51 | "helpers"
52 | ],
53 | "repository": "https://github.com/adopted-ember-addons/ember-cli-string-helpers",
54 | "license": "MIT",
55 | "author": [
56 | "Lauren Tan ",
57 | "Marten Schilstra ",
58 | "Rômulo Machado "
59 | ],
60 | "directories": {
61 | "doc": "doc",
62 | "test": "tests"
63 | },
64 | "dependencies": {
65 | "@babel/core": "^7.13.10",
66 | "broccoli-funnel": "^3.0.3",
67 | "ember-cli-babel": "^7.7.3",
68 | "resolve": "^1.20.0"
69 | },
70 | "engines": {
71 | "node": "10.* || >=12.*"
72 | },
73 | "ember-addon": {
74 | "configPath": "tests/dummy/config"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/test/index-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | 'use strict';
3 |
4 | let emberStringHelpersIndex = require('../index');
5 | let { describe, it } = require('mocha');
6 | let { expect } = require('chai');
7 |
8 | describe('index', function() {
9 | describe('#exclusionFilter', function() {
10 | it('should return `true` if a file is in the blacklist', function() {
11 | let name = 'camelize';
12 | let dummyRegex = new RegExp('.*');
13 | let lists = {
14 | blacklist: ['camelize', 'capitalize']
15 | };
16 | let result = emberStringHelpersIndex.exclusionFilter(name, dummyRegex, lists);
17 |
18 | expect(result).to.be.true;
19 | });
20 |
21 | it('should return `false` if a file is not in the blacklist', function() {
22 | let name = 'classify';
23 | let dummyRegex = new RegExp('.*');
24 | let lists = {
25 | blacklist: ['dasherize', 'html-safe']
26 | };
27 | let result = emberStringHelpersIndex.exclusionFilter(name, dummyRegex, lists);
28 |
29 | expect(result).to.be.false;
30 | });
31 |
32 | it('should return `false` if a file is in the whitelist', function() {
33 | let name = 'titleize';
34 | let dummyRegex = new RegExp('.*');
35 | let lists = {
36 | whitelist: ['titleize', 'truncate']
37 | };
38 | let result = emberStringHelpersIndex.exclusionFilter(name, dummyRegex, lists);
39 |
40 | expect(result).to.be.false;
41 | });
42 |
43 | it('should return `false` if a file is in both the whitelist and blacklist', function() {
44 | let name = 'w';
45 | let dummyRegex = new RegExp('.*');
46 | let lists = {
47 | blacklist: ['w'],
48 | whitelist: ['w', 'camelize']
49 | };
50 | let result = emberStringHelpersIndex.exclusionFilter(name, dummyRegex, lists);
51 |
52 | expect(result).to.be.false;
53 | });
54 |
55 | it('should return `false` if both lists are empty', function() {
56 | let name = 'camelize';
57 | let dummyRegex = new RegExp('.*');
58 | let lists = {};
59 | let result = emberStringHelpersIndex.exclusionFilter(name, dummyRegex, lists);
60 |
61 | expect(result).to.be.false;
62 | });
63 | });
64 |
65 | describe('#generateWhitelist', function() {
66 | it('should return files to whitelist when both `only` and `expect` are defined' , function() {
67 | let dummyConfig = {
68 | only: ['capitalize', 'classify', 'dasherize', 'html-safe'],
69 | except: ['titleize']
70 | };
71 | let expectedResult = ['capitalize', 'classify', 'dasherize', 'html-safe'];
72 | let result = emberStringHelpersIndex.generateWhitelist(dummyConfig);
73 |
74 | expect(result).to.eql(expectedResult);
75 | });
76 |
77 | it('should return files to whitelist when `only` is defined' , function() {
78 | let dummyConfig = {
79 | only: ['camelize', 'capitalize', 'classify', 'dasherize']
80 | };
81 | let expectedResult = ['camelize', 'capitalize', 'classify', 'dasherize'];
82 | let result = emberStringHelpersIndex.generateWhitelist(dummyConfig);
83 |
84 | expect(result).to.eql(expectedResult);
85 | });
86 | });
87 |
88 | describe('#generateBlacklist', function() {
89 | it('should return files to blacklist when both `only` and `expect` are defined' , function() {
90 | let dummyConfig = {
91 | only: ['html-safe', 'titleize', 'truncate', 'underscore'],
92 | except: ['truncate']
93 | };
94 | let expectedResult = ['truncate'];
95 | let result = emberStringHelpersIndex.generateBlacklist(dummyConfig);
96 |
97 | expect(result).to.eql(expectedResult);
98 | });
99 |
100 | it('should return files to blacklist when `except` is defined' , function() {
101 | let dummyConfig = {
102 | except: ['camelize', 'capitalize', 'classify', 'dasherize']
103 | };
104 | let expectedResult = ['camelize', 'capitalize', 'classify', 'dasherize'];
105 | let result = emberStringHelpersIndex.generateBlacklist(dummyConfig);
106 |
107 | expect(result).to.eql(expectedResult);
108 | });
109 | });
110 | });
111 |
--------------------------------------------------------------------------------
/test/lib/difference-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | 'use strict';
3 |
4 | let difference = require('../../lib/difference');
5 | let { describe, it } = require('mocha');
6 | let { expect } = require('chai');
7 |
8 | describe('difference', function() {
9 | it('finds the difference between 2 arrays', function() {
10 | let a = ['foo', 'bar', 'baz'];
11 | let b = ['bar', 'baz', 'qux'];
12 | let expectedResult = ['foo'];
13 | let result = difference(a, b);
14 |
15 | expect(result).to.eql(expectedResult);
16 | });
17 |
18 | it('finds the difference between 2 arrays', function() {
19 | let a = ['foo', 'bar', 'baz'];
20 | let b = ['bar', 'baz', 'qux'];
21 | let expectedResult = ['qux'];
22 | let result = difference(b, a);
23 |
24 | expect(result).to.eql(expectedResult);
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/test/lib/intersection-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env node */
2 | 'use strict';
3 |
4 | let intersection = require('../../lib/intersection');
5 | let { describe, it } = require('mocha');
6 | let { expect } = require('chai');
7 |
8 | describe('intersection', function() {
9 | it('finds the intersection between 2 arrays', function() {
10 | let a = ['foo', 'bar', 'baz'];
11 | let b = ['bar', 'baz', 'qux'];
12 | let expectedResult = ['bar', 'baz'];
13 | let result = intersection(a, b);
14 |
15 | expect(result).to.eql(expectedResult);
16 | });
17 |
18 | it('finds the intersection between 2 arrays', function() {
19 | let a = ['foo', 'bar', 'baz'];
20 | let b = ['bar', 'baz', 'qux'];
21 | let expectedResult = ['bar', 'baz'];
22 | let result = intersection(b, a);
23 |
24 | expect(result).to.eql(expectedResult);
25 | });
26 | });
27 |
--------------------------------------------------------------------------------
/testem.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | test_page: 'tests/index.html?hidepassed',
3 | disable_watching: true,
4 | launch_in_ci: [
5 | 'Chrome'
6 | ],
7 | launch_in_dev: [
8 | 'Chrome'
9 | ],
10 | browser_args: {
11 | Chrome: {
12 | ci: [
13 | // --no-sandbox is needed when running Chrome inside a container
14 | process.env.CI ? '--no-sandbox' : null,
15 | '--headless',
16 | '--disable-gpu',
17 | '--disable-dev-shm-usage',
18 | '--disable-software-rasterizer',
19 | '--mute-audio',
20 | '--remote-debugging-port=0',
21 | '--window-size=1440,900'
22 | ].filter(Boolean)
23 | }
24 | }
25 | };
26 |
--------------------------------------------------------------------------------
/tests/dummy/app/app.js:
--------------------------------------------------------------------------------
1 | import Application from '@ember/application';
2 | import Resolver from './resolver';
3 | import loadInitializers from 'ember-load-initializers';
4 | import config from './config/environment';
5 |
6 | const App = Application.extend({
7 | modulePrefix: config.modulePrefix,
8 | podModulePrefix: config.podModulePrefix,
9 | Resolver
10 | });
11 |
12 | loadInitializers(App, config.modulePrefix);
13 |
14 | export default App;
15 |
--------------------------------------------------------------------------------
/tests/dummy/app/components/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/dummy/app/components/.gitkeep
--------------------------------------------------------------------------------
/tests/dummy/app/controllers/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/dummy/app/controllers/.gitkeep
--------------------------------------------------------------------------------
/tests/dummy/app/helpers/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/dummy/app/helpers/.gitkeep
--------------------------------------------------------------------------------
/tests/dummy/app/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Dummy
7 |
8 |
9 |
10 | {{content-for "head"}}
11 |
12 |
13 |
14 |
15 | {{content-for "head-footer"}}
16 |
17 |
18 | {{content-for "body"}}
19 |
20 |
21 |
22 |
23 | {{content-for "body-footer"}}
24 |
25 |
26 |
--------------------------------------------------------------------------------
/tests/dummy/app/models/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/dummy/app/models/.gitkeep
--------------------------------------------------------------------------------
/tests/dummy/app/resolver.js:
--------------------------------------------------------------------------------
1 | import Resolver from 'ember-resolver';
2 |
3 | export default Resolver;
4 |
--------------------------------------------------------------------------------
/tests/dummy/app/router.js:
--------------------------------------------------------------------------------
1 | import EmberRouter from '@ember/routing/router';
2 | import config from './config/environment';
3 |
4 | const Router = EmberRouter.extend({
5 | location: config.locationType,
6 | rootURL: config.rootURL
7 | });
8 |
9 | Router.map(function() {
10 | });
11 |
12 | export default Router;
13 |
--------------------------------------------------------------------------------
/tests/dummy/app/routes/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/dummy/app/routes/.gitkeep
--------------------------------------------------------------------------------
/tests/dummy/app/styles/app.css:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/dummy/app/styles/app.css
--------------------------------------------------------------------------------
/tests/dummy/app/templates/application.hbs:
--------------------------------------------------------------------------------
1 | {{!-- The following component displays Ember's default welcome message. --}}
2 | {{welcome-page}}
3 | {{!-- Feel free to remove this! --}}
4 |
5 | {{outlet}}
--------------------------------------------------------------------------------
/tests/dummy/app/templates/components/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/dummy/app/templates/components/.gitkeep
--------------------------------------------------------------------------------
/tests/dummy/app/templates/components/perform-calculation.hbs:
--------------------------------------------------------------------------------
1 |
2 | Calculate
3 |
--------------------------------------------------------------------------------
/tests/dummy/app/templates/components/toggle-button.hbs:
--------------------------------------------------------------------------------
1 |
2 | Toggle
3 |
--------------------------------------------------------------------------------
/tests/dummy/config/environment.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | module.exports = function(environment) {
4 | let ENV = {
5 | modulePrefix: 'dummy',
6 | environment,
7 | rootURL: '/',
8 | locationType: 'auto',
9 | EmberENV: {
10 | FEATURES: {
11 | // Here you can enable experimental features on an ember canary build
12 | // e.g. 'with-controller': true
13 | },
14 | EXTEND_PROTOTYPES: {
15 | // Prevent Ember Data from overriding Date.parse.
16 | Date: false
17 | }
18 | },
19 |
20 | APP: {
21 | // Here you can pass flags/options to your application instance
22 | // when it is created
23 | }
24 | };
25 |
26 | if (environment === 'development') {
27 | // ENV.APP.LOG_RESOLVER = true;
28 | // ENV.APP.LOG_ACTIVE_GENERATION = true;
29 | // ENV.APP.LOG_TRANSITIONS = true;
30 | // ENV.APP.LOG_TRANSITIONS_INTERNAL = true;
31 | // ENV.APP.LOG_VIEW_LOOKUPS = true;
32 | }
33 |
34 | if (environment === 'test') {
35 | // Testem prefers this...
36 | ENV.locationType = 'none';
37 |
38 | // keep test console output quieter
39 | ENV.APP.LOG_ACTIVE_GENERATION = false;
40 | ENV.APP.LOG_VIEW_LOOKUPS = false;
41 |
42 | ENV.APP.rootElement = '#ember-testing';
43 | ENV.APP.autoboot = false;
44 | }
45 |
46 | if (environment === 'production') {
47 | // here you can enable a production-specific feature
48 | }
49 |
50 | return ENV;
51 | };
52 |
--------------------------------------------------------------------------------
/tests/dummy/config/optional-features.json:
--------------------------------------------------------------------------------
1 | {
2 | "jquery-integration": false
3 | }
4 |
--------------------------------------------------------------------------------
/tests/dummy/config/targets.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const browsers = [
4 | 'last 1 Chrome versions',
5 | 'last 1 Firefox versions',
6 | 'last 1 Safari versions'
7 | ];
8 |
9 | const isCI = !!process.env.CI;
10 | const isProduction = process.env.EMBER_ENV === 'production';
11 |
12 | if (isCI || isProduction) {
13 | browsers.push('ie 11');
14 | }
15 |
16 | module.exports = {
17 | browsers
18 | };
19 |
--------------------------------------------------------------------------------
/tests/dummy/public/robots.txt:
--------------------------------------------------------------------------------
1 | # http://www.robotstxt.org
2 | User-agent: *
3 | Disallow:
4 |
--------------------------------------------------------------------------------
/tests/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Dummy Tests
7 |
8 |
9 |
10 | {{content-for "head"}}
11 | {{content-for "test-head"}}
12 |
13 |
14 |
15 |
16 |
17 | {{content-for "head-footer"}}
18 | {{content-for "test-head-footer"}}
19 |
20 |
21 | {{content-for "body"}}
22 | {{content-for "test-body"}}
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 | {{content-for "body-footer"}}
31 | {{content-for "test-body-footer"}}
32 |
33 |
34 |
--------------------------------------------------------------------------------
/tests/integration/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/integration/.gitkeep
--------------------------------------------------------------------------------
/tests/integration/helpers/camelize-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{camelize}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It maintains camelCase correctly', async function(assert) {
11 | await render(hbs`{{camelize "andAnother"}}`);
12 |
13 | let expected = 'andAnother';
14 |
15 | assert.dom('*').hasText(expected, 'maintains camelCase');
16 | });
17 |
18 | test('It converts underscores to camelCase', async function(assert) {
19 | await render(hbs`{{camelize "harry_potter"}}`);
20 |
21 | let expected = 'harryPotter';
22 |
23 | assert.dom('*').hasText(expected, 'converts underscores to camelCase');
24 | });
25 |
26 | test('It converts dashes to camelCase', async function(assert) {
27 | await render(hbs`{{camelize "harry-potter"}}`);
28 |
29 | let expected = 'harryPotter';
30 |
31 | assert.dom('*').hasText(expected, 'converts dashes to camelCase');
32 | });
33 |
34 | test('It converts spaces to camelCase', async function(assert) {
35 | await render(hbs`{{camelize "age is foolish and forgetful when it underestimates youth"}}`);
36 |
37 | let expected = 'ageIsFoolishAndForgetfulWhenItUnderestimatesYouth';
38 |
39 | assert.dom('*').hasText(expected, 'correctly camelizes input with spaces');
40 | });
41 |
42 | test('It correctly handles empty string input', async function(assert) {
43 | await render(hbs`{{camelize ""}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
48 | });
49 |
50 | test('It correctly handles undefined input', async function(assert) {
51 | await render(hbs`{{camelize undefined}}`);
52 |
53 | let expected = '';
54 |
55 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
56 | });
57 |
58 | test('It handles a SafeString', async function(assert) {
59 | this.set('wizard', htmlSafe('harry-potter'));
60 |
61 | await render(hbs`{{camelize this.wizard}}`);
62 |
63 | let expected = 'harryPotter';
64 |
65 | assert.dom('*').hasText(expected, 'correctly camelizes a SafeString');
66 | });
67 | });
68 |
--------------------------------------------------------------------------------
/tests/integration/helpers/capitalize-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{capitalize}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It capitalizes a single string', async function(assert) {
11 | await render(hbs`{{capitalize "hi"}}`);
12 |
13 | let expected = 'Hi';
14 |
15 | assert.dom('*').hasText(expected, 'capitalizes a single string');
16 | });
17 |
18 | test('It leaves the capitalization unchanged with correctly capitalized string', async function(assert) {
19 | await render(hbs`{{capitalize "Harry"}}`);
20 |
21 | let expected = 'Harry';
22 |
23 | assert.dom('*').hasText(expected, 'leaves capitalization when string is already capitalized');
24 | });
25 |
26 | test('It correctly capitalizes an uncapitalized sentence', async function(assert) {
27 | await render(hbs`{{capitalize "age is foolish and forgetful when it underestimates youth"}}`);
28 |
29 | let expected = 'Age is foolish and forgetful when it underestimates youth';
30 |
31 | assert.dom('*').hasText(expected, 'correctly capitalizes an uncapitalized sentence');
32 | });
33 |
34 | test('It correctly handles empty string input', async function(assert) {
35 | await render(hbs`{{capitalize ""}}`);
36 |
37 | let expected = '';
38 |
39 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
40 | });
41 |
42 | test('It correctly handles undefined input', async function(assert) {
43 | await render(hbs`{{capitalize undefined}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
48 | });
49 |
50 | test('It handles a SafeString', async function(assert) {
51 | this.set('greeting', htmlSafe('hi'));
52 |
53 | await render(hbs`{{capitalize this.greeting}}`);
54 |
55 | let expected = 'Hi';
56 |
57 | assert.dom('*').hasText(expected, 'correctly capitalizes a SafeString');
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/tests/integration/helpers/classify-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{classify}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It converts camelCase correctly', async function(assert) {
11 | await render(hbs`{{classify "andAnother"}}`);
12 |
13 | let expected = 'AndAnother';
14 |
15 | assert.dom('*').hasText(expected, 'classifies camelCased strings');
16 | });
17 |
18 | test('It converts underscored strings correctly', async function(assert) {
19 | await render(hbs`{{classify "harry_potter"}}`);
20 |
21 | let expected = 'HarryPotter';
22 |
23 | assert.dom('*').hasText(expected, 'classifies underscored strings');
24 | });
25 |
26 | test('It converts spaces in strings correctly', async function(assert) {
27 | await render(hbs`{{classify "age is foolish and forgetful when it underestimates youth"}}`);
28 |
29 | let expected = 'AgeIsFoolishAndForgetfulWhenItUnderestimatesYouth';
30 |
31 | assert.dom('*').hasText(expected, 'classifies strings with spaces');
32 | });
33 |
34 | test('It correctly handles empty string input', async function(assert) {
35 | await render(hbs`{{classify ""}}`);
36 |
37 | let expected = '';
38 |
39 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
40 | });
41 |
42 | test('It correctly handles undefined input', async function(assert) {
43 | await render(hbs`{{classify undefined}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
48 | });
49 |
50 | test('It handles a SafeString', async function(assert) {
51 | this.set('wizard', htmlSafe('harry_potter'));
52 |
53 | await render(hbs`{{classify this.wizard}}`);
54 |
55 | let expected = 'HarryPotter';
56 |
57 | assert.dom('*').hasText(expected, 'correctly classifies a SafeString');
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/tests/integration/helpers/dasherize-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{dasherize}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It converts camelCase correctly', async function(assert) {
11 | await render(hbs`{{dasherize "andAnother"}}`);
12 |
13 | let expected = 'and-another';
14 |
15 | assert.dom('*').hasText(expected, 'converts camelCase to dasherized');
16 | });
17 |
18 | test('It converts underscores to dashes', async function(assert) {
19 | await render(hbs`{{dasherize "harry_potter"}}`);
20 |
21 | let expected = 'harry-potter';
22 |
23 | assert.dom('*').hasText(expected, 'converts underscores to dashes');
24 | });
25 |
26 | test('It converts spaces to dashes', async function(assert) {
27 | await render(hbs`{{dasherize "age is foolish and forgetful when it underestimates youth"}}`);
28 |
29 | let expected = 'age-is-foolish-and-forgetful-when-it-underestimates-youth';
30 |
31 | assert.dom('*').hasText(expected, 'correctly dasherizes input with spaces');
32 | });
33 |
34 | test('It correctly handles empty string input', async function(assert) {
35 | await render(hbs`{{dasherize ""}}`);
36 |
37 | let expected = '';
38 |
39 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
40 | });
41 |
42 | test('It correctly handles undefined input', async function(assert) {
43 | await render(hbs`{{dasherize undefined}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
48 | });
49 |
50 | test('It handles a SafeString', async function(assert) {
51 | this.set('wizard', htmlSafe('harry_potter'));
52 |
53 | await render(hbs`{{dasherize this.wizard}}`);
54 |
55 | let expected = 'harry-potter';
56 |
57 | assert.dom('*').hasText(expected, 'correctly dasherizes a SafeString');
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/tests/integration/helpers/html-safe-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render, find } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 |
6 | module('Integration | Helper | {{html-safe}}', function(hooks) {
7 | setupRenderingTest(hooks);
8 |
9 | test('It html-safes the html string', async function(assert) {
10 | await render(hbs`{{html-safe 'Hello World '}}`);
11 |
12 | assert.dom('h1').hasText('Hello World', 'html string is correctly rendered');
13 | });
14 |
15 | test('It safely renders CSS classes from a property', async function(assert) {
16 | this.set('classes', 'error has-error');
17 | await render(hbs`Hello World `);
18 |
19 | assert.dom('h1').hasText('Hello World', 'it renders');
20 | assert.deepEqual(find('h1').getAttribute('class').split(' ').sort(), ['error', 'has-error'].sort(), 'it has the correct CSS classes');
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/tests/integration/helpers/humanize-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{humanize}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It converts underscores to spaces and capitalizes the first word', async function(assert) {
11 | await render(hbs `{{humanize "item_color"}}`);
12 |
13 | let expected = 'Item color';
14 |
15 | assert.dom('*').hasText(expected, 'converts underscored to humanized');
16 | });
17 |
18 | test('It converts dashes to spaces and capitalizes the first word', async function(assert) {
19 | await render(hbs `{{humanize "item-color-options"}}`);
20 |
21 | let expected = 'Item color options';
22 |
23 | assert.dom('*').hasText(expected, 'converts underscored to humanized');
24 | });
25 |
26 | test('It correctly handles single string input', async function(assert) {
27 | await render(hbs `{{humanize "a"}}`);
28 |
29 | let expected = 'A';
30 |
31 | assert.dom('*').hasText(expected, 'converts underscored to humanized');
32 | });
33 |
34 | test('It correctly handles empty string input', async function(assert) {
35 | await render(hbs `{{humanize ""}}`);
36 |
37 | let expected = '';
38 |
39 | assert.dom('*').hasText(expected, 'converts underscored to humanized');
40 | });
41 |
42 | test('It correctly handles undefined input', async function(assert) {
43 | await render(hbs `{{humanize undefined}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'converts underscored to humanized');
48 | });
49 |
50 | test('It correctly handles capitalised input with spaces', async function(assert) {
51 | await render(hbs `{{humanize "CHOOSE AN ITEM COLOR"}}`);
52 |
53 | let expected = 'Choose an item color';
54 |
55 | assert.dom('*').hasText(expected, 'converts capitals to humanized');
56 | });
57 |
58 | test('It correctly handles capitalised input with underscores', async function(assert) {
59 | await render(hbs `{{humanize "CHOOSE_AN_ITEM_COLOR"}}`);
60 |
61 | let expected = 'Choose an item color';
62 |
63 | assert.dom('*').hasText(expected, 'converts capitals to humanized');
64 | });
65 |
66 | test('It correctly handles capitalised input with dashes', async function(assert) {
67 | await render(hbs `{{humanize "CHOOSE-AN-ITEM-COLOR"}}`);
68 |
69 | let expected = 'Choose an item color';
70 |
71 | assert.dom('*').hasText(expected, 'converts capitals to humanized');
72 | });
73 |
74 | test('It correctly handles mixed-case input with spaces', async function(assert) {
75 | await render(hbs `{{humanize "cHoOsE aN iTeM cOlOr"}}`);
76 |
77 | let expected = 'Choose an item color';
78 |
79 | assert.dom('*').hasText(expected, 'converts capitals to humanized');
80 | });
81 |
82 | test('It correctly handles mixed-case input with underscores', async function(assert) {
83 | await render(hbs `{{humanize "cHoOsE_aN_iTeM_cOlOr"}}`);
84 |
85 | let expected = 'Choose an item color';
86 |
87 | assert.dom('*').hasText(expected, 'converts capitals to humanized');
88 | });
89 |
90 | test('It correctly handles mixed-case input with dashes', async function(assert) {
91 | await render(hbs `{{humanize "cHoOsE-aN-iTeM-cOlOr"}}`);
92 |
93 | let expected = 'Choose an item color';
94 |
95 | assert.dom('*').hasText(expected, 'converts capitals to humanized');
96 | });
97 |
98 | test('It handles a SafeString', async function(assert) {
99 | this.set('sentence', htmlSafe('cHoOsE aN iTeM cOlOr'));
100 |
101 | await render(hbs `{{humanize this.sentence}}`);
102 |
103 | let expected = 'Choose an item color';
104 |
105 | assert.dom('*').hasText(expected, 'converts SafeString capitals to humanized');
106 | });
107 | });
108 |
--------------------------------------------------------------------------------
/tests/integration/helpers/lowercase-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{lowercase}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It converts all uppercase to lowercase', async function(assert) {
11 | await render(hbs`{{lowercase "ALL UPPERCASE"}}`);
12 |
13 | let expected = 'all uppercase';
14 |
15 | assert.dom('*').hasText(expected, 'converts all uppercase to lowercase');
16 | });
17 |
18 | test('It converts mixed case to lowercase', async function(assert) {
19 | await render(hbs`{{lowercase "UPPER and lower CaSe"}}`);
20 |
21 | let expected = 'upper and lower case';
22 |
23 | assert.dom('*').hasText(expected, 'converts upper and lower case to lowercase');
24 | });
25 |
26 | test('It leaves special characters unmodified', async function(assert) {
27 | await render(hbs`{{lowercase "SPECIAL @&\/*-+^\`"}}`);
28 |
29 | let expected = 'special @&/*-+^`';
30 |
31 | assert.dom('*').hasText(expected, 'converts special characters');
32 | });
33 |
34 | test('It converts accented characters to lowercase', async function(assert) {
35 | await render(hbs`{{lowercase "ÂÊÎÔÛÄËÏÖÜÉÀÈ"}}`);
36 |
37 | let expected = 'âêîôûäëïöüéàè';
38 |
39 | assert.dom('*').hasText(expected, 'converts accented characters to lowercase');
40 | });
41 |
42 | test('It correctly handles empty string input', async function(assert) {
43 | await render(hbs`{{lowercase ""}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
48 | });
49 |
50 | test('It correctly handles undefined input', async function(assert) {
51 | await render(hbs`{{lowercase undefined}}`);
52 |
53 | let expected = '';
54 |
55 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
56 | });
57 |
58 | test('It handles a SafeString', async function(assert) {
59 | this.set('scream', htmlSafe('NOOOOOOOO'));
60 |
61 | await render(hbs`{{lowercase this.scream}}`);
62 |
63 | let expected = 'noooooooo';
64 |
65 | assert.dom('*').hasText(expected, 'converts all uppercase SafeString to lowercase');
66 | });
67 | });
68 |
--------------------------------------------------------------------------------
/tests/integration/helpers/titleize-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{titleize}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It titleizes a string', async function(assert) {
11 | await render(hbs`
12 | {{titleize 'my big fat greek wedding'}}
13 | `);
14 |
15 | let expected = 'My Big Fat Greek Wedding';
16 |
17 | assert.dom('*').hasText(expected, 'titleized value');
18 | });
19 |
20 | test('It handles undefined', async function(assert) {
21 | await render(hbs`
22 | {{titleize this.nostring}}
23 | `);
24 |
25 | assert.dom('*').hasText('', 'No value');
26 | });
27 |
28 | test('It handles null', async function(assert) {
29 | this.set('value', null);
30 | await render(hbs`{{titleize this.value}}`);
31 |
32 | assert.dom('*').hasText('', 'No value');
33 | });
34 |
35 | test('It handles a SafeString', async function(assert) {
36 | this.set('title', htmlSafe('my big fat greek wedding'));
37 |
38 | await render(hbs`{{titleize this.title}}`);
39 |
40 | let expected = 'My Big Fat Greek Wedding';
41 |
42 | assert.dom('*').hasText(expected, 'correctly titleizes a SafeString');
43 | });
44 | });
45 |
--------------------------------------------------------------------------------
/tests/integration/helpers/trim-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{trim}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It trim correctly', async function(assert) {
11 | await render(hbs`{{trim " aa "}}`);
12 |
13 | let expected = 'aa';
14 |
15 | assert.dom('*').hasText(expected, 'trim string as expected');
16 | });
17 |
18 | test('It correctly handles empty string input', async function(assert) {
19 | await render(hbs`{{trim ""}}`);
20 |
21 | let expected = '';
22 |
23 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
24 | });
25 |
26 | test('It correctly handles undefined input', async function(assert) {
27 | await render(hbs`{{trim undefined}}`);
28 |
29 | let expected = '';
30 |
31 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
32 | });
33 |
34 | test('It handles a SafeString', async function(assert) {
35 | this.set('breakup', htmlSafe(' i need some space '));
36 |
37 | await render(hbs`{{trim this.breakup}}`);
38 |
39 | let expected = 'i need some space';
40 |
41 | assert.dom('*').hasText(expected, 'correctly trims a SafeString');
42 | });
43 | });
44 |
--------------------------------------------------------------------------------
/tests/integration/helpers/truncate-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{truncate}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It truncates to 140 characters if no characterLimit is provided', async function(assert) {
11 | await render(
12 | hbs`{{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit quam enim, in suscipit est rutrum id. Etiam vitae blandit purus, sed semper sem."}}`
13 | );
14 |
15 | let expected = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit quam enim, in suscipit est rutrum id. Etiam vitae blandit pur...';
16 |
17 | assert.dom('*').hasText(expected, 'truncates to 140 characters');
18 | });
19 |
20 | test('It truncates to characterLimit provided', async function(assert) {
21 | await render(
22 | hbs`{{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit quam enim, in suscipit est rutrum id. Etiam vitae blandit purus, sed semper sem." 20}}`
23 | );
24 |
25 | let expected = 'Lorem ipsum dolor...';
26 |
27 | assert.dom('*').hasText(expected, 'truncates to characterLimit');
28 | });
29 |
30 | test('It does not truncate if string is not longer than characterLimit', async function(assert) {
31 | await render(
32 | hbs`{{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit quam enim, in suscipit est rutrum id." 140}}`
33 | );
34 |
35 | let expected = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit quam enim, in suscipit est rutrum id.';
36 |
37 | assert.dom('*').hasText(expected, 'does not truncate');
38 | });
39 |
40 | test('It truncates to characterLimit provided without an ellipsis if useEllipsis is false', async function(assert) {
41 | await render(
42 | hbs`{{truncate "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit quam enim, in suscipit est rutrum id. Etiam vitae blandit purus, sed semper sem." 20 false}}`
43 | );
44 |
45 | let expected = 'Lorem ipsum dolor si';
46 |
47 | assert.dom('*').hasText(expected, 'truncates to characterLimit without ellipsis');
48 | });
49 |
50 | test('It handles a SafeString', async function(assert) {
51 | this.set('sentence', htmlSafe('Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas hendrerit quam enim, in suscipit est rutrum id. Etiam vitae blandit purus, sed semper sem.'));
52 |
53 | await render(hbs`{{truncate this.sentence 20}}`);
54 |
55 | let expected = 'Lorem ipsum dolor...';
56 |
57 | assert.dom('*').hasText(expected, 'correctly trims a SafeString');
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/tests/integration/helpers/underscore-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{underscore}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It converts camelCase correctly', async function(assert) {
11 | await render(hbs`{{underscore "andAnother"}}`);
12 |
13 | let expected = 'and_another';
14 |
15 | assert.dom('*').hasText(expected, 'converts camelCase to underscored');
16 | });
17 |
18 | test('It converts dashes to underscores', async function(assert) {
19 | await render(hbs`{{underscore "harry-potter"}}`);
20 |
21 | let expected = 'harry_potter';
22 |
23 | assert.dom('*').hasText(expected, 'converts dashes to underscores');
24 | });
25 |
26 | test('It converts spaces to underscores', async function(assert) {
27 | await render(hbs`{{underscore "age is foolish and forgetful when it underestimates youth"}}`);
28 |
29 | let expected = 'age_is_foolish_and_forgetful_when_it_underestimates_youth';
30 |
31 | assert.dom('*').hasText(expected, 'converts spaces to underscores');
32 | });
33 |
34 | test('It correctly handles empty string input', async function(assert) {
35 | await render(hbs`{{underscore ""}}`);
36 |
37 | let expected = '';
38 |
39 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
40 | });
41 |
42 | test('It correctly handles undefined input', async function(assert) {
43 | await render(hbs`{{underscore undefined}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
48 | });
49 |
50 | test('It handles a SafeString', async function(assert) {
51 | this.set('wizard', htmlSafe('harry-potter'));
52 |
53 | await render(hbs`{{underscore this.wizard}}`);
54 |
55 | let expected = 'harry_potter';
56 |
57 | assert.dom('*').hasText(expected, 'correctly underscores a SafeString');
58 | });
59 | });
60 |
--------------------------------------------------------------------------------
/tests/integration/helpers/uppercase-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 | import { htmlSafe } from '@ember/template';
6 |
7 | module('Integration | Helper | {{uppercase}}', function(hooks) {
8 | setupRenderingTest(hooks);
9 |
10 | test('It converts all lowercase to uppercase', async function(assert) {
11 | await render(hbs`{{uppercase "all lowercase"}}`);
12 |
13 | let expected = 'ALL LOWERCASE';
14 |
15 | assert.dom('*').hasText(expected, 'converts all lowercase to uppercase');
16 | });
17 |
18 | test('It converts mixed case to uppercase', async function(assert) {
19 | await render(hbs`{{uppercase "UPPER and lower CaSe"}}`);
20 |
21 | let expected = 'UPPER AND LOWER CASE';
22 |
23 | assert.dom('*').hasText(expected, 'converts upper and lower case to uppercase');
24 | });
25 |
26 | test('It leaves special characters untouched', async function(assert) {
27 | await render(hbs`{{uppercase "special @&\/*-+^\`"}}`);
28 |
29 | let expected = 'SPECIAL @&/*-+^`';
30 |
31 | assert.dom('*').hasText(expected, 'ignores special characters');
32 | });
33 |
34 | test('It converts accented characters to uppercase', async function(assert) {
35 | await render(hbs`{{uppercase "âêîôûäëïöüéàè"}}`);
36 |
37 | let expected = 'ÂÊÎÔÛÄËÏÖÜÉÀÈ';
38 |
39 | assert.dom('*').hasText(expected, 'converts accented characters to uppercase');
40 | });
41 |
42 | test('It correctly handles empty string input', async function(assert) {
43 | await render(hbs`{{uppercase ""}}`);
44 |
45 | let expected = '';
46 |
47 | assert.dom('*').hasText(expected, 'renders empty string if input is empty string');
48 | });
49 |
50 | test('It correctly handles undefined input', async function(assert) {
51 | await render(hbs`{{uppercase undefined}}`);
52 |
53 | let expected = '';
54 |
55 | assert.dom('*').hasText(expected, 'renders empty string if undefined input');
56 | });
57 |
58 | test('It handles a SafeString', async function(assert) {
59 | this.set('screamplease', htmlSafe('noooooooo'));
60 |
61 | await render(hbs`{{uppercase this.screamplease}}`);
62 |
63 | let expected = 'NOOOOOOOO';
64 |
65 | assert.dom('*').hasText(expected, 'converts all lowercase SafeString to uppercase');
66 | });
67 | });
68 |
--------------------------------------------------------------------------------
/tests/integration/helpers/w-test.js:
--------------------------------------------------------------------------------
1 | import { module, test } from 'qunit';
2 | import { setupRenderingTest } from 'ember-qunit';
3 | import { render } from '@ember/test-helpers';
4 | import hbs from 'htmlbars-inline-precompile';
5 |
6 | module('Integration | Helper | {{w}}', function(hooks) {
7 | setupRenderingTest(hooks);
8 |
9 | test('It splits the string on whitespace', async function(assert) {
10 | this.set('string', 'foo bar\nbaz');
11 |
12 | await render(hbs`{{#each (w this.string) as |word|}}{{word}}{{/each}}`);
13 |
14 | assert.dom('*').hasText('foobarbaz', 'the words are split');
15 | });
16 |
17 | test('It makes an array of many words', async function(assert) {
18 | await render(hbs`{{#each (w "foo" "bar" "baz") as |word|}}{{word}}{{/each}}`);
19 | assert.dom('*').hasText('foobarbaz', 'the words are turned into an array');
20 | });
21 |
22 | test('You can even break up multiple strings of words', async function(assert) {
23 | await render(hbs`{{#each (w "foo bar" "baz") as |word|}}{{word}}{{/each}}`);
24 | assert.dom('*').hasText('foobarbaz', 'the words are turned into an array');
25 | });
26 |
27 | test('It gracefully handles empty arguments', async function(assert) {
28 | await render(hbs`{{#each (w) as |word|}}{{word}}{{/each}}`);
29 |
30 | assert.dom('*').hasText('', 'is blank');
31 | });
32 | });
33 |
--------------------------------------------------------------------------------
/tests/test-helper.js:
--------------------------------------------------------------------------------
1 | import Application from '../app';
2 | import config from '../config/environment';
3 | import { setApplication } from '@ember/test-helpers';
4 | import { start } from 'ember-qunit';
5 |
6 | setApplication(Application.create(config.APP));
7 |
8 | start();
9 |
--------------------------------------------------------------------------------
/tests/unit/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/tests/unit/.gitkeep
--------------------------------------------------------------------------------
/tests/unit/utils/titleize-test.js:
--------------------------------------------------------------------------------
1 | import titleize from 'dummy/utils/titleize';
2 | import { module, test } from 'qunit';
3 |
4 | module('Unit | Utility | titleize', function() {
5 | test('it titleizes a string', function(assert) {
6 | let result = titleize('my big fat greek wedding');
7 |
8 | assert.equal(result, 'My Big Fat Greek Wedding');
9 | });
10 | });
11 |
--------------------------------------------------------------------------------
/vendor/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/romulomachado/ember-cli-string-helpers/2d4f18a1e7f342ea0a0f4575bd0ddad6194e5a62/vendor/.gitkeep
--------------------------------------------------------------------------------