I am writing unit test cases using karma-jasmine
for my angular
application. I have a configuration constant
something like this:
app.constant('Configuration', {
BASE_URL: 'http://localhost:3030',
SUPPORTED_BROWSERS: ['Chrome', 'Firefox', 'CriOs']
});
I need to test the unit test the Configuration
constant. I don't know whether it makes sense or not testing a constant. My suits will be something like this:
describe('Configuration.SUPPORTED_BROWSERS', function() {
it('should say only 3 browsers are supported', function() {
expect(Configuration.SUPPORTED_BROWSERS.length).toBe(2);
});
it('should say crios is supported', function() {
var temp = Configuration.SUPPORTED_BROWSERS.some(function(browser) {
return browser.toLowerCase() === 'chrome';
});
expect(temp).toBe(true);
});
it('should say firefox is supported', function() {
var temp = Configuration.SUPPORTED_BROWSERS.some(function(browser) {
return browser.toLowerCase() === 'firefox';
});
expect(temp).toBe(true);
});
it('should say chrome is supported', function() {
var temp = Configuration.SUPPORTED_BROWSERS.some(function(browser) {
return browser.toLowerCase() === 'crios';
});
expect(temp).toBe(true);
});
});
I am not sure whether it is good to test something which is constant, does not contain any logic and is hard coded.
Aucun commentaire:
Enregistrer un commentaire