Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 1a83d65

Browse files
author
Nick Litwin
committed
Add spec file for tc-file-input
1 parent 6b4dbde commit 1a83d65

File tree

2 files changed

+49
-10
lines changed

2 files changed

+49
-10
lines changed
Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,58 @@
11
/* jshint -W117, -W030 */
2-
describe('Topcoder File Input Directive', function() {
3-
var scope;
4-
5-
// USE AS TEMPLATE FOR DIRECTIVES
2+
describe.only('Topcoder File Input Directive', function() {
3+
var scope, element, isolateScope;
64

75
beforeEach(function() {
8-
bard.appModule('tcUIComponents');
6+
bard.appModule('topcoder');
97
bard.inject(this, '$compile', '$rootScope');
8+
scope = $rootScope.$new();
9+
10+
var html = '' +
11+
'<form>' +
12+
'<tc-file-input ' +
13+
'label-text="Preview Image"' +
14+
'field-id="DESIGN_COVER"' +
15+
'button-text="Add File"' +
16+
'file-type="jpg,jpeg,png"' +
17+
'placeholder="Image file as .jpg or .png"' +
18+
'mandatory="true"' +
19+
'set-file-reference="vm.setFileReference(file, fieldId)"' +
20+
'ng-model="vm.submissionForm.submissionZip"' +
21+
' />' +
22+
'</form>';
23+
var form = angular.element(html);
24+
element = form.find('tc-file-input');
25+
var formElement = $compile(form)(scope);
26+
scope.$digest();
27+
28+
isolateScope = element.isolateScope();
1029
});
1130

1231
bard.verifyNoOutstandingHttpRequests();
1332

14-
xdescribe('', function() {
15-
beforeEach(function() {});
33+
describe('selectFile', function() {
34+
it('triggers a click on the file input', function() {
35+
var fileInput = $(element).find('.none')[0];
36+
var mockClick = sinon.spy(fileInput, 'click');
37+
38+
isolateScope.selectFile();
39+
scope.$digest();
40+
41+
expect(mockClick).calledOnce;
42+
});
43+
});
44+
45+
describe('change events on the file input', function() {
46+
it('do things', function() {
47+
expect(false).to.be.true;
48+
});
49+
50+
it('do other things', function() {
51+
expect(false).to.be.true;
52+
});
1653

17-
it('', function() {});
54+
it('yet some more things', function() {
55+
expect(false).to.be.true;
56+
});
1857
});
1958
});

app/specs.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ <h1><a href="specs.html">Spec Runner</a></h1>
270270
<script src="/app/my-dashboard/my-dashboard.spec.js"></script>
271271
<script src="/app/my-srms/my-srms.spec.js"></script>
272272
<script src="/app/profile/profile.controller.spec.js"></script>
273+
<script src="/app/settings/settings.spec.js"></script>
273274
<script src="/app/services/authToken.service.spec.js"></script>
274275
<script src="/app/services/challenge.service.spec.js"></script>
275276
<script src="/app/services/externalAccounts.service.spec.js"></script>
@@ -280,12 +281,11 @@ <h1><a href="specs.html">Spec Runner</a></h1>
280281
<script src="/app/services/tcAuth.service.spec.js"></script>
281282
<script src="/app/services/user.service.spec.js"></script>
282283
<script src="/app/services/userStats.service.spec.js"></script>
283-
<script src="/app/settings/settings.spec.js"></script>
284284
<script src="/app/skill-picker/skill-picker.spec.js"></script>
285285
<script src="/app/submissions/submissions.spec.js"></script>
286286
<script src="/app/account/login/login.spec.js"></script>
287-
<script src="/app/account/register/register.spec.js"></script>
288287
<script src="/app/account/logout/logout.controller.spec.js"></script>
288+
<script src="/app/account/register/register.spec.js"></script>
289289
<script src="/app/account/reset-password/reset-password.spec.js"></script>
290290
<script src="/app/blocks/exception/exception-handler.provider.spec.js"></script>
291291
<script src="/app/directives/badges/badge-tooltip.spec.js"></script>

0 commit comments

Comments
 (0)