You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.0 KiB

import { initChart } from './c3-helper'
describe('c3 cache', function() {
'use strict'
var chart
var args = {
data: {
columns: [
['data1', 30, 200, 100, 400, 150, 250],
['data2', 50, 20, 10, 40, 15, 25],
['data3', 150, 120, 110, 140, 115, 125]
]
}
}
beforeEach(function(done) {
chart = initChart(chart, args, done)
})
it('returns undefined for unknown values', function() {
expect(chart.internal.getFromCache('undefined')).toBeUndefined()
})
it('returns cached value', function() {
chart.internal.addToCache('cached', 1)
expect(chart.internal.getFromCache('cached')).toEqual(1)
chart.internal.addToCache('cached', { x: 1 })
expect(chart.internal.getFromCache('cached')).toEqual({ x: 1 })
})
it('can clear cached values', function() {
chart.internal.addToCache('cached', 1)
expect(chart.internal.getFromCache('cached')).toEqual(1)
chart.internal.resetCache()
expect(chart.internal.getFromCache('cached')).toBeUndefined()
})
})