date.js
// First of all, save the already bound framebuffer
GLint qt_buffer;
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &qt_buffer);
// Do some rendering stuff in n offscreen textures
glBindFramebuffer(GL_FRAMEBUFFER, your_buffer);
glDrawBuffers(n, buffers);
// Rendering calls
// Finally use the results for the final rendering
if (glIsFramebuffer(qt_buffer))
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glDrawBuffer(GL_BACK);
}
else
{
glBindFramebuffer(GL_FRAMEBUFFER, qt_buffer);
glDrawBuffers(1, buffers);
}
// Rendering calls
date_spec.js
class DateHelper {
constructor() {
this.months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
}
postedOn(from) {
const date = new Date(from);
const day = date.getDate();
const month = this.months[date.getMonth()];
const year = date.getFullYear();
if (year === new Date().getFullYear()) {
return `${day} ${month}`;
}
return `${day} ${month} ${year}`;
}
}
所有测试目前都在通过,但由于describe('', () => {
it('', () => {
const from = 'Wed Feb 25 2015 00:38:24 GMT+0200 (EET)';
expect(newDateHelper.postedOn(from)).to.equal('25 Feb 2015');
});
it('', () => {
const from = 'Wed Feb 25 2017 00:38:24 GMT+0200 (EET)';
expect(newDateHelper.postedOn(from)).to.equal('25 Feb');
});
});
与当前年度相比,我需要每年更新这些测试。我该如何解决这个问题?
答案 0 :(得分:2)
您如何看待模板文字并将当前年份纳入其中?
const from = `Wed Feb 25 ${new Date().getFullYear()} 00:38:24 GMT+0200 (EET)`;