forked from cironunes/angular-testing-recipes
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathfilters.spec.js
44 lines (33 loc) · 1.1 KB
/
filters.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
describe('sampleFilter', function () {
'use strict';
var trim;
beforeEach(module('myApp'));
beforeEach(inject(function ($rootScope, $filter) {
trim = $filter('trim');
$rootScope.showLogs = false;
}));
it('should remove the whitespaces in the start and the end of a text', function () {
var text = ' angularjs ';
expect(trim(text)).toBe('angularjs');
});
it('should return an string empty if the value is equal `undefined` or `null`', function () {
expect(trim(undefined)).toBe('');
expect(trim(null)).toBe('');
});
});
describe('dummyFilter', function () {
'use strict';
var snakeCase;
beforeEach(module('myApp'));
beforeEach(inject(function ($filter) {
snakeCase = $filter('snakeCase');
}));
it('should return the input string with snakecase format', function () {
var text = 'angular js';
expect(snakeCase(text)).toBe('angular_js');
});
it('should return the input string empty if input element value is equal "undefined" or "null" ', function () {
expect(snakeCase(undefined)).toBe('');
expect(snakeCase(null)).toBe('');
});
});