mockup icon indicating copy to clipboard operation
mockup copied to clipboard

Tests for recurrence and querystring

Open janga1997 opened this issue 7 years ago • 4 comments

I would like to write the tests for the patterns recurrence and querystring, as a part of my application to gsoc this year. I'm assuming that they are required .

I would love to get some tips on how to proceed, because I couldn't find proper documentation on writing tests.

janga1997 avatar Mar 12 '17 21:03 janga1997

@janga1997 Thanks for showing interest in Plone foundation for writing tests. But I will suggest you should come with some more better ideas than just writing tests as the GSOC project. Writing tests may include one part of the project.

prakharjoshi avatar Mar 13 '17 05:03 prakharjoshi

@prakharjoshi i am not proposing writing tests as the project. I want to write tests as part of the proposal to get some PRs in. I am applying to a project which relates to patterns,.

janga1997 avatar Mar 13 '17 07:03 janga1997

Hi @janga1997!

All tests are in the mockup/tests folder. The filename structure is pattern-[pattern name]-test.js.

You should be able to inspect the current set of tests to give you ideas on how to write tests for recurrence.

A simple test might look like this:

/* global define, describe, beforeEach, afterEach, it */
define([
  'expect',
  'jquery',
  'sinon',
  'pat-registry',
  'mockup-patterns-recurrence',
  'mockup-patterns-select2'
], function(expect, $, sinon, registry, Recurrence) {
  'use strict';

  window.mocha.setup('bdd');
  $.fx.off = true;

  describe('Recurrence', function() {

    beforeEach(function() {
      this.$el = $('<div><input class="pat-recurrence" /></div>');
      this.clock = sinon.useFakeTimers(new Date(2016,12,23,15,30).getTime());
    });

    afterEach(function() {
      $('body').empty();
      this.clock.restore();
    });

    it('should add recurrence-widget class', function() {
      var self = this;
      expect($('.pat-recurrence', self.$el).hasClass('recurrence-widget')).to.equal(true);
   });
});

vangheem avatar Mar 13 '17 15:03 vangheem

@vangheem That helps a lot. Thanks!

janga1997 avatar Mar 13 '17 15:03 janga1997