Skip to content

Commit d46db0b

Browse files
Add unit tests
1 parent 84e8fb9 commit d46db0b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/functional/validation-functions-and-decorators.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ import {
193193
isTaxId,
194194
IsTaxId,
195195
IsISO4217CurrencyCode,
196+
IsISO6391,
196197
} from '../../src/decorator/decorators';
197198
import { Validator } from '../../src/validation/Validator';
198199
import { ValidatorOptions } from '../../src/validation/ValidatorOptions';
@@ -4789,3 +4790,20 @@ describe('IsISO4217', () => {
47894790
return checkInvalidValues(new MyClass(), invalidValues);
47904791
});
47914792
});
4793+
4794+
describe('IsISO6391', () => {
4795+
class MyClass {
4796+
@IsISO6391()
4797+
someProperty: string;
4798+
}
4799+
4800+
it('should not fail for a valid ISO 639-1 language code', () => {
4801+
const validValues = ['de', 'en', 'eo', 'fy', 'nl'];
4802+
return checkValidValues(new MyClass(), validValues);
4803+
});
4804+
4805+
it('should fail for invalid values', () => {
4806+
const invalidValues = [undefined, null, '', 'FR', 'xx', 'tok'];
4807+
return checkInvalidValues(new MyClass(), invalidValues);
4808+
});
4809+
});

0 commit comments

Comments
 (0)