blob: 66e26d3e1134f0143c9fa6f2e2b1398b180a4299 [file] [log] [blame]
Matteo Scandoloa5d03d52016-07-21 11:35:46 -07001(function () {
2 'use strict';
3
4 describe('The xos.helper module', function(){
5 describe('The Comparator service', () => {
6
7 let service;
8
9 // load the application module
10 beforeEach(module('xos.helpers'));
11
12 // inject the cartService
13 beforeEach(inject(function (_Comparator_) {
14 // The injector unwraps the underscores (_) from around the parameter names when matching
15 service = _Comparator_;
16 }));
17
18 describe('given a string', () => {
19 it('should return true if expected is substring of actual', () => {
20 const res = service('test', 'te');
21 expect(res).toBeTruthy();
22 });
23
24 it('should return false if expected is not substring of actual', () => {
25 const res = service('test', 'ab');
26 expect(res).toBeFalsy();
27 });
28 });
29
30 describe('given a boolean', () => {
31 it('should return true if values match', () => {
32 expect(service(false, false)).toBeTruthy();
33 expect(service(true, true)).toBeTruthy();
34 expect(service(0, false)).toBeTruthy();
35 expect(service(1, true)).toBeTruthy();
36 });
37
38 it('should return false if values doesn\'t match', () => {
39 expect(service(false, true)).toBeFalsy();
40 expect(service(true, false)).toBeFalsy();
41 expect(service(1, false)).toBeFalsy();
42 expect(service(0, true)).toBeFalsy();
43 });
44 });
45
46 describe('given a number', () => {
47 // NOTE if numbers should we compare with === ??
48 it('should return true if expected is substring of actual', () => {
49 expect(service(12, 1)).toBeTruthy();
50 });
51
52 it('should return false if expected is not substring of actual', () => {
53 expect(service(12, 3)).toBeFalsy();
54 });
55 });
56
57 });
58 });
59
60})();