summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsyuilo <Syuilotan@yahoo.co.jp>2020-03-07 01:04:36 +0900
committersyuilo <Syuilotan@yahoo.co.jp>2020-03-07 01:04:36 +0900
commit1947835c5152b7cc9a23bb1a5da0caa953e9d660 (patch)
tree9d6e91f2a3ce6023b3c782c0fa0b650cdfbd2310 /test
parentRefactor (diff)
downloadsharkey-1947835c5152b7cc9a23bb1a5da0caa953e9d660.tar.gz
sharkey-1947835c5152b7cc9a23bb1a5da0caa953e9d660.tar.bz2
sharkey-1947835c5152b7cc9a23bb1a5da0caa953e9d660.zip
Resolve #6137
Diffstat (limited to 'test')
-rw-r--r--test/chart.ts79
1 files changed, 53 insertions, 26 deletions
diff --git a/test/chart.ts b/test/chart.ts
index 13f0392632..27cf2833e2 100644
--- a/test/chart.ts
+++ b/test/chart.ts
@@ -86,8 +86,8 @@ describe('Chart', () => {
it('Can updates', async(async () => {
await testChart.increment();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -109,8 +109,8 @@ describe('Chart', () => {
it('Can updates (dec)', async(async () => {
await testChart.decrement();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -130,8 +130,8 @@ describe('Chart', () => {
}));
it('Empty chart', async(async () => {
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -155,8 +155,8 @@ describe('Chart', () => {
await testChart.increment();
await testChart.increment();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -182,8 +182,8 @@ describe('Chart', () => {
await testChart.increment();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -209,8 +209,8 @@ describe('Chart', () => {
await testChart.increment();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -235,8 +235,8 @@ describe('Chart', () => {
clock.tick('05:00:00');
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -262,8 +262,8 @@ describe('Chart', () => {
clock.tick('05:00:00');
await testChart.increment();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -282,14 +282,41 @@ describe('Chart', () => {
});
}));
+ it('Can specify offset', async(async () => {
+ await testChart.increment();
+
+ clock.tick('01:00:00');
+
+ await testChart.increment();
+
+ const chartHours = await testChart.getChart('hour', 3, 1);
+ const chartDays = await testChart.getChart('day', 3, 1);
+
+ assert.deepStrictEqual(chartHours, {
+ foo: {
+ dec: [0, 0, 0],
+ inc: [1, 0, 0],
+ total: [1, 0, 0]
+ },
+ });
+
+ assert.deepStrictEqual(chartDays, {
+ foo: {
+ dec: [0, 0, 0],
+ inc: [0, 0, 0],
+ total: [0, 0, 0]
+ },
+ });
+ }));
+
describe('Grouped', () => {
it('Can updates', async(async () => {
await testGroupedChart.increment('alice');
- const aliceChartHours = await testGroupedChart.getChart('hour', 3, 'alice');
- const aliceChartDays = await testGroupedChart.getChart('day', 3, 'alice');
- const bobChartHours = await testGroupedChart.getChart('hour', 3, 'bob');
- const bobChartDays = await testGroupedChart.getChart('day', 3, 'bob');
+ const aliceChartHours = await testGroupedChart.getChart('hour', 3, 0, 'alice');
+ const aliceChartDays = await testGroupedChart.getChart('day', 3, 0, 'alice');
+ const bobChartHours = await testGroupedChart.getChart('hour', 3, 0, 'bob');
+ const bobChartDays = await testGroupedChart.getChart('day', 3, 0, 'bob');
assert.deepStrictEqual(aliceChartHours, {
foo: {
@@ -331,8 +358,8 @@ describe('Chart', () => {
await testUniqueChart.uniqueIncrement('alice');
await testUniqueChart.uniqueIncrement('bob');
- const chartHours = await testUniqueChart.getChart('hour', 3);
- const chartDays = await testUniqueChart.getChart('day', 3);
+ const chartHours = await testUniqueChart.getChart('hour', 3, 0);
+ const chartDays = await testUniqueChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: [2, 0, 0],
@@ -350,8 +377,8 @@ describe('Chart', () => {
await testChart.resync();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {
@@ -379,8 +406,8 @@ describe('Chart', () => {
await testChart.resync();
- const chartHours = await testChart.getChart('hour', 3);
- const chartDays = await testChart.getChart('day', 3);
+ const chartHours = await testChart.getChart('hour', 3, 0);
+ const chartDays = await testChart.getChart('day', 3, 0);
assert.deepStrictEqual(chartHours, {
foo: {