Skip to content

Commit ca90389

Browse files
committed
Adding tests and mocha-phantomjs running task.
1 parent dd22a3b commit ca90389

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

Gruntfile.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,11 @@ module.exports = function (grunt) {
5252
files: { 'index.html': 'html/index.html' }
5353
}
5454
},
55+
mocha_phantomjs: {
56+
all: ['test/**/*.html']
57+
}
5558
});
5659

57-
grunt.registerTask('build', ['clean', 'less', 'useminPrepare', 'concat', 'uglify', 'cssmin', 'htmlmin', 'usemin']);
60+
grunt.registerTask('build', ['clean', 'less', 'useminPrepare', 'concat', 'uglify', 'cssmin', 'htmlmin', 'usemin', 'mocha_phantomjs']);
5861
grunt.registerTask('default', ['build', 'connect', 'watch']);
5962
};

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"grunt-contrib-concat": "^0.3.0",
1414
"grunt-contrib-uglify": "^0.4.0",
1515
"grunt-contrib-htmlmin": "^0.2.0",
16-
"grunt-contrib-cssmin": "^0.9.0"
16+
"grunt-contrib-cssmin": "^0.9.0",
17+
"grunt-mocha-phantomjs": "^0.4.3"
1718
}
1819
}

test/test.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
describe('jwt library wrapper (jwt.js)', function () {
2+
it('should fail on invalid data', function () {
3+
var result = window.verify('hello', 'bye', false);
4+
expect(result.error).not.to.be(null);
5+
expect(result.result).to.be('');
6+
});
7+
it('should verify using ascii secret', function () {
8+
var result = window.verify('eyJhbGciOiJIUzI1NiIsImN0eSI6IkpXVCJ9.eyJhZ2UiOjIxfQ.8nqb61Mdqdama9pZQz07HiIySY6FZC9UjHMKHg6zhjw', 'secret', false);
9+
expect(result.error).to.be.equal(null);
10+
expect(result.result).to.be(true);
11+
});
12+
it('should verify using bas64 encoded secret', function () {
13+
var jwt = 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwczovL2F1dGgwLmF1dGgwLmNvbS8iLCJzdWIiOiJhdXRoMHw1MjdhYzIxOWQ1ZWFjYzE4ZDQwMDAwMDUiLCJhdWQiOiJhRkd2RFRvNTVHT3RkRVlyb1Fsa3RBMkFHNU1rVDY2SCIsImV4cCI6MTM5NDY5OTg5MiwiaWF0IjoxMzk0NjYzODkyfQ.kEdt5CChBWdPytkGv10mb3tqe6CEcpCQ_DLnEgq69p8';
14+
var secret = '3GdpH_8Ty1Sx_laCRwyUaSl7ddb6xfpR-352SZPFdPKdZ1S8KGtDYbiNMG3Wt61X';
15+
var result = window.verify(jwt, secret, true);
16+
expect(result.error).to.be.equal(null);
17+
expect(result.result).to.be(true);
18+
});
19+
});
File renamed without changes.

0 commit comments

Comments
 (0)