40a7fdf606
tests had wrong results before
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import { moduleFor, test } from 'ember-qunit';
|
|
|
|
moduleFor('validator:time', 'Unit | Validator | time', {
|
|
needs: ['validator:messages']
|
|
});
|
|
|
|
test('HH:mm is treated as valid', function(assert) {
|
|
let validator = this.subject();
|
|
|
|
assert.equal(validator.validate('00:00'), true);
|
|
assert.equal(validator.validate('23:59'), true);
|
|
});
|
|
|
|
test('24:00 is invalid', function(assert) {
|
|
let validator = this.subject();
|
|
|
|
assert.ok(typeof validator.validate('24:00') === 'string');
|
|
});
|
|
|
|
test('00:60 is invalid', function(assert) {
|
|
let validator = this.subject();
|
|
|
|
assert.ok(typeof validator.validate('00:60') === 'string');
|
|
});
|
|
|
|
test('an empty string is invalid', function(assert) {
|
|
let validator = this.subject();
|
|
|
|
assert.ok(typeof validator.validate('') === 'string');
|
|
});
|
|
|
|
test('null is invalid', function(assert) {
|
|
let validator = this.subject();
|
|
|
|
assert.ok(typeof validator.validate(null) === 'string');
|
|
});
|
|
|
|
test('undefined is invalid', function(assert) {
|
|
let validator = this.subject();
|
|
|
|
assert.ok(typeof validator.validate(undefined) === 'string');
|
|
});
|
|
|
|
test('a valid time wrapped by spaces is valid', function(assert) {
|
|
let validator = this.subject();
|
|
|
|
assert.equal(validator.validate(' 10:00 '), true);
|
|
});
|