Skip to content

Commit

Permalink
wbotelhos#244: Drops JQuery from Test Helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Bukhtiyarov committed Oct 22, 2022
1 parent 8b73703 commit 141825a
Show file tree
Hide file tree
Showing 31 changed files with 874 additions and 1,084 deletions.
2 changes: 1 addition & 1 deletion __tests__/features/fn_cancel_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ describe('#fn_cancel', () => {
raty.cancel(true);

// then
expect(testContext.target.text()).toEqual('targetText');
expect(testContext.target.textContent).toEqual('targetText');
});
});
});
Expand Down
17 changes: 12 additions & 5 deletions __tests__/features/fn_click_spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
describe('#click', () => {
beforeEach(() => {
$('body').append('<div id="element"></div>');
var element = document.createElement('div');
element.id = 'element';
document.querySelector(`body`).appendChild(element);
});

afterEach(() => {
$('#element').remove();
$('#hint').remove();
document.querySelector('#element').remove();
});

it('clicks on star', () => {
Expand Down Expand Up @@ -97,7 +98,13 @@ describe('#click', () => {

context('with :target', function () {
beforeEach(() => {
$('body').append('<div id="hint"></div>');
var hint = document.createElement('div');
hint.id = 'hint';
document.querySelector(`body`).appendChild(hint);
});

afterEach(() => {
document.querySelector('#hint').remove();
});

context('and :targetKeep', function () {
Expand All @@ -113,7 +120,7 @@ describe('#click', () => {
raty.click(1);

// then
expect($('#hint')[0].innerHTML).toEqual('bad');
expect(document.querySelector('#hint').innerHTML).toEqual('bad');
});
});
});
Expand Down
7 changes: 4 additions & 3 deletions __tests__/features/fn_get_score_spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
describe('get #score', () => {
beforeEach(() => {
$('body').append('<div id="element"></div>');
var element = document.createElement('div');
element.id = 'element';
document.querySelector(`body`).appendChild(element);
});

afterEach(() => {
$('#element').remove();
$('#hint').remove();
document.querySelector('#element').remove();
});

it('accepts number as string', () => {
Expand Down
56 changes: 25 additions & 31 deletions __tests__/features/fn_move_spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
describe('#move', () => {
jest.useFakeTimers()
jest.useFakeTimers();

let testContext;

Expand All @@ -24,9 +24,8 @@ describe('#move', () => {
expect(raty.isMove).toEqual(false);
});

describe('with interger score', () => {

it('moves to the right point', done => {
describe('with interger score', () => {
it('moves to the right point', (done) => {
// given
var raty = new Raty(document.querySelector('#el'), {
precision: true,
Expand All @@ -39,21 +38,18 @@ describe('#move', () => {
raty.move(1);

// then
expect(testContext.target.text()).toEqual('1.0');
expect(testContext.target.textContent).toEqual('1.0');

done();
}, 100);
jest.advanceTimersByTime(100)

jest.advanceTimersByTime(100);
});
});

describe('with float score', () => {
context('with one decimal', function () {

it('moves to the right point', done => {


context('with one decimal', function () {
it('moves to the right point', (done) => {
// given
var raty = new Raty(document.querySelector('#el'), {
precision: true,
Expand All @@ -66,18 +62,17 @@ describe('#move', () => {
raty.move(1.7);

// then
expect(testContext.target.text()).toEqual('1.7');
expect(testContext.target.textContent).toEqual('1.7');

done();
}, 100);
jest.advanceTimersByTime(100)

jest.advanceTimersByTime(100);
});
});

context('with two decimal', function () {

it('moves to the right point', done => {
context('with two decimal', function () {
it('moves to the right point', (done) => {
// given
var raty = new Raty(document.querySelector('#el'), {
precision: true,
Expand All @@ -90,20 +85,19 @@ describe('#move', () => {
raty.move(1.79);

// then
expect(testContext.target.text()).toEqual('1.7');
expect(testContext.target.textContent).toEqual('1.7');

done();
}, 100);
jest.advanceTimersByTime(100)

jest.advanceTimersByTime(100);
});
});
});

describe('with string score', () => {
it('moves to the right point', done => {

jest.advanceTimersByTime(100)
it('moves to the right point', (done) => {
jest.advanceTimersByTime(100);
// given
var raty = new Raty(document.querySelector('#el'), {
precision: true,
Expand All @@ -116,17 +110,17 @@ describe('#move', () => {
raty.move('1.7');

// then
expect(testContext.target.text()).toEqual('1.7');
expect(testContext.target.textContent).toEqual('1.7');

done();
}, 100);
jest.advanceTimersByTime(100)

jest.advanceTimersByTime(100);
});
});

describe('when score is bigger then the number of stars', () => {
it('moves to the and of the last star', done => {
it('moves to the and of the last star', (done) => {
// given
var raty = new Raty(document.querySelector('#el'), {
precision: true,
Expand All @@ -139,12 +133,12 @@ describe('#move', () => {
raty.move(6.7);

// then
expect(testContext.target.text()).toEqual('5.0');
expect(testContext.target.textContent).toEqual('5.0');

done();
}, 100);
jest.advanceTimersByTime(100)

jest.advanceTimersByTime(100);
});
});
});
4 changes: 2 additions & 2 deletions __tests__/features/fn_set_score_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ describe('#fn_setScore', () => {
raty.score(6);

// then
expect(testContext.target.text()).toEqual(raty.opt.number.toString());
expect(testContext.target.textContent).toEqual(raty.opt.number.toString());
});

it('sets the :score on target', () => {
Expand All @@ -85,7 +85,7 @@ describe('#fn_setScore', () => {
raty.score(1);

// then
expect(testContext.target.text()).toEqual('1');
expect(testContext.target.textContent).toEqual('1');
});
});
});
Expand Down

0 comments on commit 141825a

Please sign in to comment.