Skip to content

Commit a3a8f8d

Browse files
committed
add test suit with sqlite date type
1 parent 9392622 commit a3a8f8d

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/integration/drivers/sqlite_spec.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,40 @@ describe("Sqlite driver", function() {
7272
should.strictEqual(valueToProperty('1.200 '), 1);
7373
});
7474
});
75+
76+
describe("date", function () {
77+
var timezone = /GMT([+/-]\d{4})/.exec(new Date().toString())[1];
78+
79+
function valueToProperty (value) {
80+
return driver.valueToProperty(value, { type: 'date' });
81+
}
82+
83+
it("should return origin object when given non-string", function () {
84+
var now = new Date();
85+
should.strictEqual(valueToProperty(now), now);
86+
var array = [];
87+
should.strictEqual(valueToProperty(array), array);
88+
var obj = {};
89+
should.strictEqual(valueToProperty(obj), obj);
90+
})
91+
92+
it("should pass on normal time", function () {
93+
var normal = '2017-12-07 00:00:00';
94+
should.strictEqual(valueToProperty(normal).toString(), new Date(normal).toString());
95+
})
96+
97+
it("should pass on utc time by orm saved with local config", function () {
98+
var utc = '2017-12-07T00:00:00';
99+
should.strictEqual(valueToProperty(utc+'Z').toString(), new Date(utc+timezone).toString());
100+
})
101+
102+
it("should pass on utc time by orm saved with timezone config", function () {
103+
var utc = '2017-12-07T00:00:00';
104+
driver.config.timezone = timezone;
105+
should.strictEqual(valueToProperty(utc+'Z').toString(), new Date(utc+timezone).toString());
106+
driver.config.timezone = '';
107+
})
108+
});
75109
});
76110
});
77111

0 commit comments

Comments
 (0)