/
datetimeformat.spec.js
63 lines (51 loc) · 1.65 KB
/
datetimeformat.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import {I18N} from '../../src/i18n';
import {DefaultLoader} from 'aurelia-loader-default';
import {BindingSignaler} from 'aurelia-templating-resources';
import {EventAggregator} from 'aurelia-event-aggregator';
describe('datetimeformat tests', () => {
var sut;
beforeEach(() => {
var resources = {
en: {
translation: {
"lives": "__count__ life remaining",
"lives_plural": "__count__ lives remaining",
"lives_indefinite": "a life remaining",
"lives_plural_indefinite": "some lives remaining"
}
}
};
sut = new I18N(new EventAggregator(), new DefaultLoader(), new BindingSignaler());
sut.setup({
resStore: resources,
lng: 'en',
getAsync: false,
sendMissing: false,
fallbackLng: 'en',
debug: false
});
});
it('should display only the date in the setup locale format by default', () => {
var df = sut.df();
var testDate = new Date(2000, 0, 1, 0,0,1);
expect(df.format(testDate)).toEqual('1/1/2000');
});
it('should display date in the previously modified locale', (done) => {
sut.setLocale('de').then( () => {
var df = sut.df();
var testDate = new Date(2000, 0, 1, 0,0,1);
expect(df.format(testDate)).toEqual('1.1.2000');
done();
});
});
it('should display datetime',() => {
var options = {
year: 'numeric', month: '2-digit', day: '2-digit',
hour: '2-digit', minute: '2-digit', second: '2-digit',
hour12: false
};
var df = sut.df(options, 'de');
var testDate = new Date(2000, 0, 1, 0,0,1);
expect(df.format(testDate)).toEqual('01.01.2000, 00:00:01');
});
});