github.com/sl1pm4t/consul@v1.4.5-0.20190325224627-74c31c540f9c/ui-v2/tests/unit/utils/sumOfUnhealthy-test.js (about) 1 import sumOfUnhealthy from 'consul-ui/utils/sumOfUnhealthy'; 2 import { module, test, skip } from 'qunit'; 3 4 module('Unit | Utility | sum of unhealthy'); 5 6 test('it returns the correct single count', function(assert) { 7 const expected = 1; 8 [ 9 [ 10 { 11 Status: 'critical', 12 }, 13 ], 14 [ 15 { 16 Status: 'warning', 17 }, 18 ], 19 ].forEach(function(checks) { 20 const actual = sumOfUnhealthy(checks); 21 assert.equal(actual, expected); 22 }); 23 }); 24 test('it returns the correct single count when there are none', function(assert) { 25 const expected = 0; 26 [ 27 [ 28 { 29 Status: 'passing', 30 }, 31 { 32 Status: 'passing', 33 }, 34 { 35 Status: 'passing', 36 }, 37 { 38 Status: 'passing', 39 }, 40 ], 41 [ 42 { 43 Status: 'passing', 44 }, 45 ], 46 ].forEach(function(checks) { 47 const actual = sumOfUnhealthy(checks); 48 assert.equal(actual, expected); 49 }); 50 }); 51 test('it returns the correct multiple count', function(assert) { 52 const expected = 3; 53 [ 54 [ 55 { 56 Status: 'critical', 57 }, 58 { 59 Status: 'warning', 60 }, 61 { 62 Status: 'warning', 63 }, 64 { 65 Status: 'passing', 66 }, 67 ], 68 [ 69 { 70 Status: 'passing', 71 }, 72 { 73 Status: 'critical', 74 }, 75 { 76 Status: 'passing', 77 }, 78 { 79 Status: 'warning', 80 }, 81 { 82 Status: 'warning', 83 }, 84 { 85 Status: 'passing', 86 }, 87 ], 88 ].forEach(function(checks) { 89 const actual = sumOfUnhealthy(checks); 90 assert.equal(actual, expected); 91 }); 92 }); 93 skip('it works as a factory, passing ember `get` in to create the function');