Skip to content

Commit 39252f0

Browse files
committed
added a test for column order
1 parent 479d10d commit 39252f0

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

test/unit/ngCsv/directives/ngCsv.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,27 @@ describe('ngCsv directive', function () {
129129
scope.$apply();
130130
});
131131

132+
it('Accepts optional csv-column-order attribute (input array)', function (done) {
133+
$rootScope.testDelim = [ {a:1, b:2, c:3}, {a:4, b:5, c:6} ];
134+
$rootScope.order = [ 'b', 'a', 'c' ];
135+
var element = $compile(
136+
'<div ng-csv="testDelim" csv-column-order="order" filename="custom.csv"></div>')($rootScope);
137+
138+
$rootScope.$digest();
139+
140+
var scope = element.isolateScope();
141+
142+
// Check that the compiled element contains the templated content
143+
expect(scope.$eval(scope.data)).toEqual($rootScope.testDelim);
144+
expect(scope.$eval(scope.columnOrder)).toEqual($rootScope.order);
145+
146+
scope.buildCSV(scope.data).then(function() {
147+
expect(scope.csv).toBe('2,1,3\r\n5,4,6\r\n');
148+
done();
149+
});
150+
scope.$apply();
151+
});
152+
132153
it('Accepts optional text-delimiter attribute (input array)', function (done) {
133154
$rootScope.testDelim = [[1, 'a', 2], ['b', 'c', 3]];
134155
var element = $compile(

0 commit comments

Comments
 (0)