Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Kurinnyi <[email protected]>
  • Loading branch information
Oleksii Kurinnyi committed Feb 28, 2017
1 parent 009a79d commit 85bc215
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
50 changes: 50 additions & 0 deletions dashboard/src/components/attribute/input-type/input-city.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2015-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*/
'use strict';
import {CheTypeCity} from './input-city.directive';

/**
* Test for CheTypeCity class.
*
* @author Oleksii Kurinnyi
*/

describe('CheTypeCity', () => {
let cheTypeCity: CheTypeCity;

let validSymbols = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.\' ';
let invalidSymbols = '`~!@#$%^&*()[]{}<>_+=:;?0123456789';

beforeEach(() => {
cheTypeCity = new CheTypeCity();
});

validSymbols.split('').forEach((validSymbol: string) => {

(function shouldPass(symbol: string) {
it(`should pass "${symbol}" symbol`, () => {
expect(cheTypeCity.symbolIsValid(symbol)).toBeTruthy();
});
})(validSymbol);

});

invalidSymbols.split('').forEach((invalidSymbol: string) => {

(function (symbol: string) {
it(`should not pass "${symbol}" symbol`, () => {
expect(cheTypeCity.symbolIsValid(symbol)).toBeFalsy();
});
})(invalidSymbol);

});

});
50 changes: 50 additions & 0 deletions dashboard/src/components/attribute/input-type/input-number.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2015-2017 Codenvy, S.A.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Codenvy, S.A. - initial API and implementation
*/
'use strict';
import {CheTypeNumber} from './input-number.directive';

/**
* Test for CheTypeNumber class.
*
* @author Oleksii Kurinnyi
*/

describe('CheTypeNumber', () => {
let cheTypeNumber: CheTypeNumber;

let validSymbols = '0123456789';
let invalidSymbols = '`~!@#$%^&*()[]{}<>_+=:;.?,/|\'"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';

beforeEach(() => {
cheTypeNumber = new CheTypeNumber();
});

validSymbols.split('').forEach((validSymbol: string) => {

(function(symbol: string) {
it(`should pass "${symbol}" symbol`, () => {
expect(cheTypeNumber.symbolIsValid(symbol)).toBeTruthy();
});
})(validSymbol);

});

invalidSymbols.split('').forEach((invalidSymbol: string) => {

(function(symbol: string) {
it(`should not pass "${symbol}" symbol`, () => {
expect(cheTypeNumber.symbolIsValid(symbol)).toBeFalsy();
});
})(invalidSymbol);

});

});

0 comments on commit 85bc215

Please sign in to comment.