nexus site path corrected
[portal.git] / ecomp-portal-FE-common / client / app / filters / elipsis / elipsis.filter.spec.js
1 /*-
2  * ================================================================================
3  * eCOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 describe('Filter: elipsis', function () {
21     'use strict';
22     let filter;
23
24     beforeEach(function () {
25         module('ecompApp');
26     });
27
28     beforeEach(inject((_CacheFactory_)=> {
29         _CacheFactory_.destroyAll();
30
31     }));
32
33     it('should trim the text and return it with ... when the text length is greater than the limit"', inject(function (_$filter_) {
34         filter = _$filter_;
35         // given
36         let text = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore
37         et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex
38         ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat
39         nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim
40         id est laborum`;
41         let limit = 50;
42
43         var result = filter('elipsis')(text, limit);
44
45         expect(result).toBe(text.substr(0, 50) + '...');
46     }));
47
48     it("should return the exact string where there's no limit", inject(function (_$filter_) {
49         filter = _$filter_;
50
51         let text = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore';
52
53         let result = filter('elipsis')(text);
54
55         expect(result).toEqual(text);
56     }));
57
58 });