|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +/* jasmine specs for plugins go here */ |
| 4 | + |
| 5 | +describe('plugins', function () { |
| 6 | + var elm, scope; |
| 7 | + |
| 8 | + var initalizeHelper = function(gridOptions) { |
| 9 | + return inject(function($rootScope, $compile) { |
| 10 | + elm = angular.element( |
| 11 | + '<div ng-grid="gridOptions" style="width: 1000px; height: 1000px"></div>' |
| 12 | + ); |
| 13 | + |
| 14 | + scope = $rootScope; |
| 15 | + scope.myData = [{ name: "Moroni", age: 50 }, |
| 16 | + { name: "Tiancum", age: 43 }, |
| 17 | + { name: "Jacob", age: 27 }, |
| 18 | + { name: "Nephi", age: 29 }, |
| 19 | + { name: "Enos", age: 34 }]; |
| 20 | + |
| 21 | + scope.gridOptions = $.extend(true, { data: 'myData' }, gridOptions); |
| 22 | + |
| 23 | + $compile(elm)(scope); |
| 24 | + |
| 25 | + scope.$digest(); |
| 26 | + }); |
| 27 | + }; |
| 28 | + // Load the ngGrid module |
| 29 | + beforeEach(module('ngGrid')); |
| 30 | + |
| 31 | + describe('ng-grid-wysiwyg-export', function () { |
| 32 | + describe('initialization', function () { |
| 33 | + var testData = function(data) { |
| 34 | + expect(data.columns.length).toBe(2); |
| 35 | + expect(data.columns[0]).toBe('name'); |
| 36 | + expect(data.columns[1]).toBe('age'); |
| 37 | + |
| 38 | + expect(data.data.length / data.columns.length).toBe(scope.myData.length); |
| 39 | + expect(data.data.length % data.columns.length).toBe(0); |
| 40 | + }; |
| 41 | + |
| 42 | + describe('function-literal', function() { |
| 43 | + beforeEach(initalizeHelper({ plugins: [ngGridWYSIWYGPlugin] })); |
| 44 | + |
| 45 | + it('should work if the plugin being passed in is a function literal', function() { |
| 46 | + testData(scope.gridOptions.plugins['ngGridWYSIWYGPlugin'].export()); |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + describe('instance', function() { |
| 51 | + beforeEach(initalizeHelper({ plugins: [new ngGridWYSIWYGPlugin()] })); |
| 52 | + |
| 53 | + it('should work if the plugin being passed in is an instance', function() { |
| 54 | + testData(scope.gridOptions.plugins['ngGridWYSIWYGPlugin'].export()); |
| 55 | + }); |
| 56 | + }); |
| 57 | + }); |
| 58 | + //describe('filtering', function () { |
| 59 | + // var testData = function (data) { |
| 60 | + // expect(data.columns.length).toBe(2); |
| 61 | + // expect(data.columns[0]).toBe('name'); |
| 62 | + // expect(data.columns[1]).toBe('age'); |
| 63 | + |
| 64 | + // expect(data.data.length).toBe(2); |
| 65 | + // }; |
| 66 | + |
| 67 | + // describe('function-literal', function () { |
| 68 | + // beforeEach(initalizeHelper({ |
| 69 | + // plugins: [ngGridWYSIWYGPlugin], |
| 70 | + // filterOptions: { filterText: '', useExternalFilter: false }, |
| 71 | + // })); |
| 72 | + |
| 73 | + // it('should work if the plugin being passed in is a function literal', function () { |
| 74 | + // testData(scope.gridOptions.plugins['ngGridWYSIWYGPlugin'].export()); |
| 75 | + // }); |
| 76 | + // }); |
| 77 | + |
| 78 | + // describe('instance', function () { |
| 79 | + // beforeEach(initalizeHelper({ |
| 80 | + // plugins: [new ngGridWYSIWYGPlugin()], |
| 81 | + // filterOptions: { filterText: 'Jacob', useExternalFilter: false }, |
| 82 | + // })); |
| 83 | + |
| 84 | + // it('should work if the plugin being passed in is an instance', function () { |
| 85 | + // var flag = false; |
| 86 | + // runs(function () { |
| 87 | + // scope.$digest(); |
| 88 | + // setTimeout(function () { |
| 89 | + // flag = true; |
| 90 | + // scope.$digest(); |
| 91 | + // }, 500); |
| 92 | + // }); |
| 93 | + // waitsFor(function () { |
| 94 | + // return flag; |
| 95 | + // }); |
| 96 | + // runs(function () { |
| 97 | + // testData(scope.gridOptions.plugins['ngGridWYSIWYGPlugin'].export()); |
| 98 | + // }); |
| 99 | + // }); |
| 100 | + // }); |
| 101 | + //}); |
| 102 | + }); |
| 103 | + |
| 104 | +}); |
0 commit comments